Fix declined reason breaking formatting
This commit is contained in:
parent
825efc692d
commit
849454016d
1 changed files with 12 additions and 7 deletions
19
main.go
19
main.go
|
|
@ -80,13 +80,12 @@ func main() {
|
|||
// 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() {
|
||||
|
||||
userID, username, joinReason, declinedBy, declinedAt := GetInfoFromMsg(repliedMsg.Text)
|
||||
edit := api.NewEditMessageText(b.Config.AdminChatId, repliedMsg.MessageID,
|
||||
strings.Replace(repliedMsg.Text, "(no reason provided, reply to this to send one)",
|
||||
escapeHTML(update.Message.Text), 1))
|
||||
fmt.Sprintf(AdminDeclinedMsg,
|
||||
username, userID, joinReason, declinedBy, declinedAt, escapeHTML(update.Message.Text)))
|
||||
edit.ParseMode = api.ModeHTML
|
||||
b.API.Send(edit)
|
||||
userID := GetUserIDFromMessage(repliedMsg.Text)
|
||||
m := api.NewMessage(userID, fmt.Sprintf("Your join request was declined for the following reason:\n\n%s",
|
||||
update.Message.Text))
|
||||
b.API.Send(m)
|
||||
|
|
@ -257,9 +256,15 @@ func newApprovalKeyboard(userID int64) api.InlineKeyboardMarkup {
|
|||
return api.NewInlineKeyboardMarkup([]api.InlineKeyboardButton{approveBtn, declineBtn})
|
||||
}
|
||||
|
||||
func GetUserIDFromMessage(msg string) int64 {
|
||||
func GetInfoFromMsg(msg string) (userId int64, username, joinReason, declinedBy, declinedAt string) {
|
||||
start := strings.Index(msg, "[")
|
||||
end := strings.Index(msg, "]")
|
||||
num, _ := strconv.Atoi(msg[start+1 : end])
|
||||
return int64(num)
|
||||
userID, _ := strconv.Atoi(msg[start+1 : end])
|
||||
username = msg[31 : start-1]
|
||||
lines := strings.Split(msg, "\n")
|
||||
joinReason = strings.TrimPrefix(lines[2], "Join reason: ")
|
||||
declinedBy = strings.TrimPrefix(lines[3], "Declined by: ")
|
||||
declinedAt = strings.TrimPrefix(lines[4], "Declined at: ")
|
||||
|
||||
return int64(userID), username, joinReason, declinedBy, declinedAt
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue