From be3dfb251d2fde30bb6d04b6ac96393c2af23c74 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 25 Feb 2021 23:28:54 +0100 Subject: Check rune length instead of bytes (telegram). Fixes #1409 (#1412) --- bridge/telegram/handlers.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index 48cfd316..dbbc36ea 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -181,13 +181,15 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) { // sends a EVENT_AVATAR_DOWNLOAD message to the gateway if successful. // logs an error message if it fails func (b *Btelegram) handleDownloadAvatar(userid int, channel string) { - rmsg := config.Message{Username: "system", - Text: "avatar", - Channel: channel, - Account: b.Account, - UserID: strconv.Itoa(userid), - Event: config.EventAvatarDownload, - Extra: make(map[string][]interface{})} + rmsg := config.Message{ + Username: "system", + Text: "avatar", + Channel: channel, + Account: b.Account, + UserID: strconv.Itoa(userid), + Event: config.EventAvatarDownload, + Extra: make(map[string][]interface{}), + } if _, ok := b.avatarMap[strconv.Itoa(userid)]; !ok { photos, err := b.c.GetUserProfilePhotos(tgbotapi.UserProfilePhotosConfig{UserID: userid, Limit: 1}) @@ -413,7 +415,7 @@ func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string if format == "" { format = "{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})" } - quoteMessagelength := len(quoteMessage) + quoteMessagelength := len([]rune(quoteMessage)) if b.GetInt("QuoteLengthLimit") != 0 && quoteMessagelength >= b.GetInt("QuoteLengthLimit") { runes := []rune(quoteMessage) quoteMessage = string(runes[0:b.GetInt("QuoteLengthLimit")]) -- cgit v1.2.3