dkanavis

Untitled

Mar 11th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python3.6
  2.  
  3. import requests
  4. import random
  5. import sys
  6.  
  7. if random.randint(1, 10) != 9:
  8.     sys.exit()
  9.  
  10. KEY = "742085233:AAGQw7HDVLSYNC2lmDg_rjTgTRDy339-bNM"
  11. #CHAT = "96378817"
  12. CHAT = "-1001059274286"
  13. JOKE_IDS = (1, 2, 3, 4, 5, 6, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16)
  14.  
  15.  
  16. def call(method, **params):
  17.     url = f"https://api.telegram.org/bot{KEY}/{method}"
  18.     r = requests.get(url, params=params)
  19.     return r
  20.  
  21.  
  22. def joke():
  23.     joke_id = random.choice(JOKE_IDS)
  24.     r = requests.get(f"http://rzhunemogu.ru/RandJSON.aspx?CType={joke_id}")
  25.     text = r.text.replace('{"content":"', "").replace('"}', "")
  26.     return text
  27.  
  28. text = joke()
  29. print(call("sendMessage", chat_id=CHAT, text=text).text)
Advertisement
Add Comment
Please, Sign In to add comment