Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import time, random
- from telethon import TelegramClient, events, sync, functions, types
- # sample API_ID from https://github.com/telegramdesktop/tdesktop/blob/f98fdeab3fb2ba6f55daf8481595f879729d1b84/Telegram/SourceFiles/config.h#L220
- # or use your own
- api_id = ''
- api_hash = ''
- # fill in your own details here
- phone = ''
- username = ''
- # password = 'YOUR_PASSWORD' # if you have two-step verification enabled
- # content of the automatic reply
- warning_messages = {1: "Busy right now. Much unlike Bloody Mary, do __not__ ping me thrice.",
- 2: "For clarity\'s sake, \'thrice\' is three times. This is \'twice\' now. Please don't do it again, thanks.",
- 3: ["Rude.", "**So** rude.", "Don\'t harass me, I need therapy.", "You think this is zoke, but __you__ are acully zoke."]}
- watch_list = {}
- white_list = [646975991 # Aishwarya
- , 193268 # Tarun
- , 587995386] # Me
- def main():
- client = TelegramClient(username, api_id, api_hash)
- @client.on(events.NewMessage(incoming=True))
- async def _(event):
- if ((event.is_private) or (event.message.mentioned)):
- if event.message.from_id in white_list:
- print ("He copacetic, brah...")
- else:
- if event.message.from_id not in watch_list:
- watch_list[event.message.from_id] = 1
- else:
- watch_list[event.message.from_id] += 1;
- if (watch_list[event.message.from_id] > 2):
- while(1):
- time.sleep(0.3)
- await client.send_message(event.message.from_id, random.choice(warning_messages[watch_list[event.message.from_id]]))
- print(time.asctime(), '-', event.message.from_id, "->", event.message.message, watch_list)
- await event.respond(warning_messages[watch_list[event.message.from_id]])
- with client:
- print(time.asctime(), '-', 'Auto-replying...')
- client.run_until_disconnected()
- print(time.asctime(), '-', 'Stopped!')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement