mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-04 08:22:03 -08:00
Use AuthorSignature as a fallback username (telegram) (#1979)
This comes in handy for annoucement type channels where neither the SenderChat or From structs contain name information. Also Tweak username logic as when using a full name the username field can be " " instead of "".
This commit is contained in:
parent
d00dcf3f58
commit
768fb791c5
@ -128,8 +128,10 @@ func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Messa
|
|||||||
rmsg.Username = message.From.FirstName
|
rmsg.Username = message.From.FirstName
|
||||||
}
|
}
|
||||||
if b.GetBool("UseFullName") {
|
if b.GetBool("UseFullName") {
|
||||||
|
if message.From.FirstName != "" && message.From.LastName != "" {
|
||||||
rmsg.Username = message.From.FirstName + " " + message.From.LastName
|
rmsg.Username = message.From.FirstName + " " + message.From.LastName
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if rmsg.Username == "" {
|
if rmsg.Username == "" {
|
||||||
rmsg.Username = message.From.UserName
|
rmsg.Username = message.From.UserName
|
||||||
if rmsg.Username == "" {
|
if rmsg.Username == "" {
|
||||||
@ -148,8 +150,10 @@ func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Messa
|
|||||||
rmsg.Username = message.SenderChat.FirstName
|
rmsg.Username = message.SenderChat.FirstName
|
||||||
}
|
}
|
||||||
if b.GetBool("UseFullName") {
|
if b.GetBool("UseFullName") {
|
||||||
|
if message.SenderChat.FirstName != "" && message.SenderChat.LastName != "" {
|
||||||
rmsg.Username = message.SenderChat.FirstName + " " + message.SenderChat.LastName
|
rmsg.Username = message.SenderChat.FirstName + " " + message.SenderChat.LastName
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if rmsg.Username == "" || rmsg.Username == "Channel_Bot" {
|
if rmsg.Username == "" || rmsg.Username == "Channel_Bot" {
|
||||||
rmsg.Username = message.SenderChat.UserName
|
rmsg.Username = message.SenderChat.UserName
|
||||||
@ -164,6 +168,11 @@ func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Messa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback on author signature (used in "channel" type of chat)
|
||||||
|
if rmsg.Username == "" && message.AuthorSignature != "" {
|
||||||
|
rmsg.Username = message.AuthorSignature
|
||||||
|
}
|
||||||
|
|
||||||
// if we really didn't find a username, set it to unknown
|
// if we really didn't find a username, set it to unknown
|
||||||
if rmsg.Username == "" {
|
if rmsg.Username == "" {
|
||||||
rmsg.Username = unknownUser
|
rmsg.Username = unknownUser
|
||||||
|
Loading…
Reference in New Issue
Block a user