Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- import socket, re, time
- HOST = "irc.twitch.tv"
- PORT = 6667
- NICK = "##########"
- PASS = "oauth:##############################"
- CHAN = "##########"
- RATE = (20/30)
- s = socket.socket()
- s.connect((HOST, PORT))
- s.send("PASS {}\r\n".format(PASS).encode("utf-8"))
- s.send("NICK {}\r\n".format(NICK).encode("utf-8"))
- s.send("JOIN {}\r\n".format(CHAN).encode("utf-8"))
- CHAT_MSG=re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
- while True:
- response = s.recv(1024).decode("utf-8")
- if response == "PING :tmi.twitch.tv\r\n":
- s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
- else:
- username = re.search(r"\w+", response).group(0)
- message = CHAT_MSG.sub("", response)
- print(username + ": " + message)
- if username == "hey":
- print "Sent!"
- s.send('PRIVMSG '+CHAN+' :' + "Welcome to the Stream!" + '\r\n')
- time.sleep(1 / RATE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement