import sys import socket import string import os HOST='irc.irchighway.net' #The server we want to connect to PORT=6667 #The connection port which is usually 6667 NICK='manga`list' #The bot's nickname IDENT='manga`list' REALNAME='s1ash' OWNER='woofcat' #The bot owner's nick CHANNELINIT='#mangashare' #The default channel for the bot readbuffer='' #Here we store all the messages from server s=socket.socket( ) #Create the socket s.connect((HOST, PORT)) #Connect to server s.send('NICK '+NICK+'n') #Send the nick to server s.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 ')