Add delete request message config, update reason text
This commit is contained in:
parent
9605e894eb
commit
71b12970df
2 changed files with 30 additions and 14 deletions
20
main.go
20
main.go
|
|
@ -76,14 +76,18 @@ func main() {
|
|||
if update.Message.Chat.ID == b.Config.AdminChatId && update.Message.ReplyToMessage != nil {
|
||||
// handle admin declineion reason
|
||||
repliedMsg := update.Message.ReplyToMessage
|
||||
if strings.Contains(repliedMsg.Text, "(no reason provided, reply to this to send one)") {
|
||||
if strings.Contains(repliedMsg.Text, "(no reason provided, reply to this to send one, prepend with + to also send to user)") {
|
||||
// now we need to make sure the one that declined it is the one replying
|
||||
lines := strings.Split(repliedMsg.Text, "\n")
|
||||
if strings.TrimPrefix(lines[3], "Declined by: ") == update.Message.From.String() {
|
||||
reason := escapeHTML(update.Message.Text)
|
||||
if after, ok := strings.CutPrefix(update.Message.Text, "+"); ok {
|
||||
reason = escapeHTML(after)
|
||||
}
|
||||
userID, username, joinReason, declinedBy, declinedAt := GetInfoFromMsg(repliedMsg.Text)
|
||||
edit := api.NewEditMessageText(b.Config.AdminChatId, repliedMsg.MessageID,
|
||||
fmt.Sprintf(AdminDeclinedMsg,
|
||||
username, userID, joinReason, declinedBy, declinedAt, escapeHTML(update.Message.Text)))
|
||||
username, userID, joinReason, declinedBy, declinedAt, reason))
|
||||
edit.ParseMode = api.ModeHTML
|
||||
b.API.Send(edit)
|
||||
m := api.NewMessage(userID, fmt.Sprintf("Your join request was declined for the following reason:\n\n%s",
|
||||
|
|
@ -213,7 +217,7 @@ func (bot *Bot) handleCallbackQuery(query *api.CallbackQuery) {
|
|||
}
|
||||
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
||||
fmt.Sprintf(AdminDeclinedMsg,
|
||||
userString, user.From.ID, user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05"), "(no reason provided, reply to this to send one)"))
|
||||
userString, user.From.ID, user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05"), "(no reason provided, reply to this to send one, prepend with + to also send to user)"))
|
||||
edit.ParseMode = api.ModeHTML
|
||||
bot.API.Send(edit)
|
||||
|
||||
|
|
@ -221,6 +225,16 @@ func (bot *Bot) handleCallbackQuery(query *api.CallbackQuery) {
|
|||
bot.API.Request(callback)
|
||||
}
|
||||
|
||||
if bot.Config.DeleteRequestAfterDecision {
|
||||
deleteTimer := time.NewTimer(10 * time.Second)
|
||||
go func() {
|
||||
<-deleteTimer.C
|
||||
|
||||
del := api.NewDeleteMessage(bot.Config.AdminChatId, user.JoinRequestMessageID)
|
||||
bot.API.Send(del)
|
||||
}()
|
||||
}
|
||||
|
||||
delete(bot.WaitingForApproval, userId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue