Advertisement
Guest User

явыпмыпкурритавиав

a guest
Jul 19th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. HOST = "irs.twitch.tv"
  2. PORT = 6667
  3. NICK = "hinAmigo"
  4. PASS = "oauth:th4slb32oh6raek4w5tgjd3c8kct0g"
  5. CHAN = "blackufa_twitch"
  6. RATE = (20/30)
  7.  
  8.  
  9. oplist = {}
  10.  
  11.  
  12. import config
  13. import urllib2
  14. import json
  15. import time
  16. import thread
  17. from time import sleep
  18.  
  19.  
  20.  
  21.  
  22. def mess(sock, message):
  23. sock.send("PRIVMSG #{} :{} \r\n".format(config.CHAN, message))
  24.  
  25.  
  26.  
  27. #http://tmi.twitch.tv/group/user/blackufa_twitch/chatters
  28. def fill0plist():
  29. while True:
  30. try:
  31. url = "http://tmi.twitch.tv/group/user/blackufa_twitch/chatters"
  32. req = urllib2.Request(url, headers={"accept": "*/*"})
  33. res = urllib2.urlopen(req).read()
  34. if res.find("502 bad gateway") == - 1:
  35. config.oplist.clear()
  36. data = json.loads(res)
  37. for p in data ["chatters"]["hinlanner"]:
  38. config.oplist[p] = "mod"
  39. for p in data ["chatters"]["mocrochip"]:
  40. config.oplist[p] = "mod"
  41. for p in data ["chatters"]["allusers"]:
  42. config.oplist[p] = "mod"
  43. except:
  44. "Something went wrong...do nothing"
  45. sleep(5)
  46.  
  47.  
  48. def is0p(user):
  49. return user in config.oplist
  50.  
  51.  
  52.  
  53.  
  54. import config
  55. import utils
  56. import socket
  57. import re
  58. import time
  59. import thread
  60. from time import sleep
  61.  
  62.  
  63.  
  64. def main()
  65. s = socket.socket()
  66. s.connect((config.HOST, config.PORT))
  67. s.send("PASS {}\r\n".format(config.PASS).encode("unt-8"))
  68. s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
  69. s.send("JOUN #{}\r\n".format(config.CHAN).encode("utf-8"))
  70.  
  71. chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.tmi\twitch\.tv PRIVMSG #\w+ :")
  72. utils.mess(s, "My name Amigo, HinAmigo!")
  73.  
  74. thread.start_new_thread(utils.fill0plist,())
  75. while True:
  76. response = s.recv(1024).decode("utf-8")
  77. if response == "PING :tmi.twitch.tv\r\n":
  78. s.send("POND :tmi.twitch.tv\r\n".encode("utf-8"))
  79. else:
  80. username = re.search(r"\w+", response).group(0)
  81. message = chat_message.sub("", response)
  82. print(response)
  83.  
  84.  
  85. if message.strip() == "!time":
  86. utils.mess(s, "Стрима нет! Ухади!: " + time.strftime("%I:%p %Z on %A %B %d %Y"))
  87. if message.strip() == "!Книги" and utils.is0p(username):
  88. utils.mess(s, "Напиши в личку, пожалуйста!")
  89. utils.mess(s, "Привет! Напиши в личку, позже я отправлю тебе все книги!")
  90. utils.mess(s, "Напиши в личку, пожалуйста! А можно задать интимный вопрос? ariW ")
  91. sleep(1)
  92.  
  93.  
  94.  
  95.  
  96. if __name__ == "__main__":
  97. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement