B
B
BOSH222022-03-21 01:46:19
Python
BOSH22, 2022-03-21 01:46:19

How to get the user ID of a user who joined a private group by an invite link created by a bot?

Good evening everyone.
Faced a small problem. Diligent combing through the Internet did not help much.
I'm trying to make the bot send a message to a person who has joined a private channel via an invite link created by this bot, immediately after he has joined the channel.

The block for sending a message by the bot to the user is removed if the user sent an application for joining via the link created by the bot.
Now the question remains: how to get the user ID and immediately after the entry send him a message?

The search led to the
@dp.chat_join_request_handler() handler

AND a postscript like:
async def join(update: types.ChatJoinRequest):
await update.approve()
Logically, this code should automatically accept all applications for membership, but for some reason this does not work.
If someone can help me figure it out, I'd appreciate it!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
i3a4em, 2022-03-21
@i3a4em

Since you did not deign to indicate the library used, I will give an example from the first one that I remembered.

@bot.message_handler(content_types=['new_chat_members'])
def new_chat_members(message):
    bot.send_message(message.from_user.id, "какая-то чертовски важная инфа")

If, as you claim
The block for sending a message by the bot to the user is removed...

Then it will work
. And please indicate:
- The real complexity of the issue (not for you personally, but for the IT community as a whole) when publishing it.
- Libraries that you use.
- Minimal reproducible code example.
These points have a huge impact on the decision to answer the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question