Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listening for a reply to an image with the '/isimage' command, replying with a message saying 'this is an image' #1182

Open
ViralisLabs opened this issue Mar 24, 2024 · 1 comment

Comments

@ViralisLabs
Copy link

ViralisLabs commented Mar 24, 2024

Question

Hello,

Before the 0.65 release on March 9th 2024, I was able to have a small beginner telegram bot that checks if the message a user replied to with '/isimage' command is a image (where the bot would type out 'that is an image') or if it is text (where the bot would say nothing), the following code worked before fine, but as of the 0.65 update, reply_to_message object property of message is undefined, and I can no longer find a reply_to_message object property to check if the user typing '/isimage' command is a reply to a previous message made by another user, and if that message is a photograph or not (via message.reply_to_message.photo property)

Here is the code I made below, that worked pre 0.65 update:

const TelegramBot = require('node-telegram-bot-api');

const token = '[MY TOKEN]';

const bot = new TelegramBot(token, { polling: true });

bot.on('message', (msg) => { const chatId = msg.chat.id;

if (msg.text && msg.text.toLowerCase() === '/isimage') {
    if (msg.reply_to_message && msg.reply_to_message.photo) {
        bot.sendMessage(chatId, 'You have an image');
    }
}
});

What would be the new way to write this out as per the 0.65 update, and if there is nothing to change, why is reply_to_message now undefined, when pre march 9th, it was defined and worked flawlessly.

@adougies
Copy link

adougies commented Apr 3, 2024

Log the msg object to console to see the structure of the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants