all repos — escarbot @ 661438f9080f348c334f56cc65014c5288474afb

Earthbound Café's custom Telegram bot, with lots of cool utilities built-in.

handle people with no username
Marco Andronaco andronacomarco@gmail.com
Mon, 21 Oct 2024 19:30:05 +0200
commit

661438f9080f348c334f56cc65014c5288474afb

parent

0d332b999873f9a6d035d0977c0649b8ef7b6b19

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M telegram/replace.gotelegram/replace.go

@@ -70,7 +70,13 @@ return links

} func getUserMention(user tgbotapi.User) string { - return fmt.Sprintf("[@%s](tg://user?id=%d)", user.UserName, user.ID) + var name string + if user.UserName == "" { + name = user.FirstName + user.LastName + } else { + name = "@" + user.UserName + } + return fmt.Sprintf("[%s](tg://user?id=%d)", name, user.ID) } func handleLinks(bot *tgbotapi.BotAPI, message *tgbotapi.Message) {