add /deop admin command

This commit is contained in:
Akulij 2025-03-27 22:34:42 +08:00
parent ee254ed865
commit e7b21a45b3

View File

@ -16,6 +16,7 @@ var adminCommands = map[string]func(BotController, tgbotapi.Update, User){
"/secret": handleSecretCommand, // activate admin mode via /secret `AdminPass` "/secret": handleSecretCommand, // activate admin mode via /secret `AdminPass`
"/panel": handlePanelCommand, // open bot settings "/panel": handlePanelCommand, // open bot settings
"/usermode": handleDefaultMessage, // temporarly disable admin mode to test ui "/usermode": handleDefaultMessage, // temporarly disable admin mode to test ui
"/deop": handleDeopCommand, // removes your admin rights at all!
"/id": handleDefaultMessage, // to check id of chat "/id": handleDefaultMessage, // to check id of chat
"/setchannelid": handleDefaultMessage, // just type it in channel which one is supposed to be lined with bot "/setchannelid": handleDefaultMessage, // just type it in channel which one is supposed to be lined with bot
} }
@ -166,6 +167,13 @@ func handleUserModeCommand(bc BotController, update tgbotapi.Update, user User)
bc.bot.Send(msg) bc.bot.Send(msg)
} }
func handleDeopCommand(bc BotController, update tgbotapi.Update, user User) {
bc.db.Model(&user).Update("RoleBitmask", user.RoleBitmask&(^uint(0b11)))
log.Printf("Set role bitmask (%b) for user: %d", user.RoleBitmask, user.ID)
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "DeOPed you!")
bc.bot.Send(msg)
}
func handleDefaultMessage(bc BotController, update tgbotapi.Update, user User) { func handleDefaultMessage(bc BotController, update tgbotapi.Update, user User) {
if user.State == "leaveticket" { if user.State == "leaveticket" {
f := update.Message.From f := update.Message.From