all repos — escarbot @ 4bc11dca690db617f89741a2f9ee7af2067b713d

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

better url parsing
Marco Andronaco andronacomarco@gmail.com
Thu, 28 Nov 2024 10:05:48 +0100
commit

4bc11dca690db617f89741a2f9ee7af2067b713d

parent

52c9b07a1684492fa7d561bdc8901ee088d39dcb

1 files changed, 4 insertions(+), 2 deletions(-)

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

@@ -3,6 +3,7 @@

import ( "fmt" "regexp" + "strings" tgbotapi "github.com/BiRabittoh/telegram-bot-api/v5" )

@@ -60,6 +61,7 @@ }

func parseText(text string, entities []tgbotapi.MessageEntity) (links []string) { var rawLinks string + runes := []rune(text) // Convert to runes to handle emojis for _, e := range entities { if e.Type == "text_link" {

@@ -72,7 +74,7 @@ if isInSpoiler(entities, e.Offset, e.Length) {

continue } - rawLinks += text[e.Offset:e.Offset+e.Length] + "\n" + rawLinks += string(runes[e.Offset:e.Offset+e.Length]) + "\n" } }

@@ -99,7 +101,7 @@

func getUserMention(user tgbotapi.User) string { var name string if user.UserName == "" { - name = user.FirstName + user.LastName + name = strings.TrimSpace(user.FirstName + " " + user.LastName) } else { name = "@" + user.UserName }