import socket import message class Wzirc: # Settings HOST='irc.freenode.org' #HOST='127.0.0.1' PORT=6667 NICK='marvins_ircbride' IDENT='ircbridge' REALNAME='marvin' OWNER='warpzone' CHANNELINIT='#warpzone' rb = '' s = '' dgbmode = False; def __init__(self, ringbuffer): self.rb = ringbuffer self.s = socket.socket(); # Create a TCP Socket s.connect((self.HOST, self.PORT)) #Connect to server self.ircLoop() def enableIrcDebug(self): self.dbgmode = Tru def ircLoop(self): # Connect to the Server self.s.send('NICK ' + self.NICK + '\n') #Send the nick to server self.s.send('USER ' + self.IDENT + ' ' + self.HOST +' blub :' + self.REALNAME + '\n') #send the identification # Enter the main LOOP while 1: line = self.s.recv(1024) #recieve server messages - 1KB if self.dbgmode: print line if line.find('End of /MOTD command.')!=-1: # The connection stuff was sent. Join the channel. self.s.send('JOIN '+ self.CHANNELINIT +'\n') if line[0:4] == 'PING': #If server pings then anser with pong to keep connection alive pong = 'PONG '+ line[5:len(line)]+'\n' if self.dbgmode: print pong self.s.send(pong) #message Handling here