From 858612f4d0313621699e42d87c8c705cf9ca3f87 Mon Sep 17 00:00:00 2001 From: Yury Nevalenny Date: Mon, 13 May 2024 08:28:27 +0000 Subject: [PATCH] non-audio documents --- backend/app/telegram/telegram.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/app/telegram/telegram.go b/backend/app/telegram/telegram.go index 69e8083..cbe9b66 100644 --- a/backend/app/telegram/telegram.go +++ b/backend/app/telegram/telegram.go @@ -205,6 +205,13 @@ func handleMessage(bot *telego.Bot, message telego.Message) { voice_type = "note" case message.Document != nil: voice_type = "document" + + if !strings.HasPrefix(message.Document.MimeType, "audio/") { + log.Warnf("Ignoring non-audio document message in chat %s, mimetype: %s", chatIDString, message.Document.MimeType) + + bot.SendMessage(tu.Message(chatID, "I don't support non-audio documents yet, stay tuned for updates.").WithMessageThreadID(message.MessageThreadID)) + return + } } config.CONFIG.DataDogClient.Incr("telegram.voice_message_received", []string{"type:" + voice_type, "channel_type:" + message.Chat.Type}, 1)