How to check telegram group invitation link parameters on new_chat_members

1.6k Views Asked by At

I have telegram bot which is added to the group and is listening on everything what is going on on the group. There is a command /invite implemented which displays invitation link to the group (not to the bot but to the group). This link contains parameter refUserId so I can get it later and count how many people has been invited by particular members of the group. This is what I was going to achieve but looks like there is no way to retrieve invitation link parameters on the new_chat_members event.

Here is a piece of code I want to retrieve the param

bot.on('new_chat_members', ctx => {
    // retrieve refUserId param here
})

I'm open to any suggestion and will be more than grateful to hear some other solutions.

Here is bigger picture in case that's needed

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => ctx.reply(`${Constants.msg.welcome(ctx.from.first_name)}`))
bot.command('invite', ctx => {
    // reply with invitation link like this:
    // t.me/myGroupIdWillBeHere?refUserId=${ctx.from.id}
})
bot.on('new_chat_members', ctx => {
    // retrieve refUserId param here
})
bot.launch()
0

There are 0 best solutions below