commit 3bcfedcc7c68c309f3a931017f1d670bd464d108
Author: Humorhenker <36549980+Humorhenker@users.noreply.github.com>
Date: Thu Jan 30 00:02:33 2020 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 5da535d..105d568 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -1166 +1167 @@ type Protocol struct {
Protocol string // all protocols
QuoteDisable bool // telegram
QuoteFormat string // telegram
+ QuoteLengthLimit int // telegram
RejoinDelay int // IRC
ReplaceMessages [][]string // all protocols
ReplaceNicks [][]string // all protocols
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go
index bbe1243..a74a3f8 100644
--- a/bridge/telegram/handlers.go
+++ b/bridge/telegram/handlers.go
@@ -3576 +35714 @@ 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)
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index 61c8617..af3c5df 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -8536 +85310 @@ UseInsecureURL=false
#OPTIONAL (default false)
QuoteDisable=false
+#Set the max. quoted length if 0 the whole message will be quoted
+#OPTIONAL (default 0)
+QuoteLengthLimit=0
+
#Format quoted/reply messages
#OPTIONAL (default "{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})")
QuoteFormat="{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})"