I want to check through which invite link a new member joins the group chat. According to the Telegram API docs, there should be an invite_link type when listening on the Chat_member update.
ChatMemberUpdated
This object represents changes in the status of a chat member.
Field Type Description
chat Chat Chat the user belongs to
from User Performer of the action, which resulted in the change
date Integer Date the change was done in Unix time
old_chat_member ChatMember Previous information about the chat member
new_chat_member ChatMember New information about the chat member
invite_link ChatInviteLink Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
via_join_request Boolean Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator
via_chat_folder_invite_link Boolean Optional. True, if the user joined the chat via a chat folder invite link
But I failed to get the invite_link object with the following code:
const TelegramBot = require('node-telegram-bot-api');
require ('dotenv').config();
const token = process.env.BOT_TOKEN;
const bot = new TelegramBot(token, { polling: true });
bot.on('chat_member', (msg) => {
const newMemberInviteLink = msg.invite_link ? msg.invite_link : "Unknown Invite Link";
console.log(newMemberInviteLink);
})
When I try to console log the entire msg, I get the entire ChatMemberUpdated type, but there is no invite_link even though I am sure the new member joined the group chat with a generated invite link other than the primary invite link:
Received update: {
chat: {
id: -1002225700353,
title: 'TestReferralChatgroup',
username: 'TestReferralChatgroup',
type: 'supergroup'
},
from: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
date: 1721558379,
old_chat_member: {
user: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
status: 'left'
},
new_chat_member: {
user: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
status: 'member'
}
}
When I try to console log the entire msg, I get the entire ChatMemberUpdated type, but there is no invite_link even though I am sure the new member joined the group chat with a generated invite link other than the primary invite link:
Received update: {
chat: {
id: -1002225700353,
title: 'TestReferralChatgroup',
username: 'TestReferralChatgroup',
type: 'supergroup'
},
from: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
date: 1721558379,
old_chat_member: {
user: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
status: 'left'
},
new_chat_member: {
user: {
id: 5189356713,
is_bot: false,
first_name: 'rii',
last_name: 'un',
username: 'LilKimbom'
},
status: 'member'
}
}
Frankrypto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.