Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests # импортируем библиотеки
- from telethon import TelegramClient, events
- from telethon.tl import types
- from telethon.tl.types import PeerUser, PeerChat, PeerChannel, ChatBannedRights
- from telethon.tl.functions.channels import EditBannedRequest
- api_id = *********** # +**********
- api_hash = '**************************'
- bot_token = '*****************:********************************'
- client = TelegramClient('my_account', api_id, api_hash)
- bot = TelegramClient('bot', api_id, api_hash).start(bot_token=bot_token)
- bad_words =["ПОИSК", "BE4EP", "ПОИSК", "Г0PЯ4UЕ", "ЗНАK0МСTVA", "💝💝💝", "🌶🌶🌶", "💋💋💋", "СEKS", "ПAPTНЕР0B", "🍓🍓🍓"]
- @bot.on(events.ChatAction)
- async def my_event_handler(event):
- print("Event!")
- #print(event)
- #print(event.action_message.from_id.user_id)
- channel = event.action_message.peer_id.channel_id
- #print(channel)
- method = 'getUpdates?offset=-1'
- response = requests.post(
- url='https://api.telegram.org/bot{0}/{1}'.format(bot_token, method),
- data={'id': event.action_message.from_id.user_id}).json()
- #print(response)
- data = response.get("result")[0].get("message").get("from").get("first_name")
- user = response.get("result")[0].get("message").get("from").get("username")
- #sum = response.get("result")[0].get("message").get("from")
- #print(sum)
- #print(user)
- #print(data)
- if event.user_joined == True:
- print("!!!!!!!")
- for i in range(len(bad_words)):
- print(bad_words[i], " not in ", data)
- if bad_words[i] in data:
- print("Busted", channel, user)
- await client.edit_permissions(channel, user, view_messages=False)
- print("Delited")
- client.start()
- client.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement