Thumbnail

rani/matterbridge.git

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

commit 07395508f81c349cbb60119ca43f8ac0e2bb21ce Author: Wim <wim@42.be> Date: Mon May 15 23:23:10 2017 +0000 Add UseFirstName option (telegram). Closes #144 diff --git a/bridge/config/config.go b/bridge/config/config.go index 6f34131..2cd5366 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -706 +707 @@ type Protocol struct {   UseAPI bool // mattermost, slack   UseSASL bool // IRC   UseTLS bool // IRC + UseFirstName bool // telegram  }    type ChannelOptions struct { diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 3226924..8631f2f 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -989 +9814 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {   message.Text = message.Text + b.Config.EditSuffix   }   if message.From != nil { - username = message.From.FirstName + if b.Config.UseFirstName { + username = message.From.FirstName + }   if username == "" {   username = message.From.UserName + if username == "" { + username = message.From.FirstName + }   }   text = message.Text   channel = strconv.FormatInt(message.Chat.ID, 10) diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index de1304a..0d4da80 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -4516 +45112 @@ Token="Yourtokenhere"  #See https://core.telegram.org/bots/api#html-style  MessageFormat=""   +#If enabled use the "First Name" as username. If this is empty use the Username +#If disabled use the "Username" as username. If this is empty use the First Name +#If all names are empty, username will be "unknown" +#OPTIONAL (default false) +UseFirstName=false +  #Disable sending of edits to other bridges  #OPTIONAL (default false)  EditDisable=false