Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding=utf-8
- import socket
- import string
- import time
- print "RUNNING"
- commands = ['γεια', '!εντολές']
- # Set all the variables necessary to connect to Twitch IRC
- HOST = "irc.twitch.tv"
- NICK = "teknon_my"
- PORT = 6667
- PASS = "oauth:ivjnfkclnur7cohwm3wghxpq9dvwcq"
- readbuffer = ""
- MODT = False
- # Connecting to Twitch IRC by passing credentials and joining a certain channel
- s = socket.socket()
- s.connect((HOST, PORT))
- s.send("PASS " + PASS + "\r\n")
- s.send("NICK " + NICK + "\r\n")
- s.send("JOIN #teknon_my \r\n")
- # Method for sending a message
- def send_message(old_message):
- new_message = "PRIVMSG #teknon_my : ΜΠΟΤ: " + old_message + "\r\n"
- s.send(new_message)
- print new_message
- send_message("Μπήκα!")
- # send_message("Dryzon = mouni")
- s.send("CAP REQ :twitch.tv/commands")
- time.sleep(1)
- s.send(".mods")
- time.sleep(1)
- while True:
- readbuffer += s.recv(1024)
- print readbuffer
- temp = string.split(readbuffer, "\n")
- readbuffer = temp.pop()
- for line in temp:
- # Checks whether the message is PING because its a method of Twitch to check if you're afk
- if line[0] == "PING":
- s.send("PONG %s\r\n" % line[1])
- else:
- # Splits the given string so we can work with it better
- parts = string.split(line, ":")
- if "QUIT" not in parts[1] and "JOIN" not in parts[1] and "PART" not in parts[1]:
- try:
- # Sets the message variable to the actual message sent
- message = parts[2][:len(parts[2]) - 1]
- except:
- message = ""
- # Sets the username variable to the actual username
- usernamesplit = string.split(parts[1], "!")
- username = usernamesplit[0]
- # Only works after twitch is done announcing stuff (MODT = Message of the day)
- if MODT:
- print username + ": " + message
- msg = message.lower()
- print msg
- # You can add all your plain commands here
- if msg == "γεια":
- send_message("Καλωσήρθες, " + username)
- elif msg == "!εντολές":
- for cmd in commands:
- send_message(cmd)
- for l in parts:
- if "End of /NAMES list" in l:
- MODT = True
- # print parts
- # time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement