From 3b329ebdd8133160432fbd4ac2e55225ce0e3b66 Mon Sep 17 00:00:00 2001 From: Akulij Date: Tue, 25 Mar 2025 11:32:20 +0800 Subject: [PATCH] add missing logic that was deleted by AI in the commit before last --- cmd/app/main.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/cmd/app/main.go b/cmd/app/main.go index 00bf1cf..8508285 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -292,6 +292,35 @@ func handleDefaultMessage(bc BotController, update tgbotapi.Update, user User) { bc.db.Model(&user).Update("state", "start") msg := tgbotapi.NewMessage(update.Message.Chat.ID, bc.GetBotContent("sended_notify")) bc.bot.Send(msg) + } else if user.IsEffectiveAdmin() { + if user.State != "start" { + if strings.HasPrefix(user.State, "imgset:") { + Literal := strings.Split(user.State, ":")[1] + if update.Message.Text == "unset" { + var l BotContent + bc.db.First(&l, "Literal", Literal) + bc.SetBotContent(Literal, "") + } + maxsize := 0 + fileid := "" + for _, p := range update.Message.Photo { + if p.FileSize > maxsize { + fileid = p.FileID + maxsize = p.FileSize + } + } + bc.SetBotContent(Literal, fileid) + bc.db.Model(&user).Update("state", "start") + msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Successfully set new image!") + bc.bot.Send(msg) + } else if strings.HasPrefix(user.State, "stringset:") { + Literal := strings.Split(user.State, ":")[1] + bc.SetBotContent(Literal, update.Message.Text) + bc.db.Model(&user).Update("state", "start") + msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Successfully set new text!") + bc.bot.Send(msg) + } + } } }