Update callbacks.go
This commit is contained in:
parent
67ce076a7c
commit
f9eabae404
1 changed files with 27 additions and 28 deletions
|
|
@ -76,6 +76,33 @@ 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"),
|
||||||
|
|
@ -109,34 +136,6 @@ func (bot *Bot) handleApproveRequest(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."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue