Allow PrefixMessagesWithNick on Telegram

This makes the PrefixMessagesWithNick setting work for messages relayed
to Telegram, similar to how they work for messages relayed to mattermost
(it is in fact copied from the mattermost bridge implementation).

I believe this logic should be moved up the stack and not left to
individual bridge implementations, but adding it here like this made it
quickly work for my use-case (I don't have the time to dig in deeper and
refactor everything).
This commit is contained in:
Nick Groenen 2016-11-25 20:44:01 +01:00
parent 20c04f7977
commit f8537c63a5
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098

View File

@ -57,7 +57,12 @@ func (b *Btelegram) Send(msg config.Message) error {
if err != nil {
return err
}
m := tgbotapi.NewMessage(chatid, msg.Text)
message := msg.Text
if b.Config.PrefixMessagesWithNick {
message = msg.Username + " " + message
}
m := tgbotapi.NewMessage(chatid, message)
_, err = b.c.Send(m)
return err
}