Skip to content

Commit

Permalink
feat(telegram): command to get chat id
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Zuev committed Jan 28, 2022
1 parent 23353f0 commit c285520
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 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,21 @@ 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 == "/chat-id" {
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 c285520

Please sign in to comment.