From 6940150f3168a867627e926d4df6837fc346265b Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 28 Jan 2024 16:54:50 +0300 Subject: [PATCH] fix: fixed the panic when getting nil chat. --- bot.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index ea93a16..b54db31 100644 --- a/bot.go +++ b/bot.go @@ -200,7 +200,14 @@ func (bot *Bot) Run() error { u := &Update{ Update: &up, } - chn, ok := handles[u.FromChat().Type] + + // Sometimes returns nil. + fromChat := u.FromChat() + if fromChat == nil { + continue + } + + chn, ok := handles[fromChat.Type] if !ok { continue }