Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 5ae3533863d5589e5d286341553d43886d77fb84 Author: Wim <wim@42.be> Date: Fri May 11 20:59:15 2018 +0000 Add QuoteFormat option (telegram). Closes #413 diff --git a/bridge/config/config.go b/bridge/config/config.go index 0fc4141..0b92783 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -956 +957 @@ 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 a5cba28..6b7d1a0 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -2237 +2237 @@ 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)   }   }   @@ -4153 +41514 @@ 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 d28dc8b..e2558cb 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -8156 +81510 @@ 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