Add @ to username
This commit is contained in:
parent
18e606f368
commit
8cb988abd7
1 changed files with 30 additions and 4 deletions
34
main.go
34
main.go
|
|
@ -76,9 +76,15 @@ func (bot *Bot) handleJoinRequestResponse(user *ExtendedChatJoinRequest, update
|
||||||
if user.JoinReason == "" {
|
if user.JoinReason == "" {
|
||||||
user.JoinReason = escapeMarkdown(update.Text)
|
user.JoinReason = escapeMarkdown(update.Text)
|
||||||
|
|
||||||
|
userString := ""
|
||||||
|
if user.From.UserName != "" {
|
||||||
|
userString = "@" + user.From.UserName
|
||||||
|
} else {
|
||||||
|
userString = fmt.Sprintf("%s %s (no username)", user.From.FirstName, user.From.LastName)
|
||||||
|
}
|
||||||
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
||||||
fmt.Sprintf(AdminJoinRequestMsg,
|
fmt.Sprintf(AdminJoinRequestMsg,
|
||||||
user.From.String(), user.JoinReason))
|
userString, user.JoinReason))
|
||||||
keyboard := newApprovalKeyboard(user.From.ID)
|
keyboard := newApprovalKeyboard(user.From.ID)
|
||||||
edit.ReplyMarkup = &keyboard
|
edit.ReplyMarkup = &keyboard
|
||||||
edit.ParseMode = api.ModeMarkdown
|
edit.ParseMode = api.ModeMarkdown
|
||||||
|
|
@ -102,8 +108,14 @@ func (bot *Bot) handleJoinRequest(request *api.ChatJoinRequest) {
|
||||||
m.ParseMode = api.ModeMarkdown
|
m.ParseMode = api.ModeMarkdown
|
||||||
bot.API.Send(m)
|
bot.API.Send(m)
|
||||||
|
|
||||||
|
userString := ""
|
||||||
|
if request.From.UserName != "" {
|
||||||
|
userString = "@" + request.From.UserName
|
||||||
|
} else {
|
||||||
|
userString = fmt.Sprintf("%s %s (no username)", request.From.FirstName, request.From.LastName)
|
||||||
|
}
|
||||||
m = api.NewMessage(bot.Config.AdminChatId,
|
m = api.NewMessage(bot.Config.AdminChatId,
|
||||||
fmt.Sprintf(AdminJoinRequestMsg, request.From.String(), "(awaiting user response)"))
|
fmt.Sprintf(AdminJoinRequestMsg, userString, "(awaiting user response)"))
|
||||||
m.ReplyMarkup = newApprovalKeyboard(request.From.ID)
|
m.ReplyMarkup = newApprovalKeyboard(request.From.ID)
|
||||||
m.ParseMode = api.ModeMarkdown
|
m.ParseMode = api.ModeMarkdown
|
||||||
if bot.Config.AdminChatTopicId != 0 {
|
if bot.Config.AdminChatTopicId != 0 {
|
||||||
|
|
@ -141,9 +153,16 @@ func (bot *Bot) handleCallbackQuery(query *api.CallbackQuery) {
|
||||||
UserID: user.ChatJoinRequest.From.ID,
|
UserID: user.ChatJoinRequest.From.ID,
|
||||||
}
|
}
|
||||||
bot.API.Send(r)
|
bot.API.Send(r)
|
||||||
|
|
||||||
|
userString := ""
|
||||||
|
if user.From.UserName != "" {
|
||||||
|
userString = "@" + user.From.UserName
|
||||||
|
} else {
|
||||||
|
userString = fmt.Sprintf("%s %s (no username)", user.From.FirstName, user.From.LastName)
|
||||||
|
}
|
||||||
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
||||||
fmt.Sprintf(AdminApprovedMsg,
|
fmt.Sprintf(AdminApprovedMsg,
|
||||||
user.From.String(), user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05")))
|
userString, user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05")))
|
||||||
edit.ParseMode = api.ModeMarkdown
|
edit.ParseMode = api.ModeMarkdown
|
||||||
bot.API.Send(edit)
|
bot.API.Send(edit)
|
||||||
|
|
||||||
|
|
@ -161,9 +180,16 @@ func (bot *Bot) handleCallbackQuery(query *api.CallbackQuery) {
|
||||||
UserID: user.ChatJoinRequest.From.ID,
|
UserID: user.ChatJoinRequest.From.ID,
|
||||||
}
|
}
|
||||||
bot.API.Send(r)
|
bot.API.Send(r)
|
||||||
|
|
||||||
|
userString := ""
|
||||||
|
if user.From.UserName != "" {
|
||||||
|
userString = "@" + user.From.UserName
|
||||||
|
} else {
|
||||||
|
userString = fmt.Sprintf("%s %s (no username)", user.From.FirstName, user.From.LastName)
|
||||||
|
}
|
||||||
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
edit := api.NewEditMessageText(bot.Config.AdminChatId, user.JoinRequestMessageID,
|
||||||
fmt.Sprintf(AdminRejectedMsg,
|
fmt.Sprintf(AdminRejectedMsg,
|
||||||
user.From.String(), user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05")))
|
userString, user.JoinReason, query.From.String(), time.Now().Format("2006-01-02 15:04:05")))
|
||||||
edit.ParseMode = api.ModeMarkdown
|
edit.ParseMode = api.ModeMarkdown
|
||||||
bot.API.Send(edit)
|
bot.API.Send(edit)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue