add ban confirm button
This commit is contained in:
parent
0bde13e836
commit
096655bb7e
1 changed files with 21 additions and 0 deletions
|
|
@ -39,6 +39,10 @@ func (bot *Bot) HandleCallbackQuery(query *api.CallbackQuery) {
|
|||
case "decline":
|
||||
bot.handleDeclineRequest(query, user, userString, adminUserString)
|
||||
case "ban":
|
||||
bot.showBanConfirmation(query, user, userString)
|
||||
bot.API.Request(api.NewCallback(query.ID, ""))
|
||||
return
|
||||
case "banc":
|
||||
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."))
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (bot *Bot) HandleDeclineReason(update *api.Update) {
|
||||
repliedMsg := update.Message.ReplyToMessage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue