Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telethon import TelegramClient, events
- api_id = ************
- api_hash = "************************************"
- target_chat = ****************
- client = TelegramClient('my_account11', api_id, api_hash)
- text1 = "MessageActionChatDeleteUser"
- text2 = "MessageActionChatAddUser"
- @client.on(events.chataction.ChatAction)
- async def my_event_handler(event):
- #print(event)
- patt = str(event.action_message.action)
- try:
- if text1 in patt:
- id_todel = event.action_message.id
- await client.delete_messages(target_chat, message_ids=id_todel)
- print("User left delited")
- elif text2 in patt:
- id_todel = event.action_message.id
- await client.delete_messages(target_chat, message_ids=id_todel)
- print("User add delited")
- except Exception as e:
- print("Error: ", e)
- client.start()
- client.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement