add ban confirm button

This commit is contained in:
Astra 2026-02-17 20:29:27 +00:00
parent 0bde13e836
commit 096655bb7e

View file

@ -39,6 +39,10 @@ func (bot *Bot) HandleCallbackQuery(query *api.CallbackQuery) {
case "decline": case "decline":
bot.handleDeclineRequest(query, user, userString, adminUserString) bot.handleDeclineRequest(query, user, userString, adminUserString)
case "ban": case "ban":
bot.showBanConfirmation(query, user, userString)
bot.API.Request(api.NewCallback(query.ID, ""))
return
case "banc":
bot.handleBanRequest(query, user, userString, adminUserString) bot.handleBanRequest(query, user, userString, adminUserString)
} }
@ -127,6 +131,23 @@ func (bot *Bot) handleBanRequest(query *api.CallbackQuery, user *ExtendedChatJoi
bot.API.Request(api.NewCallback(query.ID, "User banned.")) bot.API.Request(api.NewCallback(query.ID, "User banned."))
} }
// showBanConfirmation displays a confirmation prompt for the ban action.
func (bot *Bot) showBanConfirmation(query *api.CallbackQuery, user *ExtendedChatJoinRequest, userString string) {
approveBtn := api.NewInlineKeyboardButtonData("Approve", fmt.Sprintf("approve_%d", user.From.ID))
declineBtn := api.NewInlineKeyboardButtonData("Decline", fmt.Sprintf("decline_%d", user.From.ID))
confirmBtn := api.NewInlineKeyboardButtonData("Ban (confirm)", fmt.Sprintf("banc_%d", user.From.ID))
keyboard := api.NewInlineKeyboardMarkup(
[]api.InlineKeyboardButton{approveBtn, declineBtn},
[]api.InlineKeyboardButton{confirmBtn},
)
msg := fmt.Sprintf("Are you sure you want to ban %s for 24 hours?", userString)
edit := api.NewEditMessageText(query.Message.Chat.ID, query.Message.MessageID, msg)
edit.ReplyMarkup = &keyboard
edit.ParseMode = api.ModeHTML
bot.API.Send(edit)
}
// HandleDeclineReason allows admins to provide a decline reason by replying to decline messages. // HandleDeclineReason allows admins to provide a decline reason by replying to decline messages.
func (bot *Bot) HandleDeclineReason(update *api.Update) { func (bot *Bot) HandleDeclineReason(update *api.Update) {
repliedMsg := update.Message.ReplyToMessage repliedMsg := update.Message.ReplyToMessage