1
0
mirror of synced 2024-11-22 12:26:02 +03:00

Process only text messages from Telegram

This commit is contained in:
Ilyas Salikhov 2018-06-01 15:14:29 +03:00
parent b6f48255ef
commit d56f97052b

View File

@ -84,6 +84,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
var client = v1.New(c.MGURL, c.MGToken) var client = v1.New(c.MGURL, c.MGToken)
if update.Message != nil { if update.Message != nil {
if update.Message.Text != "" {
snd := v1.SendData{ snd := v1.SendData{
Message: v1.SendMessage{ Message: v1.SendMessage{
Message: v1.Message{ Message: v1.Message{
@ -115,8 +116,10 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
logger.Debugf("telegramWebhookHandler Type: SendMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data) logger.Debugf("telegramWebhookHandler Type: SendMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
} }
} }
}
if update.EditedMessage != nil { if update.EditedMessage != nil {
if update.EditedMessage.Text != "" {
snd := v1.UpdateData{ snd := v1.UpdateData{
Message: v1.UpdateMessage{ Message: v1.UpdateMessage{
Message: v1.Message{ Message: v1.Message{
@ -140,6 +143,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
logger.Debugf("telegramWebhookHandler Type: UpdateMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data) logger.Debugf("telegramWebhookHandler Type: UpdateMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
} }
} }
}
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
} }