I’m trying to log my data from my bot and I use this script:
bot.use((ctx, next) => {
console.log(ctx.from);
if(ctx.updateSubTypes[0] == "text") {
bot.telegram.sendMessage(-4..5, "@" + ctx.from.username + " said: " + ctx.message.text)
} else {
bot.telegram.sendMessage(-4..5, "@" + ctx.from.username + " sent a " + ctx.updateSubTypes[0]);
}
next();
})
This code works well with the usernames, but what if the user doesn’t have one.
I would like to know if there is a possibility to have the first_name with a link to the user profile using just the user ID, so I could anytime check the profile of users who are running my bot.
Thank you in advance!
2
Answers
I got it to work like this:
I hope this will help you in case you have the same issue.
ctx.updateSubTypes
is no longer supported aftertelegraf 4.0.3
.But I don’t know what is the new alternative for this method?
Check out => https://github.com/telegraf/telegraf/releases/tag/v4.0.0#:~:text=Remove%20ctx.updateSubTypes