summaryrefslogtreecommitdiffstats
path: root/bridge/telegram/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/telegram/handlers.go')
-rw-r--r--bridge/telegram/handlers.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go
index 8461df37..c5ed8c46 100644
--- a/bridge/telegram/handlers.go
+++ b/bridge/telegram/handlers.go
@@ -10,6 +10,7 @@ import (
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
+ "github.com/davecgh/go-spew/spew"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
@@ -123,6 +124,25 @@ func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Messa
}
}
+ if message.SenderChat != nil { //nolint:nestif
+ rmsg.UserID = strconv.FormatInt(message.SenderChat.ID, 10)
+ if b.GetBool("UseFirstName") {
+ rmsg.Username = message.SenderChat.FirstName
+ }
+
+ if rmsg.Username == "" || rmsg.Username == "Channel_Bot" {
+ rmsg.Username = message.SenderChat.UserName
+
+ if rmsg.Username == "" || rmsg.Username == "Channel_Bot" {
+ rmsg.Username = message.SenderChat.FirstName
+ }
+ }
+ // only download avatars if we have a place to upload them (configured mediaserver)
+ if b.General.MediaServerUpload != "" || (b.General.MediaServerDownload != "" && b.General.MediaDownloadPath != "") {
+ b.handleDownloadAvatar(message.SenderChat.ID, rmsg.Channel)
+ }
+ }
+
// if we really didn't find a username, set it to unknown
if rmsg.Username == "" {
rmsg.Username = unknownUser
@@ -139,6 +159,10 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
continue
}
+ if b.GetInt("debuglevel") == 1 {
+ spew.Dump(update.Message)
+ }
+
var message *tgbotapi.Message
rmsg := config.Message{Account: b.Account, Extra: make(map[string][]interface{})}