From 67ce076a7c6a2b37ba3d97ea2ac795f97b71dccd Mon Sep 17 00:00:00 2001 From: Astra Date: Wed, 11 Mar 2026 09:23:38 +0000 Subject: [PATCH] Update telegram-join-approval-bot submodule and apply patches --- handlers/callbacks.go | 55 ++++++++++++++++++++++--------------------- pkg/utils/utils.go | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/handlers/callbacks.go b/handlers/callbacks.go index 59afc85..c3d9b96 100644 --- a/handlers/callbacks.go +++ b/handlers/callbacks.go @@ -76,33 +76,6 @@ func (bot *Bot) handleApproveRequest(query *api.CallbackQuery, user *ExtendedCha return } - utils.EditMessage(bot.API, query.Message.Chat.ID, query.Message.MessageID, - fmt.Sprintf(AdminApprovedMsg, - userString, user.From.ID, user.JoinReason, adminUserString, - time.Now().Format("2006-01-02 15:04:05"), - ), - ) - - if bot.Config.SendApprovalMessage { - utils.SendMessage(bot.API, user.From.ID, 0, bot.Config.ApprovalMessage) - } - - bot.API.Request(api.NewCallback(query.ID, "Join request approved.")) -} - -// handleDeclineRequest declines a join request and sends a decline callback. -func (bot *Bot) handleDeclineRequest(query *api.CallbackQuery, user *ExtendedChatJoinRequest, userString, adminUserString string) { - r := api.DeclineChatJoinRequest{ - ChatConfig: api.ChatConfig{ChatID: user.ChatJoinRequest.Chat.ID}, - UserID: user.ChatJoinRequest.From.ID, - } - - if _, err := bot.API.Request(r); err != nil { - log.Println(err) - bot.restoreMessage(query) - return - } - messageText := fmt.Sprintf(AdminDeclinedMsg, userString, user.From.ID, user.JoinReason, adminUserString, time.Now().Format("2006-01-02 15:04:05"), @@ -136,6 +109,34 @@ func (bot *Bot) handleDeclineRequest(query *api.CallbackQuery, user *ExtendedCha bot.API.Send(edit) + if bot.Config.SendApprovalMessage { + utils.SendMessage(bot.API, user.From.ID, 0, bot.Config.ApprovalMessage) + } + + bot.API.Request(api.NewCallback(query.ID, "Join request approved.")) +} + +// handleDeclineRequest declines a join request and sends a decline callback. +func (bot *Bot) handleDeclineRequest(query *api.CallbackQuery, user *ExtendedChatJoinRequest, userString, adminUserString string) { + r := api.DeclineChatJoinRequest{ + ChatConfig: api.ChatConfig{ChatID: user.ChatJoinRequest.Chat.ID}, + UserID: user.ChatJoinRequest.From.ID, + } + + if _, err := bot.API.Request(r); err != nil { + log.Println(err) + bot.restoreMessage(query) + return + } + + utils.EditMessage(bot.API, query.Message.Chat.ID, query.Message.MessageID, + fmt.Sprintf(AdminDeclinedMsg, + userString, user.From.ID, user.JoinReason, adminUserString, + time.Now().Format("2006-01-02 15:04:05"), + defaultReason, + ), + ) + bot.API.Request(api.NewCallback(query.ID, "Join request declined.")) } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 371fc2c..1456b40 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -38,7 +38,7 @@ func EscapeHTML(s string) string { func NewApprovalKeyboard(userID int64) api.InlineKeyboardMarkup { approveBtn := api.NewInlineKeyboardButtonData("Approve", fmt.Sprintf("approve_%d", userID)) declineBtn := api.NewInlineKeyboardButtonData("Decline", fmt.Sprintf("decline_%d", userID)) - banBtn := api.NewInlineKeyboardButtonData("Ban", fmt.Sprintf("ban_%d", userID)) + banBtn := api.NewInlineKeyboardButtonData("Ban (24h)", fmt.Sprintf("ban_%d", userID)) return api.NewInlineKeyboardMarkup( []api.InlineKeyboardButton{approveBtn, declineBtn}, []api.InlineKeyboardButton{banBtn},