0

I'm making a bot and need to let the user save the channelID to an array.
The rest of the code is fine and works as intended in a group, but it's totally unresponsive inside a channel.

I've if else statements for if the chat is a channel, group, supergroup or private to no avail.

I'm using the node-telegram-bot-api - here is the snippet:

bot.onText(/\/getid/, (msg) => {
    console.log(`Channel/Group ID is: ${msg.chat.id}`);
});
msanford
  • 11,803
  • 11
  • 66
  • 93
Sean Fox
  • 11
  • 1
  • Hi! Can you post some more of the code, like how and when `bot` is instantiated and where this handler is bound, in relation? If you log nothing for match-all (e.g., `/[\s\S]*/`) then the event handler is not bound. – msanford Jan 28 '23 at 17:03
  • Please provide enough code so others can better understand or reproduce the problem. – Ahmed Sbai Jan 29 '23 at 01:26

1 Answers1

1
bot.on('channel_post', (msg) => {
    if (msg.text === "/getid") {
        console.log(`Channel ID is: ${msg.chat.id}`);
    }
});

I managed to solve with this.

Sean Fox
  • 11
  • 1