That end point was removed with new version of telgraf https://github.com/telegraf/telegraf/releases/tag/v4.0.0#:~:text=ctx.updateSubTypes
How we can detect the message type with new API
this is the old ctx retrun
That end point was removed with new version of telgraf https://github.com/telegraf/telegraf/releases/tag/v4.0.0#:~:text=ctx.updateSubTypes
How we can detect the message type with new API
this is the old ctx retrun
This is an alternative usage to ctx.updatesubtypes
AKA getting message type in telegraf 3.
bot.use((ctx, next) => {
console.log(`Message Type is: ${getMessageType(ctx.message)}`);
// Message Type is: STICKER or Message Type is: TEXT
});
const getMessageType = (message) => {
var keys = Object.keys(message);
var messageType = keys.pop();
console.log(messageType);
return messageType.toUpperCase();
};
A good
alternative to using ctx.updatesubtypes in 4.6.0 is:
bot.use((ctx, next) => {
let message_type = "";
let keys = Object.keys(ctx.message);
if (keys.includes("text")) {
message_type = "text";
} else if (keys.includes("sticker")) {
message_type = "sticker";
} else if (keys.includes("photo")) {
message_type = "photo";
}
console.log(`Message Type is: ${message_type}`);
next();
});