D
D
Dmitry2022-04-01 10:30:29
Python
Dmitry, 2022-04-01 10:30:29

How to catch? who invited how many to the telegram chat (group)?

Tell me how to catch the event, who and how many users invited to the telegram chat.

@dp.message_handler(content_types=['ChatJoinRequest'])
async def on_user_joined(message: types.Message):
    await bot.chat_join_request(
                      message.chat.id,                                   
                      message.from_user.id)
    await update.message()


and did so: But how, I didn’t find any examples on the net, but I stuck this code from another code, there was an invitation by reference.
@dp.chat_join_request_handler()
async def on_user_joined(message: types.Message):
    await bot.chat_join_request(
                      message.chat.id,                                   
                      message.from_user.id)
    await update.message()


In the console I saw this

INFO:aiogram.contrib.middlewares.logging:Received chat member update for user [ID:1621id]. Old state: {'user': {'id': 1956id, 'is_bot': False, 'first_name': 'Дмитрий', 'username': 'nik', 'language_code': 'ru'}, 'status': 'left'} New state: {'user': {'id': 195id, 'is_bot': False, 'first_name': 'Дмитрий', 'username': 'nik', 'language_code': 'ru'}, 'status': 'member'} 
INFO:aiogram.contrib.middlewares.logging:Process update [ID:2619id]: [success] (in 1 ms)
INFO:aiogram.contrib.middlewares.logging:Received message [ID:20id] in chat [supergroup:-100177id]


How to output a string to the group, on behalf of the Bot that Dmitry invited 10 users, or write it to a json file and by day.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question