diff --git a/internal/handlers/telegram/handler.go b/internal/handlers/telegram/handler.go index 021f49d..167618e 100644 --- a/internal/handlers/telegram/handler.go +++ b/internal/handlers/telegram/handler.go @@ -21,6 +21,13 @@ which handler to fire off */ func updateHandler(tg *Client, updates tgbotapi.UpdatesChannel) { for u := range updates { + // Don't process any messages that didn't come from the + // chat we're bridging + if u.Message.Chat.ID != tg.Settings.ChatID { + tg.logger.LogDebug("Ignored message from a telegram chat we're not bridging:", tg.Settings.ChatID) + continue + } + switch { case u.Message == nil: tg.logger.LogError("Missing message data") @@ -66,12 +73,6 @@ func messageHandler(tg *Client, u tgbotapi.Update) { return } - // Don't forward messages to IRC that didn't come from the - // chat we're bridging - if u.Message.Chat.ID != tg.Settings.ChatID { - return - } - // Telegram user replied to a message if u.Message.ReplyToMessage != nil { replyHandler(tg, u)