From 2f8e15ee4a4630d9fb19d393b73c34a2b3dc2278 Mon Sep 17 00:00:00 2001 From: Nefrace Date: Thu, 28 Dec 2023 23:17:51 +0300 Subject: [PATCH] Fixed text handling in captcha --- kicker/handlers.go | 11 +++++++++-- kicker/kicker.go | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kicker/handlers.go b/kicker/handlers.go index d0e18df..1632123 100644 --- a/kicker/handlers.go +++ b/kicker/handlers.go @@ -269,8 +269,15 @@ func checkCaptcha(b *bot, update *echotron.Update) error { return nil } } - text_runes := []rune(message.Text) - guess := string(text_runes[0]) + userText := message.Text + if userText == "" { + userText = message.Caption + } + text_runes := []rune(userText) + guess := "" + if len(text_runes) > 0 { + guess = string(text_runes[0]) + } solved := false if num, err := strconv.Atoi(guess); err == nil { if num == int(user.CorrectAnswer) { diff --git a/kicker/kicker.go b/kicker/kicker.go index bf2f92d..57b0c41 100644 --- a/kicker/kicker.go +++ b/kicker/kicker.go @@ -69,8 +69,8 @@ func (b *bot) Update(update *echotron.Update) { return } } - checkCaptcha(b, update) } + checkCaptcha(b, update) checkAdminTopics(b, update) } if update.ChatMember != nil {