Skip to content

Commit

Permalink
Add Telegram Bot Command /chatId (telegram) (42wim#1703)
Browse files Browse the repository at this point in the history
* feat(telegram): command to get chat id

* Gofumpt

Co-authored-by: Ivan Zuev <[email protected]>
Co-authored-by: Wim <[email protected]>
  • Loading branch information
3 people committed Feb 2, 2022
1 parent 6a7412b commit 4801850
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bridge/telegram/handlers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package btelegram

import (
"fmt"
"html"
"path/filepath"
"strconv"
Expand All @@ -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
Expand Down

0 comments on commit 4801850

Please sign in to comment.