I've been using a Telegram BOT to send notifications for a group, and for users.
I already know i can get Chat ID by receiving a message from the user on my bot, using getUpdates.
I also know i can get Group ID using the same method...
But what i really need is:
There is three users in my group.
My bot.
Me.
Another user that didn't sent any messages to my bot so it does not appear on getUpdates
Is it possible to get this third user his ID?
PS: I am the group owner, and also added my bot as Admin...
The third user is a normal user.
Can someone help me?
Thanks!
That's not possible with the offical Telegram Bot API
Possible Workarounds:
Hold a list of your own. If a user is joining (new_chat_member), lefting (left_chat_member), somebody is sending a message in the group, and so on. Check Message for more information.
Check if a user is a member of the group with getChatMember.
Also may be helpful: getChatMembersCount and getChatAdministrators
Related
I created a new Telegram group, and my problem is that I cannot add any bot to it, knowing that I have created a channel and have linked it to the group and the bot is added to the channel with no problems. Please help me in adding the bot
bot exit messages from My group
I think you are anonymous in group and it looks like the bot you are trying to add doesn't supports anonymous admins.
I am using Telegram bot API with AWS Lambda and Zappa.
Everything was working fine. Until I realised that bot's webhook is being called everytime whenever a message is sent by anyone in the group.
I want to limit this webhook requests, as Lambda allows for only 1 million calls which is sufficient if bot is invoked, but only when /commands are called.
As I have to pin and edit messages using bot, that's why administrator permission is must.
I just want my bot to respond only to /commands along with administrator rights.
Please help me in tackling this issue.
I am assuming you added your bot to a Telegram group. In this case, the first thing that you need is group id. This should help: https://github.com/GabrielRF/telegram-id#web-group-id
And then you need to write a function that identifies the status of a chat member. You can do this using getChatMember method in Telegram Bots API.
If the chat member's status is "creator" or "administrator" then the response is sent to that user.
There are 2 things you need to do.
setPrivacy for your bot - go to BotFather chat and use the /setPrivacy command which gives you the ability to set:
'Enable' - your bot will only receive messages that either start with
the '/' symbol or mention the bot by username. (Should be default)
'Disable' - your bot
will receive all messages that people send to groups. Current status
is: DISABLED.
When setting the commands for the bot, set the BotCommandScopeAllChatAdministrators scope which should limit the use of the command only to the admins of the chat.
Relates to Retrieve all chat ids using Telegram bot but 3 years later.
My use case is a bot that notifies chat participants of home automation events. Any user might create his own chat and receive events or send commands.
Currently, it seems that the bot has no option to find the chats that it participates in. Even a potential workaround like using GetUpdates(0) seems to retrieve only new message ids which makes it impossible to get a complete list of chats from looking at the received messages.
Is there a stable solution for doing this?
This is not possible from Telegram's API. Howerver,
A bot will receive a new_chat_members which could be the bot 'joining another group':
new_chat_members -- Array of User -- Optional.
New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
To remember each user/group, you'll have to save each chat/user_id into a database.
The bot will also receive the opposite left_chat_member so you'll know when to delete a database entry.
I'm on a telegram group of wich I'm not admin. In that particular channel, there are lots of messages and "useless" information. I want to make something so when someone in the group says a particular word, I'll get a notification (maybe a private msg?). I've searched but other answers mention the bot API, but, as far as I have found, bots can't be added to groups without being admin, not even with the invitation link. How can I access the messages of the group to process them?
As you said, bots can't get message in channel without administrator permission, and they can't join group by themselves.
If you want to get all messages in group, please disable privacy mode via /setprivacy in #BotFather, and re-invite to group.
I need to create a Telegram bot to moderate a group and be able to ban/boot/kick users from the group.
I could not find anything in the Telegram API to boot a user from a group, how can a bot do this through the API?
You can use banChatMember to remove a user from a group.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
To remove a user without banning them, use unbanChatMember.
this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat.