Skip to content
Snippets Groups Projects
Commit f434dc97 authored by Oliver's avatar Oliver
Browse files

IRC handling Code in eine Klassenstruktur ueberfuehrt. Noch nicht fertig.

parent 8e43ad3f
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment