summaryrefslogtreecommitdiffstats
path: root/bridge/telegram
diff options
context:
space:
mode:
authorHumorhenker <36549980+Humorhenker@users.noreply.github.com>2020-01-30 00:02:33 +0100
committerGitHub <noreply@github.com>2020-01-30 00:02:33 +0100
commitfc30b1bacc4ceb6dd978c5838609371fa6abd801 (patch)
treec52a2ebfee544fc4de3c033aaacfa4424027e28d /bridge/telegram
parent0dd19af6e8b3c122ddc8c96e5ab259d89023d561 (diff)
downloadmatterbridge-msglm-fc30b1bacc4ceb6dd978c5838609371fa6abd801.tar.gz
matterbridge-msglm-fc30b1bacc4ceb6dd978c5838609371fa6abd801.tar.bz2
matterbridge-msglm-fc30b1bacc4ceb6dd978c5838609371fa6abd801.zip
Add QuoteLengthLimit option (telegram) fixes #963 (#985)
* QuoteLengthLimit option added to limit max. quoted message length if QuoteLengthLimit = 0 the whole message will be quoted
Diffstat (limited to 'bridge/telegram')
-rw-r--r--bridge/telegram/handlers.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go
index bbe12437..a74a3f8a 100644
--- a/bridge/telegram/handlers.go
+++ b/bridge/telegram/handlers.go
@@ -357,6 +357,14 @@ func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string
if format == "" {
format = "{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})"
}
+ quoteMessagelength := len(quoteMessage)
+ if b.GetInt("QuoteLengthLimit") != 0 && quoteMessagelength >= b.GetInt("QuoteLengthLimit") {
+ runes := []rune(quoteMessage)
+ quoteMessage = string(runes[0:b.GetInt("QuoteLengthLimit")])
+ if quoteMessagelength > b.GetInt("QuoteLengthLimit") {
+ quoteMessage += "..."
+ }
+ }
format = strings.Replace(format, "{MESSAGE}", message, -1)
format = strings.Replace(format, "{QUOTENICK}", quoteNick, -1)
format = strings.Replace(format, "{QUOTEMESSAGE}", quoteMessage, -1)