summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-05-11 20:59:15 +0200
committerWim <wim@42.be>2018-05-11 20:59:15 +0200
commit406a54b597271add1e297231e6f260895eff8f1d (patch)
tree2a8c10222edff3a7bb3a4c280efaaf674c8513d7
parentbe04d1a8627456f07c8ab9800d12532211897991 (diff)
downloadmatterbridge-msglm-406a54b597271add1e297231e6f260895eff8f1d.tar.gz
matterbridge-msglm-406a54b597271add1e297231e6f260895eff8f1d.tar.bz2
matterbridge-msglm-406a54b597271add1e297231e6f260895eff8f1d.zip
Add QuoteFormat option (telegram). Closes #413
-rw-r--r--bridge/config/config.go1
-rw-r--r--bridge/telegram/telegram.go13
-rw-r--r--matterbridge.toml.sample4
3 files changed, 17 insertions, 1 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 0fc41412..0b92783e 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -95,6 +95,7 @@ type Protocol struct {
PrefixMessagesWithNick bool // mattemost, slack
Protocol string // all protocols
QuoteDisable bool // telegram
+ QuoteFormat string // telegram
RejoinDelay int // IRC
ReplaceMessages [][]string // all protocols
ReplaceNicks [][]string // all protocols
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go
index a5cba288..6b7d1a0a 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -223,7 +223,7 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
usernameReply = "unknown"
}
if !b.GetBool("QuoteDisable") {
- rmsg.Text = rmsg.Text + " (re @" + usernameReply + ":" + message.ReplyToMessage.Text + ")"
+ rmsg.Text = b.handleQuote(rmsg.Text, usernameReply, message.ReplyToMessage.Text)
}
}
@@ -415,3 +415,14 @@ func (b *Btelegram) cacheAvatar(msg *config.Message) (string, error) {
}
return "", nil
}
+
+func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string {
+ format := b.GetString("quoteformat")
+ if format == "" {
+ format = "{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})"
+ }
+ format = strings.Replace(format, "{MESSAGE}", message, -1)
+ format = strings.Replace(format, "{QUOTENICK}", quoteNick, -1)
+ format = strings.Replace(format, "{QUOTEMESSAGE}", quoteMessage, -1)
+ return format
+}
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index d28dc8bd..e2558cbb 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -815,6 +815,10 @@ UseInsecureURL=false
#OPTIONAL (default false)
QuoteDisable=false
+#Format quoted/reply messages
+#OPTIONAL (default "{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})")
+QuoteFormat="{MESSAGE} (re @{QUOTENICK}: {QUOTEMESSAGE})"
+
#Disable sending of edits to other bridges
#OPTIONAL (default false)
EditDisable=false