node-telegram-bot-api
node-telegram-bot-api copied to clipboard
Listening for a reply to an image with the '/isimage' command, replying with a message saying 'this is an image'
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.
Log the msg object to console to see the structure of the data.