mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-06 16:57:29 +08:00
fix telegram reply threading via reply parameters
This commit is contained in:
@@ -289,7 +289,9 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
|
|||||||
if markup != nil {
|
if markup != nil {
|
||||||
sendParams.WithReplyMarkup(markup)
|
sendParams.WithReplyMarkup(markup)
|
||||||
}
|
}
|
||||||
_ = strings.TrimSpace(msg.ReplyToID) // reserved for provider-level reply threading support
|
if replyID, ok := parseTelegramMessageID(msg.ReplyToID); ok {
|
||||||
|
sendParams.ReplyParameters = &telego.ReplyParameters{MessageID: replyID}
|
||||||
|
}
|
||||||
|
|
||||||
sendCtx, cancelSend := withTelegramAPITimeout(ctx)
|
sendCtx, cancelSend := withTelegramAPITimeout(ctx)
|
||||||
_, err = c.bot.SendMessage(sendCtx, sendParams)
|
_, err = c.bot.SendMessage(sendCtx, sendParams)
|
||||||
@@ -505,6 +507,18 @@ func parseChatID(chatIDStr string) (int64, error) {
|
|||||||
return id, err
|
return id, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseTelegramMessageID(raw string) (int, bool) {
|
||||||
|
raw = strings.TrimSpace(raw)
|
||||||
|
if raw == "" {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
var id int
|
||||||
|
if _, err := fmt.Sscanf(raw, "%d", &id); err != nil || id <= 0 {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
return id, true
|
||||||
|
}
|
||||||
|
|
||||||
func markdownToTelegramHTML(text string) string {
|
func markdownToTelegramHTML(text string) string {
|
||||||
if text == "" {
|
if text == "" {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user