aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-10-29 15:47:35 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-10-29 15:52:33 +0300
commit67b8ad57f0aab1a033cbd8bcc8e75cf23342f5f9 (patch)
tree02f41432fc170dc0aea66e7a75be8b5009723064 /telegram
parent282a6fc21b9626ab1bdc9c5a78162d90b7d28aa2 (diff)
Fix reply length for hrunicode messagesv1.8.3
Diffstat (limited to 'telegram')
-rw-r--r--telegram/utils.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index 47a851a..6edea31 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -16,6 +16,7 @@ import (
"strconv"
"strings"
"time"
+ "unicode/utf8"
"dev.narayana.im/narayana/telegabber/telegram/cache"
"dev.narayana.im/narayana/telegabber/telegram/formatter"
@@ -42,7 +43,7 @@ var spaceRegex = regexp.MustCompile(`\s+`)
var replyRegex = regexp.MustCompile("\\A>>? ?([0-9]+)\\n")
const newlineChar string = "\n"
-const messageHeaderSeparator string = " | "
+const messageHeaderSeparator string = " | " // no hrunicode allowed here yet
// GetContactByUsername resolves username to user id retrieves user and chat information
func (c *Client) GetContactByUsername(username string) (*client.Chat, *client.User, error) {
@@ -845,7 +846,7 @@ func (c *Client) contentToFile(content client.MessageContent) (*client.File, *cl
func (c *Client) countCharsInLines(lines *[]string) (count int) {
for _, line := range *lines {
- count += len(line)
+ count += utf8.RuneCountInString(line)
}
return
}
@@ -895,7 +896,7 @@ func (c *Client) messageToPrefix(message *client.Message, previewString string,
}
replyLine := "reply: " + c.formatMessage(message.ChatId, message.ReplyToMessageId, true, replyMsg)
prefix = append(prefix, replyLine)
- replyEnd = replyStart + len(replyLine)
+ replyEnd = replyStart + utf8.RuneCountInString(replyLine)
if len(prefix) > 0 {
replyEnd += len(messageHeaderSeparator)
}