handle people with no username
Marco Andronaco andronacomarco@gmail.com
Mon, 21 Oct 2024 19:30:05 +0200
1 files changed,
7 insertions(+),
1 deletions(-)
jump to
M
telegram/replace.go
→
telegram/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) {