Add UseFirstName option (telegram). Closes #144

This commit is contained in:
Wim 2017-05-15 23:23:10 +02:00
parent 27c0f37e49
commit 2888fd64b0
3 changed files with 13 additions and 1 deletions

View File

@ -70,6 +70,7 @@ type Protocol struct {
UseAPI bool // mattermost, slack UseAPI bool // mattermost, slack
UseSASL bool // IRC UseSASL bool // IRC
UseTLS bool // IRC UseTLS bool // IRC
UseFirstName bool // telegram
} }
type ChannelOptions struct { type ChannelOptions struct {

View File

@ -98,9 +98,14 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
message.Text = message.Text + b.Config.EditSuffix message.Text = message.Text + b.Config.EditSuffix
} }
if message.From != nil { if message.From != nil {
username = message.From.FirstName if b.Config.UseFirstName {
username = message.From.FirstName
}
if username == "" { if username == "" {
username = message.From.UserName username = message.From.UserName
if username == "" {
username = message.From.FirstName
}
} }
text = message.Text text = message.Text
channel = strconv.FormatInt(message.Chat.ID, 10) channel = strconv.FormatInt(message.Chat.ID, 10)

View File

@ -451,6 +451,12 @@ Token="Yourtokenhere"
#See https://core.telegram.org/bots/api#html-style #See https://core.telegram.org/bots/api#html-style
MessageFormat="" 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 #Disable sending of edits to other bridges
#OPTIONAL (default false) #OPTIONAL (default false)
EditDisable=false EditDisable=false