I am using TelegrafJS
and nodejs
for developing a telegram
bot and I want to use "chat_member" because it returns the invite link used by the user to join the telegram group. but the problem is it is not getting invoked. when new members are joined. my primary goal is to get the invite link used by the member to join the telegram group.
const { Router, Markup, Telegraf } = require('telegraf');
//require .ENV
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname + './../.env') });
//creating Bot
const bot = new Telegraf(process.env.TELEGRAM_TOKEN);
bot.on("chat_member", async (ctx) => {
console.log(ctx);
})
bot.on("group_chat_created", async (ctx) => {
console.log("group_chat_created")
})
//launching bot
bot.launch()
.then(() => {
console.log("Bot Running");
})
.catch((err) => {
console.log(`Error Running Bot: ${err}`);
})
All other are working like "group_chat_created","new_chat_members","left_chat_member".
The documentation says I need to add it to allowed_updates but how to add it.
I got the solution the thing I needed to add was the launch options in the bot.launch method
var options2 =
{
allowedUpdates: ['chat_member']
}
//launching bot
bot.launch(options2)
.then(() => {
console.log("Bot Running");
})
.catch((err) => {
console.log(`Error Running Bot: ${err}`);
})
you will not get update about this method directly you need to add it to allowed_updates