From 82c16a4f5397575be51e00eb611e2e3ea18c7b39 Mon Sep 17 00:00:00 2001 From: akulij Date: Tue, 13 Aug 2024 06:21:04 +0300 Subject: [PATCH] Fix: app crash if no arguments passed to /secret --- cmd/app/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index c1947a4..4da0048 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -154,7 +154,8 @@ func ProcessUpdate(bc BotController, update tgbotapi.Update) { } else if possibleCommand == "/id" && user.IsAdmin() { log.Printf("THERe") bc.bot.Send(tgbotapi.NewMessage(update.Message.Chat.ID, strconv.FormatInt(update.Message.Chat.ID, 10))) - } else if possibleCommand == "/secret" && args[0] == bc.cfg.AdminPass { + } else if possibleCommand == "/secret" && len(args) > 0 && args[0] == bc.cfg.AdminPass { + bc.db.Model(&user).Update("state", "start") bc.db.Model(&user).Update("RoleBitmask", user.RoleBitmask | 0b11) // set real admin ID (0b1) and effective admin toggle (0b10) msg := tgbotapi.NewMessage(update.Message.Chat.ID, "You are admin now!") bc.bot.Send(msg)