diff --git a/kicker/handlers.go b/kicker/handlers.go index fdde31a..b22d5a5 100644 --- a/kicker/handlers.go +++ b/kicker/handlers.go @@ -71,7 +71,7 @@ func userLeft(b *bot, update *tb.Update) error { func checkCaptcha(b *bot, update *tb.Update) error { message := update.Message - sender := message.ForwardFrom + sender := message.From d := db.GetDatabase() ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() diff --git a/kicker/kicker.go b/kicker/kicker.go index 0c554f0..10d5452 100644 --- a/kicker/kicker.go +++ b/kicker/kicker.go @@ -18,26 +18,27 @@ type bot struct { } func (b *bot) Update(update *tb.Update) { - if len(update.Message.NewChatMembers) != 0 { - for _, user := range update.Message.NewChatMembers { - if user.ID == b.Me.ID { - botAdded(b, update) + if update.Message != nil { + if len(update.Message.NewChatMembers) != 0 { + for _, user := range update.Message.NewChatMembers { + if user.ID == b.Me.ID { + botAdded(b, update) + } } - } - userJoined(b, update) - return - } - if update.Message.LeftChatMember != nil { - userLeft(b, update) - return - } - if update.Message.Text != "" { - if update.Message.Text == "/settopic" { - setTopic(b, update) + userJoined(b, update) return } - checkCaptcha(b, update) - + if update.Message.LeftChatMember != nil { + userLeft(b, update) + return + } + if update.Message.Text != "" { + if update.Message.Text == "/settopic" { + setTopic(b, update) + return + } + checkCaptcha(b, update) + } } }