Compare commits

...

2 Commits

Author SHA1 Message Date
UserA
8a469a09b8 Reset user state on /start commandr local commits)
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
2024-08-13 06:21:45 +03:00
UserA
15a87b282c Fix: app crash if no arguments passed to /secret 2024-08-13 06:21:04 +03:00

View File

@ -122,6 +122,7 @@ func ProcessUpdate(bc BotController, update tgbotapi.Update) {
log.Printf("Args: %s", args) log.Printf("Args: %s", args)
if possibleCommand == "/start" { if possibleCommand == "/start" {
bc.db.Model(&user).Update("state", "start")
kbd := tgbotapi.NewInlineKeyboardMarkup( kbd := tgbotapi.NewInlineKeyboardMarkup(
tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardRow(
tgbotapi.NewInlineKeyboardButtonData(bc.GetBotContent("leave_ticket_button"), "leave_ticket_button"), tgbotapi.NewInlineKeyboardButtonData(bc.GetBotContent("leave_ticket_button"), "leave_ticket_button"),
@ -154,7 +155,8 @@ func ProcessUpdate(bc BotController, update tgbotapi.Update) {
} else if possibleCommand == "/id" && user.IsAdmin() { } else if possibleCommand == "/id" && user.IsAdmin() {
log.Printf("THERe") log.Printf("THERe")
bc.bot.Send(tgbotapi.NewMessage(update.Message.Chat.ID, strconv.FormatInt(update.Message.Chat.ID, 10))) 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) 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!") msg := tgbotapi.NewMessage(update.Message.Chat.ID, "You are admin now!")
bc.bot.Send(msg) bc.bot.Send(msg)