-2

I have a private channel in Telegram and a bot that I have added to the channel as a member of the administrators, and the web hook is also set to my php code file.

I plan to manage the membership of the channel members with the Telegram web service and bot, so that only users can become channel members through the bot or, if possible, through a dedicated link. How can I do this with php and Telegram web service?

According to my research, I cannot get the list of members of my channel easily and directly in order to expel unauthorized users from the channel by comparing it with the data in my database.

Please tell me how can I have a join event for my channel and get each user's ID as soon as they join the channel?

Currently, people can join the channel by copying and sharing the channel membership link with each other, which I want to prevent this unauthorized membership.

1 Answers1

0

The webhook will send you a JSON object containing the telegram message object from which you can extract the chat id.

This will always be sent, if somebody sends a message to the bot (utilizing a bot command).

You will not receive a trigger when a user joins a chat!

$request = json_decode(file_get_contents(filename: 'php://input'), false);
echo $request->message->chat->id;

So you with that you can hold up a whitelist of allowed chat IDs of users who can use bot commands. You can not stop them joining.

See also: Can Telegram bot detect a new member joining a channel event?

If that info is outdated, please let me know in the comments to update the answer.

Markus Zeller
  • 8,516
  • 2
  • 29
  • 35
  • This does not answers the question. At most this should be a comment, or marked as duplicate on the shared post. – 0stone0 Mar 16 '23 at 11:14