Skip to content

Commit

Permalink
Fixing locale check
Browse files Browse the repository at this point in the history
Fixes a bug in locale check where update.InlineQuery may be nil.
  • Loading branch information
mys721tx committed Jan 22, 2025
1 parent 84c451f commit a0c93b4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pgb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a0c93b4

Please sign in to comment.