Reputation: 183
Say I have created a group in Telegram and want to develop a bot and add it to the group as an admin. Now, say this bot is programmed to send a welcome message to the users joining the group. However, we want to send the welcome message only to actual human users, and not to other bots that might have been added to the group. Is this technically possible? I mean, when I'm developing my admin bot, how can I make it able to differentiate between a user and a bot? Is there a query or something for that?
Upvotes: 0
Views: 496
Reputation: 2441
your bot gets a JSON object as a new user joins your group:
{
message_id: 8,
from: {
id: <user_id>,
is_bot: false,
first_name: 'A',
last_name: 'B',
username: '<adder_username>'
},
chat: {
id: <chat_id>,
title: 'test',
type: 'supergroup'
},
date: 1535443550,
new_chat_participant: {
id: <user_id>,
is_bot: false,
first_name: 's',
username: '<added_username>',
language_code: 'en-us'
},
new_chat_member: {
id: <user_id>,
is_bot: false,
first_name: 's',
username: '<added_username>',
language_code: 'en-us'
},
new_chat_members: [{
id: <user_id>,
is_bot: false,
first_name: 's',
username: '<added_username>',
language_code: 'en-us'
}]
}
checking msg.new_chat_participant.is_bot you can find out if it is a real user or a bot.
Upvotes: 0