Advertisement
askanton

Как удалить уведомления про новых пользователей в телеграм каналах?

Apr 13th, 2021
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. from telethon import TelegramClient, events
  2. api_id =        ************
  3. api_hash =     "************************************"
  4. target_chat =   ****************
  5.  
  6. client = TelegramClient('my_account11', api_id, api_hash)
  7. text1 = "MessageActionChatDeleteUser"
  8. text2 = "MessageActionChatAddUser"
  9.  
  10. @client.on(events.chataction.ChatAction)
  11. async def my_event_handler(event):
  12.     #print(event)
  13.     patt = str(event.action_message.action)
  14.     try:
  15.         if text1 in patt:
  16.             id_todel = event.action_message.id
  17.             await client.delete_messages(target_chat, message_ids=id_todel)
  18.             print("User left delited")
  19.         elif text2 in patt:
  20.             id_todel = event.action_message.id
  21.             await client.delete_messages(target_chat, message_ids=id_todel)
  22.             print("User add delited")
  23.     except Exception as e:
  24.         print("Error: ", e)
  25.  
  26. client.start()
  27. client.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement