Apply patch
This commit is contained in:
parent
f9eabae404
commit
334fe2bf8f
4 changed files with 40 additions and 3 deletions
|
|
@ -46,6 +46,9 @@ func (bot *Bot) HandleCallbackQuery(query *api.CallbackQuery) {
|
|||
case "banc":
|
||||
bot.handleBanRequest(query, user, userString, adminUserString)
|
||||
bot.DeletePendingUser(args)
|
||||
case "remind":
|
||||
bot.sendReminder(query, user, userString, adminUserString)
|
||||
bot.API.Request(api.NewCallback(query.ID, "Reminder sent!"))
|
||||
case "cannedrespsel":
|
||||
parts := strings.Split(query.Data, "_")
|
||||
if len(parts) >= 3 {
|
||||
|
|
@ -63,6 +66,22 @@ func (bot *Bot) HandleCallbackQuery(query *api.CallbackQuery) {
|
|||
}
|
||||
}
|
||||
|
||||
func (bot *Bot) sendReminder(query *api.CallbackQuery, user *ExtendedChatJoinRequest, userString, adminUserString string) {
|
||||
utils.SendMessage(bot.API, user.From.ID, 0, bot.Config.ReminderMessage)
|
||||
|
||||
// Edit admin message to show reminder was sent
|
||||
messageText := fmt.Sprintf(AdminJoinRequestMsg, userString, user.From.ID, user.JoinReason)
|
||||
messageText += fmt.Sprintf("\n\n<b>Reminder sent by</b>: %s\n<b>Reminder sent at</b>: %s",
|
||||
adminUserString, time.Now().Format("2006-01-02 15:04:05"))
|
||||
|
||||
keyboard := utils.NewApprovalKeyboard(user.From.ID)
|
||||
|
||||
edit := api.NewEditMessageText(query.Message.Chat.ID, query.Message.MessageID, messageText)
|
||||
edit.ParseMode = api.ModeHTML
|
||||
edit.ReplyMarkup = &keyboard
|
||||
bot.API.Send(edit)
|
||||
}
|
||||
|
||||
// handleApproveRequest approves a join request and sends an approval callback.
|
||||
func (bot *Bot) handleApproveRequest(query *api.CallbackQuery, user *ExtendedChatJoinRequest, userString, adminUserString string) {
|
||||
r := api.ApproveChatJoinRequestConfig{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ func (bot *Bot) HandleJoinRequestResponse(user *ExtendedChatJoinRequest, update
|
|||
userString := utils.BuildUserString(&user.From)
|
||||
|
||||
keyboard := utils.NewApprovalKeyboard(user.From.ID)
|
||||
if bot.Config.ReminderMessage != "" {
|
||||
newButton := api.NewInlineKeyboardButtonData("Send Reminder", fmt.Sprintf("remind_%d", user.From.ID))
|
||||
keyboard.InlineKeyboard[1] = append([]api.InlineKeyboardButton{newButton}, keyboard.InlineKeyboard[1]...)
|
||||
}
|
||||
utils.EditMessageWithKeyboard(bot.API, *bot.Config.AdminChatId, user.JoinRequestMessageID,
|
||||
fmt.Sprintf(AdminJoinRequestMsg, userString, user.From.ID, user.JoinReason), &keyboard)
|
||||
|
||||
|
|
@ -27,12 +31,24 @@ func (bot *Bot) HandleJoinRequestResponse(user *ExtendedChatJoinRequest, update
|
|||
|
||||
// HandleJoinRequest initiates the join approval flow by sending the entry message and admin notification.
|
||||
func (bot *Bot) HandleJoinRequest(request *api.ChatJoinRequest) {
|
||||
// Check if user already has a pending request
|
||||
if existingUser := bot.GetPendingUser(request.From.ID); existingUser != nil {
|
||||
utils.SendMessage(bot.API, request.From.ID, 0,
|
||||
"You have already requested to join. Please send a single message as your join reason.")
|
||||
return
|
||||
}
|
||||
|
||||
utils.SendMessage(bot.API, request.From.ID, 0, bot.Config.EntryMessage)
|
||||
userString := utils.BuildUserString(&request.From)
|
||||
|
||||
keyboard := utils.NewApprovalKeyboard(request.From.ID)
|
||||
if bot.Config.ReminderMessage != "" {
|
||||
newButton := api.NewInlineKeyboardButtonData("Send Reminder", fmt.Sprintf("remind_%d", request.From.ID))
|
||||
keyboard.InlineKeyboard[1] = append([]api.InlineKeyboardButton{newButton}, keyboard.InlineKeyboard[1]...)
|
||||
}
|
||||
m := api.NewMessage(*bot.Config.AdminChatId,
|
||||
fmt.Sprintf(AdminJoinRequestMsg, userString, request.From.ID, "(awaiting user response)"))
|
||||
m.ReplyMarkup = utils.NewApprovalKeyboard(request.From.ID)
|
||||
m.ReplyMarkup = keyboard
|
||||
m.ParseMode = api.ModeHTML
|
||||
m.LinkPreviewOptions = api.LinkPreviewOptions{IsDisabled: true}
|
||||
if topic := *bot.Config.AdminChatTopicId; topic != 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue