yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.31k stars 1.51k forks source link

Is there a way to reply to forwarded messages? #976

Closed DarrylSSY closed 2 years ago

DarrylSSY commented 2 years ago

Is there a way to reply to forwarded messages?

Hi, I am attempting to get my bot to chat in a discussion channel. For that to work, I will have to get it to reply to a particular message in the chat, and that message happens to be a forwarded message. However, when I use the chat ID and the message ID, it simply does not reply to the correct message (it is like the message does not exist and it replies to something before it). How can I possibly get it to reply to forwarded messages?

gladunvv commented 2 years ago

How do you get the id of the message you want to reply to? the forwarded messages have a forward_date field and a forward_from object

this._bot.on('message', msg=>{
    if (msg.forward_from && msg.forward_date) {
        this._bot.sendMessage(msg.chat.id, 'Im replied you', { reply_to_message_id: msg.message_id } )
    } else {
        // its a regular chat message
}