import sysimport socketimport stringimport osHOST='irc.irchighway.net' #The server we want to connect toPORT=6667 #The connection port which is usually 6667NICK='manga`list' #The bot's nicknameIDENT='manga`list'REALNAME='s1ash'OWNER='woofcat' #The bot owner's nickCHANNELINIT='#mangashare' #The default channel for the botreadbuffer='' #Here we store all the messages from server s=socket.socket( ) #Create the sockets.connect((HOST, PORT)) #Connect to servers.send('NICK '+NICK+'n') #Send the nick to servers.send('USER '+IDENT+' '+HOST+' bla :'+REALNAME+'n') #Identify to server while 1: line=s.recv(500) #recieve server messages print line if line.find('Welcome to the irchighway network')!=-1: #This is Crap(I wasn't sure about it but it works) s.send('JOIN '+CHANNELINIT+'n') #Join a channel if line.find('PRIVMSG')!=-1: #Call a parsing function parsemsg(line) line=line.rstrip() #remove trailing 'rn' line=line.split() if(line[0]=='PING'): #If server pings then pong s.send('PONG '+line[1]+'n') def parsemsg(msg): complete=msg[1:].split(':',1) #Parse the message into useful data info=complete[0].split(' ') msgpart=complete[1] sender=info[0].split('!') if msgpart[0]=='!' and sender[0]==OWNER: #Treat all messages starting with '!' as command cmd=msgpart[1:].split(' ') if cmd[0]=='list': s.send('MSG '+cmd[1]+'n'' test ')