Update telegram-join-approval-bot submodule and apply patches
This commit is contained in:
parent
394c520e6f
commit
67ce076a7c
2 changed files with 29 additions and 28 deletions
|
|
@ -76,33 +76,6 @@ func (bot *Bot) handleApproveRequest(query *api.CallbackQuery, user *ExtendedCha
|
||||||
return
|
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,
|
messageText := fmt.Sprintf(AdminDeclinedMsg,
|
||||||
userString, user.From.ID, user.JoinReason, adminUserString,
|
userString, user.From.ID, user.JoinReason, adminUserString,
|
||||||
time.Now().Format("2006-01-02 15:04:05"),
|
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)
|
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."))
|
bot.API.Request(api.NewCallback(query.ID, "Join request declined."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func EscapeHTML(s string) string {
|
||||||
func NewApprovalKeyboard(userID int64) api.InlineKeyboardMarkup {
|
func NewApprovalKeyboard(userID int64) api.InlineKeyboardMarkup {
|
||||||
approveBtn := api.NewInlineKeyboardButtonData("Approve", fmt.Sprintf("approve_%d", userID))
|
approveBtn := api.NewInlineKeyboardButtonData("Approve", fmt.Sprintf("approve_%d", userID))
|
||||||
declineBtn := api.NewInlineKeyboardButtonData("Decline", fmt.Sprintf("decline_%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(
|
return api.NewInlineKeyboardMarkup(
|
||||||
[]api.InlineKeyboardButton{approveBtn, declineBtn},
|
[]api.InlineKeyboardButton{approveBtn, declineBtn},
|
||||||
[]api.InlineKeyboardButton{banBtn},
|
[]api.InlineKeyboardButton{banBtn},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue