1
0
mirror of synced 2024-11-29 06:56:02 +03:00

Merge pull request #23 from DmitryZagorulko/master

add quoting messages
This commit is contained in:
Alex Lushpai 2018-07-13 15:35:03 +03:00 committed by GitHub
commit 728ffd4b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,6 +155,10 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
ExternalChatID: strconv.FormatInt(update.Message.Chat.ID, 10), ExternalChatID: strconv.FormatInt(update.Message.Chat.ID, 10),
} }
if update.Message.ReplyToMessage.MessageID != 0 {
snd.Quote = &v1.SendMessageRequestQuote{ExternalID: strconv.Itoa(update.Message.ReplyToMessage.MessageID)}
}
data, st, err := client.Messages(snd) data, st, err := client.Messages(snd)
if err != nil { if err != nil {
raven.CaptureErrorAndWait(err, nil) raven.CaptureErrorAndWait(err, nil)
@ -259,7 +263,20 @@ func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
} }
if msg.Type == "message_sent" { if msg.Type == "message_sent" {
msg, err := bot.Send(tgbotapi.NewMessage(cid, msg.Data.Content)) m := tgbotapi.NewMessage(cid, msg.Data.Content)
if msg.Data.QuoteExternalID != "" {
qid, err := strconv.Atoi(msg.Data.QuoteExternalID)
if err != nil {
raven.CaptureErrorAndWait(err, nil)
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
m.ReplyToMessageID = qid
}
msg, err := bot.Send(m)
if err != nil { if err != nil {
raven.CaptureErrorAndWait(err, nil) raven.CaptureErrorAndWait(err, nil)
logger.Error(err) logger.Error(err)