rendered paste body# bot commands## commands.py##class Say_asd: def comm(self,parent,line): parent.send("PRIVMSG #tonkman.org :asd")class topic: def __init__(self,original): self.original = original def comm(self,parent,line): self.line = line self.line = self.line.split("#topic ",2) if not "set_original" in self.line: parent.send("TOPIC #tonkman.org :"+self.line[1]) else: parent.send("TOPIC #tonkman.org :"+self.original)class whoami: def comm(self,parent,line): self.line = line self.line = self.line.split(" ") parent.send("PRIVMSG #tonkman.org :urz "+self.line[0])class kick: def comm(self,parent,line): self.line = line self.line = self.line.split("#kick",2) parent.send("KICK #tonkman.org "+self.line[1]+" :aariviiva")class auth: def __init__(self,auth_name,auth_passwd): self.name = auth_name self.passwd = auth_passwd self.authed = False def comm(self,parent,line): if not self.authed: parent.send("PRIVMSG Q@CServe.quakenet.org :auth "+self.name+" "+self.passwd) self.authed = True else: parent.send("PRIVMSG #tonkman.org :I'm authed already!")asd = Say_asd()topic = topic("Default topic")me = whoami()kick = kick()auth = auth("x","x")commands = {":#topic":topic,":#asd":asd,":#whoami":me,":#auth":auth,":#kick":kick}# the bot## irc.py##import socket, stringfrom commands import *server = "irc.quakenet.org"port = 6667nick = "aariviiva"class Irc_connection: def __init__(self,port,server,nick): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.server = server self.port = port self.nick = nick self.chans = ["#tonkman.org"] self.on = True self.can_join = False self.joined = False def con(self): self.s.connect((self.server,self.port)) self.send("USER "+self.nick+" "+self.nick+" 0 :"+self.nick+" i_lolled") self.send("NICK "+self.nick+"\n") def send(self, msg): self.s.send(msg+"\n") def check(self,line): if "221" in line: self.can_join = True if self.can_join and not self.joined: for i in self.chans: self.send("JOIN "+i) self.joined = True sline = line.split() if len(sline) > 3 and sline[3] in commands: z = filter(lambda x: x != "\n", sline[3]) commands[z].comm(self,line) if sline[0] == "PING": self.send("PONG "+sline[1]) print "PONG "+sline[1] def mainloop(self): self.con() while self.on: self.buf = self.s.recv(1024) self.check(self.buf) print self.bufdef main(): irc = Irc_connection(port,server,nick) irc.mainloop()if __name__ == "__main__": main()