Advertisement
Guest User

Untitled

a guest
Jan 30th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import time, random
  4. from telethon import TelegramClient, events, sync, functions, types
  5.  
  6. # sample API_ID from https://github.com/telegramdesktop/tdesktop/blob/f98fdeab3fb2ba6f55daf8481595f879729d1b84/Telegram/SourceFiles/config.h#L220
  7. # or use your own
  8. api_id = ''
  9. api_hash = ''
  10.  
  11. # fill in your own details here
  12. phone = ''
  13. username = ''
  14. # password = 'YOUR_PASSWORD' # if you have two-step verification enabled
  15.  
  16. # content of the automatic reply
  17. warning_messages = {1: "Busy right now. Much unlike Bloody Mary, do __not__ ping me thrice.",
  18. 2: "For clarity\'s sake, \'thrice\' is three times. This is \'twice\' now. Please don't do it again, thanks.",
  19. 3: ["Rude.", "**So** rude.", "Don\'t harass me, I need therapy.", "You think this is zoke, but __you__ are acully zoke."]}
  20.  
  21. watch_list = {}
  22.  
  23. white_list = [646975991 # Aishwarya
  24. , 193268 # Tarun
  25. , 587995386] # Me
  26.  
  27. def main():
  28. client = TelegramClient(username, api_id, api_hash)
  29.  
  30. @client.on(events.NewMessage(incoming=True))
  31. async def _(event):
  32. if ((event.is_private) or (event.message.mentioned)):
  33. if event.message.from_id in white_list:
  34. print ("He copacetic, brah...")
  35. else:
  36. if event.message.from_id not in watch_list:
  37. watch_list[event.message.from_id] = 1
  38. else:
  39. watch_list[event.message.from_id] += 1;
  40. if (watch_list[event.message.from_id] > 2):
  41. while(1):
  42. time.sleep(0.3)
  43. await client.send_message(event.message.from_id, random.choice(warning_messages[watch_list[event.message.from_id]]))
  44. print(time.asctime(), '-', event.message.from_id, "->", event.message.message, watch_list)
  45. await event.respond(warning_messages[watch_list[event.message.from_id]])
  46.  
  47. with client:
  48. print(time.asctime(), '-', 'Auto-replying...')
  49. client.run_until_disconnected()
  50. print(time.asctime(), '-', 'Stopped!')
  51.  
  52.  
  53. if __name__ == '__main__':
  54. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement