diff options
author | Ivan Zuev <dajohnes@gmail.com> | 2022-02-03 02:20:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 00:20:25 +0100 |
commit | 48018500135005eddbf9272035c23544e338b29a (patch) | |
tree | 52882e5020e04769b66211dd45102b8c8af3e975 /bridge/telegram | |
parent | 6a7412bf2bce500cdf5a34cd06abe426376136d3 (diff) | |
download | matterbridge-msglm-48018500135005eddbf9272035c23544e338b29a.tar.gz matterbridge-msglm-48018500135005eddbf9272035c23544e338b29a.tar.bz2 matterbridge-msglm-48018500135005eddbf9272035c23544e338b29a.zip |
Add Telegram Bot Command /chatId (telegram) (#1703)
* feat(telegram): command to get chat id
* Gofumpt
Co-authored-by: Ivan Zuev <i-zuev@yandex-team.ru>
Co-authored-by: Wim <wim@42.be>
Diffstat (limited to 'bridge/telegram')
-rw-r--r-- | bridge/telegram/handlers.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index 80a7185c..8461df37 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -1,6 +1,7 @@ package btelegram import ( + "fmt" "html" "path/filepath" "strconv" @@ -15,8 +16,20 @@ import ( func (b *Btelegram) handleUpdate(rmsg *config.Message, message, posted, edited *tgbotapi.Message) *tgbotapi.Message { // handle channels if posted != nil { - message = posted - rmsg.Text = message.Text + if posted.Text == "/chatId" { + chatID := strconv.FormatInt(posted.Chat.ID, 10) + + _, err := b.Send(config.Message{ + Channel: chatID, + Text: fmt.Sprintf("ID of this chat: %s", chatID), + }) + if err != nil { + b.Log.Warnf("Unable to send chatID to %s", chatID) + } + } else { + message = posted + rmsg.Text = message.Text + } } // edited channel message |