From f434dc976b291480a27ee2d13116b87ee06d924d Mon Sep 17 00:00:00 2001
From: Oliver <oliver@macbook.olisite.de>
Date: Sun, 13 Feb 2011 17:27:46 +0100
Subject: [PATCH] IRC handling Code in eine Klassenstruktur ueberfuehrt. Noch
 nicht fertig.

---
 bin/ircbridge/wzirc.py | 49 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 bin/ircbridge/wzirc.py

diff --git a/bin/ircbridge/wzirc.py b/bin/ircbridge/wzirc.py
new file mode 100644
index 0000000..85484ae
--- /dev/null
+++ b/bin/ircbridge/wzirc.py
@@ -0,0 +1,49 @@
+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
-- 
GitLab