Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import socket, string
- def isCommand(m,c):
- if(m==""):
- return False
- if(m[0]!='!'):
- return False
- x = m[1:]
- #print(x)]
- for i in range(len(c)):
- if(x[i]!=c[i]):
- return False
- return True
- def getUser(line):
- separate = line.split(":", 2)
- user = separate[0].split("!", 1)
- return user[0]
- def getMessage(line):
- separate = line.split(":", 2)
- message = separate[1]
- return message
- NICK = "shabobot"
- HOST = "irc.twitch.tv"
- PORT= 6667
- PASS = "oauth:73hqznjeownydhqnov7wwpnbm3dpfw"
- CHANNEL = "krajuuuuu"
- s = socket.socket()
- s.connect((HOST,PORT))
- s.send("PASS " + PASS + "\r\n")
- s.send("NICK " + NICK + "\r\n")
- s.send("JOIN #" + CHANNEL + "\r\n")
- def send_message(message):
- s.send("PRIVMSG #krajuuuuu :" + message + "\r\n")
- def timeout(user, time):
- s.send("PRIVMSG #krajuuuuu :.timeout " + user + " " + time + "\r\n")
- def ban(user):
- s.send("PRIVMSG #krajuuuuu :.ban " + user + "\r\n")
- def unban(user):
- s.send("PRIVMSF #krajuuuuu :.unban " + user + "\r\n")
- readbuffer = ""
- Loading = True
- while Loading:
- readbuffer = readbuffer + s.recv(1024)
- temp = string.split(readbuffer, "\n")
- readbuffer = temp.pop()
- #print("jestem")
- for line in temp:
- print(line)
- if("End of /NAMES list" in line):
- Loading = False
- send_message("Shabbot podłączony PogChamp")
- send_message("/w krajuuuuu masz")
- #timeout("mlodypatyk","1")
- def restart():
- readbuffer = ""
- while True:
- readbuffer = readbuffer + s.recv(1024)
- temp = string.split(readbuffer, "\n")
- readbuffer = temp.pop
- for line in temp:
- czy = True
- if line=="":
- czy = False
- magia = "PING"
- test = True
- if(czy):
- for i in range(4):
- if(line[i]!=magia[i]):
- test = False
- if test:
- czy = False
- s.send("PONG %s\r\n" % line[1])
- print line
- #print line
- if czy:
- x=line.split(":")
- user = x[1].split("!")[0]
- message = x[2]
- print(user + ": " + message)
- if(isCommand(message,"gruby")):
- send_message("cwel")
- if(isCommand(message, "rewon")):
- send_message("laps")
- if(isCommand(message, "shab")):
- send_message("król")
- if(isCommand(message, "kraju")):
- send_message("PogChamp")
- if(isCommand(message, "ala")):
- send_message(" PogChamp ALA PogChamp KOALA PogChamp HYPE PogChamp ")
- if(len(message)>250 ):
- timeout(user,"60")
- send_message("Nieładnie " + user + "!")
- readbuffer = ""
- restart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement