summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-02-25 23:28:54 +0100
committerGitHub <noreply@github.com>2021-02-25 23:28:54 +0100
commitbe3dfb251d2fde30bb6d04b6ac96393c2af23c74 (patch)
treed00561a49f5356a379db36653478ca31aa01fc90
parent4e11e29f706a1ddcc7a0e6a017d3e084f7fa17ea (diff)
downloadmatterbridge-msglm-be3dfb251d2fde30bb6d04b6ac96393c2af23c74.tar.gz
matterbridge-msglm-be3dfb251d2fde30bb6d04b6ac96393c2af23c74.tar.bz2
matterbridge-msglm-be3dfb251d2fde30bb6d04b6ac96393c2af23c74.zip
Check rune length instead of bytes (telegram). Fixes #1409 (#1412)
-rw-r--r--bridge/telegram/handlers.go18
1 files 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")])