From a0c93b4988634b87e1ef3b0ce024ce6a31d8a5ab Mon Sep 17 00:00:00 2001 From: Yishen Miao Date: Wed, 22 Jan 2025 13:57:18 -0800 Subject: [PATCH] Fixing locale check Fixes a bug in locale check where update.InlineQuery may be nil. --- pgb.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pgb.go b/pgb.go index 4a77123..9aa4ea0 100644 --- a/pgb.go +++ b/pgb.go @@ -240,12 +240,15 @@ func main() { // 6. Sends the generated results back to the bot as a response to the inline // query. func handler(ctx context.Context, b *bot.Bot, update *models.Update) { - locale := update.InlineQuery.From.LanguageCode - if update.InlineQuery == nil { return } + locale := "zh" + if update.InlineQuery.From != nil && update.InlineQuery.From.LanguageCode != "" { + locale = update.InlineQuery.From.LanguageCode + } + h := sha256.New() if err := binary.Write(