Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import socket, string, sys
- map = []
- file = open('workfile', 'r')
- lines = [line.rstrip('\n') for line in file]
- dawg = []
- for x in lines:
- if dawg==[]:
- dawg+=[x]
- else:
- dawg+=[int(x)]
- map+=[dawg]
- dawg=[]
- print map
- file.close
- def timeouttime(user):
- global map
- for x in map:
- if(x[0]==user):
- x[1] = x[1] + 30
- return x[1]
- map+=[[user,60]]
- return 60
- def rm(user):
- global map
- for x in map:
- if(x[0]==user):
- x[1] = 30
- 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
- def mquit():
- f = open('workfile', 'w')
- for x in map:
- f.write(x[0] + "\n" + str(x[1]) + "\n")
- f.close()
- sys.exit("blablabla")
- 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 #" + CHANNEL + " :" + message + "\r\n")
- def timeout(user, time):
- s.send("PRIVMSG #" + CHANNEL + " :.timeout " + user + " " + str(time) + "\r\n")
- def ban(user):
- s.send("PRIVMSG #" + CHANNEL + " :.ban " + user + "\r\n")
- def unban(user):
- s.send("PRIVMSF #" + CHANNEL + " :.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("/w krajuuuuu masz")
- #timeout("mlodypatyk","1")
- def restart():
- send_message("Shabbot podłączony PogChamp")
- readbuffer = ""
- mval = True
- while mval:
- 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(isCommand(message, "exitbot") and user == "mlodypatyk" or user == "krajuuuuu"):
- mval = False
- send_message("Shabobot odłączony BibleThump")
- mquit()
- if(len(message)>250 ):
- czas = timeouttime(user)
- timeout(user,czas)
- send_message("Nieładnie " + user + "! Timeout na " + str(czas) + " sekund!")
- readbuffer = ""
- restart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement