diff options
author | Wim <wim@42.be> | 2018-06-18 23:38:52 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-06-18 23:38:52 +0200 |
commit | d02eda147ce406dc1d223e840d48ec50894c96cb (patch) | |
tree | 2c84e4e2f626328d3f89001a273ff7d4954fc214 /bridge/telegram | |
parent | 9b25716136454f724f66788237d92a398674db59 (diff) | |
download | matterbridge-msglm-d02eda147ce406dc1d223e840d48ec50894c96cb.tar.gz matterbridge-msglm-d02eda147ce406dc1d223e840d48ec50894c96cb.tar.bz2 matterbridge-msglm-d02eda147ce406dc1d223e840d48ec50894c96cb.zip |
Add support for MessageFormat=htmlnick (telegram). #444
Diffstat (limited to 'bridge/telegram')
-rw-r--r-- | bridge/telegram/telegram.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 6b7d1a0a..805d967c 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -1,6 +1,7 @@ package btelegram import ( + "html" "regexp" "strconv" "strings" @@ -97,6 +98,11 @@ func (b *Btelegram) Send(msg config.Message) (string, error) { if err != nil { return "", err } + if strings.ToLower(b.GetString("MessageFormat")) == "htmlnick" { + b.Log.Debug("Using mode HTML - nick only") + msg.Text = html.EscapeString(msg.Text) + m.ParseMode = tgbotapi.ModeHTML + } m := tgbotapi.NewEditMessageText(chatid, msgid, msg.Username+msg.Text) if b.GetString("MessageFormat") == "HTML" { b.Log.Debug("Using mode HTML") @@ -391,13 +397,17 @@ func (b *Btelegram) sendMessage(chatid int64, username, text string) (string, er m.Text = username + text if b.GetString("MessageFormat") == "HTML" { b.Log.Debug("Using mode HTML") - m.Text = username + text m.ParseMode = tgbotapi.ModeHTML } if b.GetString("MessageFormat") == "Markdown" { b.Log.Debug("Using mode markdown") m.ParseMode = tgbotapi.ModeMarkdown } + if strings.ToLower(b.GetString("MessageFormat")) == "htmlnick" { + b.Log.Debug("Using mode HTML - nick only") + m.Text = username + html.EscapeString(text) + m.ParseMode = tgbotapi.ModeHTML + } res, err := b.c.Send(m) if err != nil { return "", err |