[Otfbot-svn] r110 - in trunk: . modules

cato- at BerliOS cato-
Do Jun 14 01:21:04 CEST 2007


Author: cato-
Date: 2007-06-14 01:21:02 +0200 (Thu, 14 Jun 2007)
New Revision: 110

Added:
   trunk/control.py
   trunk/modules/controlIRCMod.py
   trunk/modules/controlTCPMod.py
Removed:
   trunk/modules/controlMod.py
Modified:
   trunk/otfbot.py
Log:
* abstracted the control-logic
* added simple tcp-server, that allows control without irc

Added: trunk/control.py
===================================================================
--- trunk/control.py	2007-06-12 12:13:07 UTC (rev 109)
+++ trunk/control.py	2007-06-13 23:21:02 UTC (rev 110)
@@ -0,0 +1,204 @@
+# This file is part of OtfBot.
+#
+# OtfBot is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# OtfBot is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OtfBot; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# 
+# (c) 2007 Robert Weidlich
+#
+class configShell:
+    DESTROY_ME=234
+    def __init__(self, bot):
+        self.bot=bot
+        self.configlevel=[]
+
+    def _getlevellist(self):
+        if len(self.configlevel) == 0:
+            return self.bot.getNetworks()
+        elif len(self.configlevel) == 1:
+            return self.bot.getChannels(self.configlevel[0])
+        else:
+            return self.bot.getSubOptions(self.configlevel)
+    
+    def _ls(self):
+        out=""
+        lst=self._getlevellist()
+        for i in range(1,len(lst)):
+            out=out+str(i)+" "+lst[i-1]+" | "
+        return out
+        
+    def _cd(self, string):
+        if string == ".." and len(self.configlevel)>=0:
+            self.configlevel.pop()
+        else:
+            num=int(string)
+            if 0 < num and num < len(self._getlevellist())+1:
+                self.configlevel.append(self._getlevellist()[num-1])
+            else:
+                return "No such setting: "+str(num)
+    
+    def _get(self,string):
+        msg=string.split(" ")
+        #self.logger.debug(msg)
+        if len(msg) == 4:
+            res=self.bot.getConfig(msg[0], "",msg[1],msg[2],msg[3])
+        elif len(msg) == 3:
+            res=self.bot.getConfig(msg[0], "", msg[1], msg[2])
+        elif len(msg) == 2:
+            res=self.bot.getConfig(msg[0], "", msg[1])
+        elif len(msg) == 1:
+            res=self.bot.getConfig(msg[0], "")
+        if len(msg) == 0 or len(msg) > 4:
+            return "Syntax: config get key [modul] [network] [channel]"
+        else:
+            #self.logger.debug(".".join(msg))
+            #self.logger.debug(res)
+            return ".".join(msg)+"="+res
+    
+    def _set(self, string):
+        #FIXME: 
+        #msg=msg[4:]
+        #tmp=msg.split("=")
+        #if len(tmp) != 2:
+        #    self.bot.sendmsg(nick, "Syntax: config set key=value")
+        #    return
+        #self.bot.setConfig(tmp[0], tmp[1])
+        return "function is out of order"
+    
+    def input(self, request):
+        tmp = request.strip().split(" ",1)
+        if len(tmp) == 1:
+            command = tmp[0]
+            argument = ""
+        else:
+            (command, argument) = tmp
+        if command == "ls":
+            return self._ls()
+        elif command == "cd":
+            return self._cd(argument)
+        elif command == "quit":
+            return self.DESTROY_ME
+        elif command == "get":
+            return self._get(argument)
+        elif command == "set":
+            return self._set(argument)
+        else:
+            return "Some helpful text"
+            #self.bot.sendmsg(nick, "Syntax: config [get <key> [modul] [network] [channel]|set <key=value>]")
+
+
+class controlInterface:
+    MODUS_DEFAULT=0
+    MODUS_CONFIGSHELL=1
+    def __init__(self, bot):
+        self.bot=bot
+        self.modus=self.MODUS_DEFAULT
+        self.configshell=None
+    
+    def input(self, request):
+        tmp = request.strip().split(" ",1)
+        if len(tmp) == 1:
+            command=tmp[0]
+            argument=""
+        else:
+            (command, argument) = tmp
+        if command == "config":
+            self.configshell=configShell(self.bot)
+            return "Entering configshell ..."
+        elif self.configshell:
+            output = self.configshell.input(request)
+            if (output == self.configshell.DESTROY_ME):
+                self.configshell=None
+                return "Leaving configshell ..."
+            else:
+                return output
+        elif command == "help":
+            return "Available commands: reload, stop|quit, disconnect [network], connect network [port], listnetworks, changenick newnick, join channel, part channel [message], listchannels"
+        elif command == "reload":
+            self.bot.reloadModules()
+            return "Reloading all modules ..."
+        elif command == "listmodules":
+            module=[]
+            for mod in self.bot.mods:
+                module.append(mod.name)
+            return str(module)
+        elif command == "stop" or command == "quit":
+            conns=self.bot.getConnections()
+            for c in conns:
+                conns[c].disconnect()
+            return "Disconnecting from all networks und exiting ..."                
+        elif command == "disconnect":
+            args = argument.split(" ")
+            conns=self.bot.getConnections()
+            if len(args) == 2:
+                if conns.has_key(args[1]):
+                    conns[args[1]].disconnect()
+                    return "Disconnecting from "+str(conns[args[1]].getDestination())
+                else:
+                    return "Not connected to "+str(args[1])
+            else:
+                self.bot.quit("Bye.")
+                return "Disconnecting from current network. Bye."                
+        elif command == "connect":
+            args = argument.split(" ")
+            if len(args) < 1 or len(args) > 2:
+                return "Usage: connect irc.network.tld [port]"
+            else:
+                if len(args) == 2:
+                    port=args[2]
+                else:
+                    port=6667
+                self.bot.addConnection(args[1],port)
+                return "Connecting to "+str(self.bot.getConnections()[args[1]].getDestination())
+        elif command == "listnetworks":
+            ne=""
+            for n in self.bot.getConnections():
+                ne=ne+" "+n
+            return "Currently connected to:"+unicode(ne).encode("utf-8")
+        elif command == "listchannels":
+            ch=""
+            for c in self.bot.channel:
+                ch=ch+" "+c
+            return "Currently in:"+unicode(ch).encode("utf-8")
+        elif command == "changenick":
+            if argument == "":
+                return "Usage: changenick newnick"
+            else:
+                self.bot.setNick(argument)
+        elif command == "join":
+            if argument == "":
+                return "Usage: join channel"
+            else:
+                self.bot.join(argument)
+                return "Joined "+str(argument)
+        elif command == "part":
+            args=argument.split(" ",1)
+            if len(args) == 0:
+                return "Usage: part channel [message]"
+            else:
+                if len(args) > 1:
+                    partmsg=args[1]
+                else:
+                    partmsg=""
+                self.bot.leave(args[0],partmsg)
+                return "Left "+args[0]
+        elif command == "kick":
+            args=msg.split(" ",2)
+            if len(args) < 2:
+                return "Usage: kick channel user [message]"
+            else:
+                if len(args) == 2:
+                    self.bot.kick(args[0],args[1])
+                else:
+                    self.bot.kick(args[0],args[1],args[3])
+                return "Kicked "+args[1]+" from "+args[0]+"."

Copied: trunk/modules/controlIRCMod.py (from rev 109, trunk/modules/controlMod.py)
===================================================================
--- trunk/modules/controlMod.py	2007-06-12 12:13:07 UTC (rev 109)
+++ trunk/modules/controlIRCMod.py	2007-06-13 23:21:02 UTC (rev 110)
@@ -0,0 +1,47 @@
+# This file is part of OtfBot.
+#
+# OtfBot is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# OtfBot is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OtfBot; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# 
+# (c) 2005, 2006 by Alexander Schier
+#
+
+import random, re, string
+import chatMod
+from control import configShell, controlInterface
+
+class chatMod(chatMod.chatMod):
+	def __init__(self, bot):
+		self.bot=bot
+		self.control={}
+	
+	def msg(self, user, channel, msg):
+		nick=user.split("!")[0]
+		if self.bot.auth(user) > 7 and string.lower(channel)==string.lower(self.bot.nickname):
+			if not self.control.has_key(user):
+				self.control[user]=controlInterface(self.bot)
+			self.bot.sendmsg(nick,self.control[user].input(msg))
+
+		#elif channel==self.bot.nickname:
+		#	self.bot.sendmsg(nick,"Not authorized")
+		elif self.bot.auth(user) > -1 and msg[0] == "!": #TODO: make "!" configurable
+			if msg[1:7] == "reload":
+				if len(msg.split(" ")) == 2:
+					for chatMod in self.bot.mods:
+						if chatMod.name == msg.split(" ")[1]:
+							try:
+								chatMod.reload()
+								self.logger.info("Reloading Settings of "+chatMod.name)
+							except Exception, e:
+								self.logger.error("Error while reloading "+chatMod.name)

Deleted: trunk/modules/controlMod.py
===================================================================
--- trunk/modules/controlMod.py	2007-06-12 12:13:07 UTC (rev 109)
+++ trunk/modules/controlMod.py	2007-06-13 23:21:02 UTC (rev 110)
@@ -1,185 +0,0 @@
-# This file is part of OtfBot.
-#
-# OtfBot is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# OtfBot is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with OtfBot; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-# 
-# (c) 2005, 2006 by Alexander Schier
-#
-
-import random, re, string
-import chatMod
-
-class chatMod(chatMod.chatMod):
-	def __init__(self, bot):
-		self.bot=bot
-		self.configshell=False
-		self.configlevel=[]
-	
-	def configgetlevellist(self):
-		if len(self.configlevel) == 0:
-			return self.bot.getNetworks()
-		elif len(self.configlevel) == 1:
-			return self.bot.getChannels(self.configlevel[0])
-		else:
-			return self.bot.getSubOptions(self.configlevel)
-	
-	def msg(self, user, channel, msg):
-		nick=user.split("!")[0]
-		if self.bot.auth(user) > 7 and string.lower(channel)==string.lower(self.bot.nickname):
-			if msg[0:6] == "config":
-				self.configshell=True
-				self.configlevel=[]
-				self.bot.sendmsg(nick,"Entering configshell ...")
-			elif self.configshell:
-				if msg[0:2] == "ls":
-					out=""
-					lst=self.configgetlevellist()
-					for i in range(1,len(lst)):
-						out=out+str(i)+" "+lst[i-1]+" | "
-					self.bot.sendmsg(nick,out.encode("utf-8"))
-				elif msg[0:2] == "cd":
-					if msg[3:5] == ".." and len(self.configlevel)>=0:
-						self.configlevel.pop()
-					else:
-						num=int(msg[3:])
-						if 0 < num and num < len(self.configgetlevellist())+1:
-							self.configlevel.append(self.configgetlevellist()[num-1])
-						else:
-							self.bot.sendmsg(nick,"No such setting: "+str(num))
-				elif msg[0:4] == "quit":
-					self.configshell=False
-					self.bot.sendmsg(nick,"Leaving configshell ...")
-				elif msg[0:3] == "get":
-					msg=msg[4:]
-					msg=msg.split(" ")
-					#self.logger.debug(msg)
-					if len(msg) == 4:
-						res=self.bot.getConfig(msg[0], "",msg[1],msg[2],msg[3])
-					elif len(msg) == 3:
-						res=self.bot.getConfig(msg[0], "", msg[1], msg[2])
-					elif len(msg) == 2:
-						res=self.bot.getConfig(msg[0], "", msg[1])
-					elif len(msg) == 1:
-						res=self.bot.getConfig(msg[0], "")
-					if len(msg) == 0 or len(msg) > 4:
-						self.bot.sendmsg(nick, "Syntax: config get key [modul] [network] [channel]")
-					else:
-						#self.logger.debug(".".join(msg))
-						#self.logger.debug(res)
-						self.bot.sendmsg(nick, ".".join(msg).encode("utf-8")+"="+res.encode("utf-8"))
-				elif msg[0:3] == "set":
-					#FIXME: 
-					#msg=msg[4:]
-					#tmp=msg.split("=")
-					#if len(tmp) != 2:
-					#	self.bot.sendmsg(nick, "Syntax: config set key=value")
-					#	return
-					#self.bot.setConfig(tmp[0], tmp[1])
-					self.bot.sendmsg(nick, "function is out of order")
-				else:
-					self.bot.sendmsg(nick, "Syntax: config [get <key> [modul] [network] [channel]|set <key=value>]")
-			elif msg[0:4] == "help":
-				self.bot.sendmsg(nick,"Available administrationcommands: reload, stop|quit, disconnect [network], connect network [port], listnetworks, changenick newnick, join channel, part channel [message], listchannels")
-			elif msg[0:6] == "reload":
-				self.bot.sendmsg(nick,"Reloading all modules ...")
-				self.bot.reloadModules()
-			elif msg[0:11] == "listmodules":
-				module=[]
-				for mod in self.bot.mods:
-					module.append(mod.name)
-				self.bot.sendmsg(nick,str(module))
-			elif msg[0:4] == "stop" or msg[0:4] == "quit":
-				self.bot.sendmsg(nick,"Disconnecting from all networks und exiting ...")
-				conns=self.bot.getConnections()
-				for c in conns:
-					conns[c].disconnect()
-			elif msg[0:10] == "disconnect":
-				args = msg[10:].split(" ")
-				conns=self.bot.getConnections()
-				if len(args) == 2:
-					if conns.has_key(args[1]):
-						self.bot.sendmsg(nick,"Disconnecting from "+str(conns[args[1]].getDestination()))
-						conns[args[1]].disconnect()
-					else:
-						self.bot.sendmsg(nick,"Not connected to "+str(args[1]))
-				else:
-					self.bot.sendmsg(nick,"Disconnecting from current network. Bye.")
-					self.bot.quit("Bye.")
-			elif msg[0:7] == "connect":
-				args = msg[7:].split(" ")
-				if len(args) < 2 or len(args) > 3:
-					self.bot.sendmsg(nick,"Usage: connect irc.network.tld [port]")
-				else:
-					if len(args) == 3:
-						port=args[2]
-					else:
-						port=6667
-					self.bot.addConnection(args[1],port)
-					self.bot.sendmsg(nick,"Connecting to "+str(self.bot.getConnections()[args[1]].getDestination()))
-			elif msg[0:12] == "listnetworks":
-				ne=""
-				for n in self.bot.getConnections():
-					ne=ne+" "+n
-				self.bot.sendmsg(nick,"Currently connected to:"+unicode(ne).encode("utf-8"))
-			elif msg[0:12] == "listchannels":
-				ch=""
-				for c in self.bot.channel:
-					ch=ch+" "+c
-				self.bot.sendmsg(nick,"Currently in:"+unicode(ch).encode("utf-8"))
-			elif msg[0:10] == "changenick":
-				args=msg.split(" ")
-				if len(args) < 2:
-					self.bot.sendmsg(nick,"Usage: changenick newnick")
-				else:
-					self.bot.setNick(args[1])
-			elif msg[0:4] == "join":
-				args=msg.split(" ")
-				if len(args) < 2:
-					self.bot.sendmsg(nick,"Usage: join channel")
-				else:
-					self.bot.join(args[1])
-					self.bot.sendmsg(nick,"Joined "+str(args[1]))
-			elif msg[0:4] == "part":
-				args=msg.split(" ")
-				if len(args) == 1:
-					self.bot.sendmsg(nick,"Usage: part channel [message]")
-				else:
-					if len(args) > 2:
-						partmsg=" ".join(args[2:])
-					else:
-						partmsg=""
-					self.bot.leave(args[1],partmsg)
-					self.bot.sendmsg(nick,"Left "+args[1])
-			elif msg[0:4] == "kick":
-				args=msg.split(" ")
-				if len(args) < 3:
-					self.bot.sendmsg(nick,"Usage: kick channel user [message]")
-				else:
-					if len(args) == 3:
-						self.bot.kick(args[1],args[2])
-					else:
-						self.bot.kick(args[1],args[2]," ".join(args[3:]))
-					self.bot.sendmsg(nick,"Kicked "+args[2]+" from "+args[1]+".")
-		#elif channel==self.bot.nickname:
-		#	self.bot.sendmsg(nick,"Not authorized")
-		elif self.bot.auth(user) > -1 and msg[0] == "!": #TODO: make "!" configurable
-			if msg[1:7] == "reload":
-				if len(msg.split(" ")) == 2:
-					for chatMod in self.bot.mods:
-						if chatMod.name == msg.split(" ")[1]:
-							try:
-								chatMod.reload()
-								self.logger.info("Reloading Settings of "+chatMod.name)
-							except Exception, e:
-								self.logger.error("Error while reloading "+chatMod.name)

Added: trunk/modules/controlTCPMod.py
===================================================================
--- trunk/modules/controlTCPMod.py	2007-06-12 12:13:07 UTC (rev 109)
+++ trunk/modules/controlTCPMod.py	2007-06-13 23:21:02 UTC (rev 110)
@@ -0,0 +1,46 @@
+# This file is part of OtfBot.
+#
+# OtfBot is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# OtfBot is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OtfBot; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# 
+# (c) 2007 Robert Weidlich
+#
+
+# TODO: * some authorization
+#       * configuring point of listening (TCP, SSL, Socket)
+#       * clientapp
+
+from twisted.internet import reactor, protocol
+from twisted.protocols import basic
+import chatMod
+from control import configShell, controlInterface
+
+class BotProtocol(basic.LineOnlyReceiver):
+    def dataReceived(self, data):
+        self.sendLine(self.control.input(data))
+    def connectionMade(self):
+        self.control=controlInterface(self.factory.bot)
+
+class BotProtocolFactory(protocol.ServerFactory):
+    def __init__(self, bot):
+        self.bot=bot
+        self.protocol=BotProtocol
+
+class chatMod(chatMod.chatMod):
+    def __init__(self, bot):
+        self.bot=bot
+    def start(self):
+        f=BotProtocolFactory(self.bot)
+        reactor.listenTCP(5022, f)
+

Modified: trunk/otfbot.py
===================================================================
--- trunk/otfbot.py	2007-06-12 12:13:07 UTC (rev 109)
+++ trunk/otfbot.py	2007-06-13 23:21:02 UTC (rev 110)
@@ -27,6 +27,8 @@
 import os, random, string, re, sys, traceback, atexit
 import functions, config, scheduler
 
+
+# some constants, can be retrieved from serveranswer while connecting.
 modchars={'a':'!','o':'@','h':'%','v':'+'}
 modcharvals={'!':4,'@':3,'%':2,'+':1,' ':0}
 
@@ -43,27 +45,27 @@
 
 (options,args)=parser.parse_args()
 if options.debug and options.debug not in (10,20,30,40,50):
-	parser.error("Unknown value for --debug")
+    parser.error("Unknown value for --debug")
 ###############################################################################
 #check for root rights
 if os.getuid()==0:
-	if options.userid and options.userid!=0 and options.groupid and options.groupid!=0:
-		from twisted.python.util import switchUID
-		#os.chroot(".") #DOES NOT WORK. pwd.getpwuid fails in switchUID, when chrooted.
-		switchUID(options.userid, options.groupid)
-	else:
-		print "Otfbot should not be run as root."
-		print "please use -u and -g to specify a userid/groupid"
-		sys.exit(1)
+    if options.userid and options.userid!=0 and options.groupid and options.groupid!=0:
+        from twisted.python.util import switchUID
+        #os.chroot(".") #DOES NOT WORK. pwd.getpwuid fails in switchUID, when chrooted.
+        switchUID(options.userid, options.groupid)
+    else:
+        print "Otfbot should not be run as root."
+        print "please use -u and -g to specify a userid/groupid"
+        sys.exit(1)
 ###############################################################################
 # Detaching from console
 if options.foreground == False and not options.debug > 0:
-	try:
-		import subprocess
-		subprocess.Popen([sys.argv[0],"-f"])
-		sys.exit(0)
-	except ImportError:
-		pass
+    try:
+        import subprocess
+        subprocess.Popen([sys.argv[0],"-f"])
+        sys.exit(0)
+    except ImportError:
+        pass
 ###############################################################################
 # Setup Logging
 import logging
@@ -79,46 +81,46 @@
 #corelogger.addHandler(filelogger)
 
 if options.debug > 0:
-	# logging to stdout
-	console = logging.StreamHandler()
-	logging.getLogger('').setLevel(options.debug)
-	formatter = logging.Formatter('%(asctime)s %(name)-10s %(module)-18s %(levelname)-8s %(message)s')
-	console.setFormatter(formatter)
-	logging.getLogger('').addHandler(console)
-	#corelogger.addHandler(console)
+    # logging to stdout
+    console = logging.StreamHandler()
+    logging.getLogger('').setLevel(options.debug)
+    formatter = logging.Formatter('%(asctime)s %(name)-10s %(module)-18s %(levelname)-8s %(message)s')
+    console.setFormatter(formatter)
+    logging.getLogger('').addHandler(console)
+    #corelogger.addHandler(console)
 corelogger = logging.getLogger('core')
 corelogger.info("Starting OtfBot - Version svn "+str(svnversion))
 
 def logerror(logger, module, exception):
-	logger.error("Exception in Module "+module+": "+str(exception))
-	tb_list = traceback.format_tb(sys.exc_info()[2])
-	for entry in tb_list:
-		for line in entry.strip().split("\n"):
-			logger.error(line)
+    logger.error("Exception in Module "+module+": "+str(exception))
+    tb_list = traceback.format_tb(sys.exc_info()[2])
+    for entry in tb_list:
+        for line in entry.strip().split("\n"):
+            logger.error(line)
 
 ###############################################################################
 # Function which is called, when the program terminates.
 def exithook():
-	# remove Pidfile
-	os.remove(pidfile)
-	writeConfig()
-	corelogger.info("Bot shutted down")
-	corelogger.info("-------------------------")
+    # remove Pidfile
+    os.remove(pidfile)
+    writeConfig()
+    corelogger.info("Bot shutted down")
+    corelogger.info("-------------------------")
 
 # Load modules
 sys.path.insert(1,"modules")
 classes=[]
 for file in os.listdir("modules"):
-	if len(file)>=3 and file[-3:]==".py":
-		classes.append(__import__("modules/"+file[:-3]))
-		classes[-1].datadir = classes[-1].__name__+"-data"
-		corelogger.debug("Loading module "+classes[-1].__name__)
+    if len(file)>=3 and file[-3:]==".py":
+        classes.append(__import__(file[:-3]))
+        classes[-1].datadir = "modules/"+classes[-1].__name__+"-data"
+        corelogger.debug("Loading module "+classes[-1].__name__)
 
 
 # react on signals
 #import signal
 #def signalhandler(signal, frame):
-#	corelogger.info("Got Signal "+str(signal))
+#    corelogger.info("Got Signal "+str(signal))
 #signal.signal(signal.SIGHUP,signalhandler)
 #signal.signal(signal.SIGTERM,signalhandler)
 
@@ -126,346 +128,346 @@
 # some config functions
 theconfig=None
 def setConfig(option, value, module=None, network=None, channel=None):
-	theconfig.set(option, value, module, network, channel)
-	writeConfig()
-		
+    theconfig.set(option, value, module, network, channel)
+    writeConfig()
+        
 def hasConfig(option, module=None):
-	return theconfig.has(option, module)
+    return theconfig.has(option, module)
 def getConfig(option, defaultvalue="", module=None, network=None, channel=None):
-	return theconfig.get(option, defaultvalue, module, network, channel)
+    return theconfig.get(option, defaultvalue, module, network, channel)
 def getBoolConfig(option, defaultvalue="", module=None, network=None, channel=None):
-	if theconfig.get(option, defaultvalue, module, network, channel) in ["True","true","On","on","1"]:
-		return True
-	return False
+    if theconfig.get(option, defaultvalue, module, network, channel) in ["True","true","On","on","1"]:
+        return True
+    return False
 
 def loadConfig(myconfigfile):
-	if os.path.exists(myconfigfile):
-		myconfig=config.config(logging, myconfigfile)
-	else:
-		myconfig=config.config(logging)
-		for myclass in classes:
-			try:
-				modconfig=myclass.default_settings()
-				for item in modconfig.keys():
-					myconfig.set(item, modconfig[item])
-			except AttributeError:
-				pass
-		
-		myconfig.set('enabled', 'false', 'main', 'irc.samplenetwork')
-		myconfig.set('enabled', 'false', 'main', 'irc.samplenetwork', '#example')
-		myconfig.set('nickname', 'OtfBot', 'main')
-		myconfig.set('encoding', 'UTF-8', 'main')
-		myconfig.set('pidfile','otfbot.pid','main')
-		
-		file=open(myconfigfile, "w")
-		file.write(myconfig.exportxml())
-		file.close()
-		#no logger here: the user needs to read this on console, not in logfile
-		print "Default Settings loaded."
-		print "Edit config.xml to configure the bot."
-		sys.exit(0)
-	return myconfig
+    if os.path.exists(myconfigfile):
+        myconfig=config.config(logging, myconfigfile)
+    else:
+        myconfig=config.config(logging)
+        for myclass in classes:
+            try:
+                modconfig=myclass.default_settings()
+                for item in modconfig.keys():
+                    myconfig.set(item, modconfig[item])
+            except AttributeError:
+                pass
+        
+        myconfig.set('enabled', 'false', 'main', 'irc.samplenetwork')
+        myconfig.set('enabled', 'false', 'main', 'irc.samplenetwork', '#example')
+        myconfig.set('nickname', 'OtfBot', 'main')
+        myconfig.set('encoding', 'UTF-8', 'main')
+        myconfig.set('pidfile','otfbot.pid','main')
+        
+        file=open(myconfigfile, "w")
+        file.write(myconfig.exportxml())
+        file.close()
+        #no logger here: the user needs to read this on console, not in logfile
+        print "Default Settings loaded."
+        print "Edit config.xml to configure the bot."
+        sys.exit(0)
+    return myconfig
 
 def writeConfig():
-	file=open(configfile, "w")
-	#options=config.keys()
-	#options.sort()
-	#for option in options:
-	#	file.write(option+"="+config[option]+"\n")
-	file.write(theconfig.exportxml())
-	file.close()
+    file=open(configfile, "w")
+    #options=config.keys()
+    #options.sort()
+    #for option in options:
+    #    file.write(option+"="+config[option]+"\n")
+    file.write(theconfig.exportxml())
+    file.close()
 
 schedulethread=scheduler.Schedule()
 schedulethread.start()
 
 def addScheduleJob(time, function):
-	schedulethread.addScheduleJob(time, function)
-	
+    schedulethread.addScheduleJob(time, function)
+    
 class Bot(irc.IRCClient):
-	"""A Chat Bot"""
-	def __init__(self):
-		#list of mods, which the bot should use
-		#you may need to configure them first
-		self.classes = classes
-		self.users={}
-		self.channel=[]
-		self.network=None
-	
-		self.mods = []
-		self.numMods = 0
+    """A Chat Bot"""
+    def __init__(self):
+        #list of mods, which the bot should use
+        #you may need to configure them first
+        self.classes = classes
+        self.users={}
+        self.channel=[]
+        self.network=None
+    
+        self.mods = []
+        self.numMods = 0
 
-		self.versionName="OtfBot"
-		self.versionNum="svn "+str(svnversion)
-		self.versionEnv="" #sys.version
-		self.logging = logging
-		self.logger = logging.getLogger("core")
-		self.logger.info("Starting new Botinstance")
-		self.startMods()
+        self.versionName="OtfBot"
+        self.versionNum="svn "+str(svnversion)
+        self.versionEnv="" #sys.version
+        self.logging = logging
+        self.logger = logging.getLogger("core")
+        self.logger.info("Starting new Botinstance")
+        self.startMods()
 
-	def _apirunner(self,apifunction,args={}):
-		for mod in self.mods:
-			if (args.has_key("channel") and args["channel"] in self.channels and self.getBoolConfig("enabled","True",mod.name,self.network,args["channel"])) or not args.has_key("channel") or args["channel"] not in self.channels:
-				try:
-					getattr(mod,apifunction)(**args)
-				except Exception, e:
-					logerror(self.logger, mod.name, e)
-	
-	# public API
-	def startMods(self):
-		workingdir=os.getcwd()
-		for chatModule in self.classes:
-			#if self.getConfig("enabled","true",chatModule.__name__,self.network)
-			self.mods.append( chatModule.chatMod(self) )
-			self.mods[-1].setLogger(self.logger)
-			self.mods[-1].name = chatModule.__name__
-			#try:
-			#	self.mods[-1].start()
-			#except AttributeError:
-			#	pass
-		self._apirunner("start")
-	def setConfig(self, option, value, module=None, network=None, channel=None):
-		return setConfig(option, value, module, network, channel)
-	def hasConfig(self, option, module=None):
-		return hasConfig(option, module)
-	def getConfig(self, option, defaultvalue="", module=None, network=None, channel=None):
-		return getConfig(option, defaultvalue, module, network, channel)
-	def getBoolConfig(self, option, defaultvalue="", module=None, network=None, channel=None):
-		return getBoolConfig(option, defaultvalue, module, network, channel)
-	def getSubOptions(self, list):
-		return theconfig.getsubopts(list)
-	def getNetworks(self):
-		return theconfig.getNetworks()
-	def getChannels(self,net):
-		return theconfig.getChannels(net)
-	def loadConfig(self):
-		return loadConfig(configfile)
-	def writeConfig(self):
-		return writeConfig()
-	def getUsers(self):
-		return self.users
-	def addScheduleJob(self, time, function):
-		return addScheduleJob(time, function)
-	def getConnections(self):
-		return connections
-	def addConnection(self,address,port):
-		f = BotFactory(address,[])
-		connections[address]=reactor.connectTCP(unicode(address).encode("iso-8859-1"),port,f)
-	def getReactor(self):
-		return reactor
+    def _apirunner(self,apifunction,args={}):
+        for mod in self.mods:
+            if (args.has_key("channel") and args["channel"] in self.channels and self.getBoolConfig("enabled","True",mod.name,self.network,args["channel"])) or not args.has_key("channel") or args["channel"] not in self.channels:
+                try:
+                    getattr(mod,apifunction)(**args)
+                except Exception, e:
+                    logerror(self.logger, mod.name, e)
+    
+    # public API
+    def startMods(self):
+        workingdir=os.getcwd()
+        for chatModule in self.classes:
+            #if self.getConfig("enabled","true",chatModule.__name__,self.network)
+            self.mods.append( chatModule.chatMod(self) )
+            self.mods[-1].setLogger(self.logger)
+            self.mods[-1].name = chatModule.__name__
+            #try:
+            #    self.mods[-1].start()
+            #except AttributeError:
+            #    pass
+        self._apirunner("start")
+    def setConfig(self, option, value, module=None, network=None, channel=None):
+        return setConfig(option, value, module, network, channel)
+    def hasConfig(self, option, module=None):
+        return hasConfig(option, module)
+    def getConfig(self, option, defaultvalue="", module=None, network=None, channel=None):
+        return getConfig(option, defaultvalue, module, network, channel)
+    def getBoolConfig(self, option, defaultvalue="", module=None, network=None, channel=None):
+        return getBoolConfig(option, defaultvalue, module, network, channel)
+    def getSubOptions(self, list):
+        return theconfig.getsubopts(list)
+    def getNetworks(self):
+        return theconfig.getNetworks()
+    def getChannels(self,net):
+        return theconfig.getChannels(net)
+    def loadConfig(self):
+        return loadConfig(configfile)
+    def writeConfig(self):
+        return writeConfig()
+    def getUsers(self):
+        return self.users
+    def addScheduleJob(self, time, function):
+        return addScheduleJob(time, function)
+    def getConnections(self):
+        return connections
+    def addConnection(self,address,port):
+        f = BotFactory(address,[])
+        connections[address]=reactor.connectTCP(unicode(address).encode("iso-8859-1"),port,f)
+    def getReactor(self):
+        return reactor
 
-	def auth(self, user):
-		"""test if the user is privileged"""
-		level=0
-		for mod in self.mods:
-			try:
-				retval=mod.auth(user)
-				if retval > level:
-					level=retval
-			except AttributeError:
-				pass
-		return level
-	
-	def sendmsg(self, channel, msg, encoding="iso-8859-15", fallback="iso-8859-15"):
-		"""msg function, that converts from iso-8859-15 to a encoding given in the config"""
-		try:
-			msg=unicode(msg, encoding).encode(self.getConfig("encoding", "UTF-8", "main"))
-		except UnicodeDecodeError:
-			#self.logger.debug("Unicode Decode Error with String:"+str(msg))
-			#Try with Fallback encoding
-			msg=unicode(msg, fallback).encode(self.getConfig("encoding", "UTF-8", "main"))
-		except UnicodeEncodeError:
-			pass
-			#self.logger.debug("Unicode Encode Error with String:"+str(msg))
-			#use msg as is
-			
-		self.msg(channel, msg)
-		self.privmsg(self.nickname, channel, msg)
-		
-	def sendme(self, channel, action, encoding="iso-8859-15"):
-		"""msg function, that converts from iso-8859-15 to a encoding given in the config"""
-		action=unicode(action, encoding).encode(self.getConfig("encoding", "UTF-8", "main"))
-			
-		self.me(channel, action)
-		self.action(self.nickname, channel, action)
-	
-	def reloadModules(self):
-		for chatModule in self.classes:
-			self.logger.info("reloading "+chatModule.__name__)
-			reload(chatModule)
-		for chatMod in self.mods:
-			try:
-				chatMod.stop()
-			except Exception, e:
-				logerror(self.logger, mod.name, e)
-		self.mods=[]
-		self.startMods()	
-	
-	# Callbacks
-	def connectionMade(self):
-		self.network=self.factory.network
-		self.channels=self.factory.channels
-		self.nickname=unicode(self.getConfig("nickname", "OtfBot", 'main', self.network)).encode("iso-8859-1")
-		if len(self.network.split(".")) < 2:
-			nw = self.network
-		else:
-			nw = self.network.split(".")[-2]
-		self.logger = self.logging.getLogger(nw)
-		self.logger.info("made connection to "+self.network)
-		irc.IRCClient.connectionMade(self)
-		for mod in self.mods:
-			mod.setLogger(self.logger)
-			mod.network=self.network
-		self._apirunner("connectionMade")
+    def auth(self, user):
+        """test if the user is privileged"""
+        level=0
+        for mod in self.mods:
+            try:
+                retval=mod.auth(user)
+                if retval > level:
+                    level=retval
+            except AttributeError:
+                pass
+        return level
+    
+    def sendmsg(self, channel, msg, encoding="iso-8859-15", fallback="iso-8859-15"):
+        """msg function, that converts from iso-8859-15 to a encoding given in the config"""
+        try:
+            msg=unicode(msg, encoding).encode(self.getConfig("encoding", "UTF-8", "main"))
+        except UnicodeDecodeError:
+            #self.logger.debug("Unicode Decode Error with String:"+str(msg))
+            #Try with Fallback encoding
+            msg=unicode(msg, fallback).encode(self.getConfig("encoding", "UTF-8", "main"))
+        except UnicodeEncodeError:
+            pass
+            #self.logger.debug("Unicode Encode Error with String:"+str(msg))
+            #use msg as is
+            
+        self.msg(channel, msg)
+        self.privmsg(self.nickname, channel, msg)
+        
+    def sendme(self, channel, action, encoding="iso-8859-15"):
+        """msg function, that converts from iso-8859-15 to a encoding given in the config"""
+        action=unicode(action, encoding).encode(self.getConfig("encoding", "UTF-8", "main"))
+            
+        self.me(channel, action)
+        self.action(self.nickname, channel, action)
+    
+    def reloadModules(self):
+        for chatModule in self.classes:
+            self.logger.info("reloading "+chatModule.__name__)
+            reload(chatModule)
+        for chatMod in self.mods:
+            try:
+                chatMod.stop()
+            except Exception, e:
+                logerror(self.logger, mod.name, e)
+        self.mods=[]
+        self.startMods()    
+    
+    # Callbacks
+    def connectionMade(self):
+        self.network=self.factory.network
+        self.channels=self.factory.channels
+        self.nickname=unicode(self.getConfig("nickname", "OtfBot", 'main', self.network)).encode("iso-8859-1")
+        if len(self.network.split(".")) < 2:
+            nw = self.network
+        else:
+            nw = self.network.split(".")[-2]
+        self.logger = self.logging.getLogger(nw)
+        self.logger.info("made connection to "+self.network)
+        irc.IRCClient.connectionMade(self)
+        for mod in self.mods:
+            mod.setLogger(self.logger)
+            mod.network=self.network
+        self._apirunner("connectionMade")
 
-	def connectionLost(self, reason):
-		#self.logger.info("lost connection: "+str(reason))
-		irc.IRCClient.connectionLost(self)
-		self._apirunner("connectionLost",{"reason": reason})
-	
-	def signedOn(self):
-		self.logger.info("signed on "+self.network+" as "+self.nickname)
+    def connectionLost(self, reason):
+        #self.logger.info("lost connection: "+str(reason))
+        irc.IRCClient.connectionLost(self)
+        self._apirunner("connectionLost",{"reason": reason})
+    
+    def signedOn(self):
+        self.logger.info("signed on "+self.network+" as "+self.nickname)
 
-		for channel in self.factory.channels:
-			if(getBoolConfig("enabled", "false", "main", self.factory.network, channel)):
-				self.join(unicode(channel).encode("iso-8859-1"))
-		self._apirunner("signedOn")
+        for channel in self.factory.channels:
+            if(getBoolConfig("enabled", "false", "main", self.factory.network, channel)):
+                self.join(unicode(channel).encode("iso-8859-1"))
+        self._apirunner("signedOn")
 
-	def joined(self, channel):
-		self.logger.info("joined "+channel)
-		self.channel.append(channel)
-		self.users[channel]={}
-		self._apirunner("joined",{"channel":channel})
+    def joined(self, channel):
+        self.logger.info("joined "+channel)
+        self.channel.append(channel)
+        self.users[channel]={}
+        self._apirunner("joined",{"channel":channel})
 
-	def left(self, channel):
-		self.logger.info("left "+channel)
-		del self.users[channel]
-		self.channel.remove(channel)
-		self._apirunner("left",{"channel":channel})
+    def left(self, channel):
+        self.logger.info("left "+channel)
+        del self.users[channel]
+        self.channel.remove(channel)
+        self._apirunner("left",{"channel":channel})
 
-	def privmsg(self, user, channel, msg):
-		self._apirunner("privmsg",{"user":user,"channel":channel,"msg":msg})
-		self._apirunner("msg",{"user":user,"channel":channel,"msg":msg})
-		#nick = user.split("!")[0]
-		#if channel == self.nickname and self.auth(nick) > 9:
-		#if msg == "!who":
-		#	self.sendLine("WHO "+channel)
-		#if msg[:6] == "!whois":
-		#	self.sendLine("WHOIS "+msg[7:])
-		#if msg == "!user":
-		#	self.sendmsg(channel,str(self.users))
+    def privmsg(self, user, channel, msg):
+        self._apirunner("privmsg",{"user":user,"channel":channel,"msg":msg})
+        self._apirunner("msg",{"user":user,"channel":channel,"msg":msg})
+        #nick = user.split("!")[0]
+        #if channel == self.nickname and self.auth(nick) > 9:
+        #if msg == "!who":
+        #    self.sendLine("WHO "+channel)
+        #if msg[:6] == "!whois":
+        #    self.sendLine("WHOIS "+msg[7:])
+        #if msg == "!user":
+        #    self.sendmsg(channel,str(self.users))
 
-	def irc_unknown(self, prefix, command, params):
-		#self.logger.debug(str(prefix)+" : "+str(command)+" : "+str(params))
-		#parse /names-list which is sent when joining a channel
-		if command == "RPL_NAMREPLY":
-			for nick in params[3].strip().split(" "):
-				if nick[0] in "@%+!":
-					s=nick[0]
-					nick=nick[1:]
-				else:
-					s=" "
-				self.users[params[2]][nick]={'modchar':s}
-		self._apirunner("irc_unknown",{"prefix":prefix,"command":command,"params":params})
+    def irc_unknown(self, prefix, command, params):
+        #self.logger.debug(str(prefix)+" : "+str(command)+" : "+str(params))
+        #parse /names-list which is sent when joining a channel
+        if command == "RPL_NAMREPLY":
+            for nick in params[3].strip().split(" "):
+                if nick[0] in "@%+!":
+                    s=nick[0]
+                    nick=nick[1:]
+                else:
+                    s=" "
+                self.users[params[2]][nick]={'modchar':s}
+        self._apirunner("irc_unknown",{"prefix":prefix,"command":command,"params":params})
 
-	def noticed(self, user, channel, msg):
-		self._apirunner("noticed",{"user":user,"channel":channel,"msg":msg})
-				
-	def action(self, user, channel, message):
-		self._apirunner("action",{"user":user,"channel":channel,"message":message})
+    def noticed(self, user, channel, msg):
+        self._apirunner("noticed",{"user":user,"channel":channel,"msg":msg})
+                
+    def action(self, user, channel, message):
+        self._apirunner("action",{"user":user,"channel":channel,"message":message})
 
-	def modeChanged(self, user, channel, set, modes, args):
-		self._apirunner("modeChanged",{"user":user,"channel":channel,"set":set,"modes":modes,"args":args})
-		i=0
-		for arg in args:
-			if modes[i] in modchars.keys() and set == True:
-				if modcharvals[modchars[modes[i]]] > modcharvals[self.users[channel][arg]['modchar']]:
-					self.users[channel][arg]['modchar'] = modchars[modes[i]]
-			elif modes[i] in modchars.keys() and set == False:
-				#FIXME: ask for the real mode
-				self.users[channel][arg]['modchar'] = ' '
-			i=i+1
+    def modeChanged(self, user, channel, set, modes, args):
+        self._apirunner("modeChanged",{"user":user,"channel":channel,"set":set,"modes":modes,"args":args})
+        i=0
+        for arg in args:
+            if modes[i] in modchars.keys() and set == True:
+                if modcharvals[modchars[modes[i]]] > modcharvals[self.users[channel][arg]['modchar']]:
+                    self.users[channel][arg]['modchar'] = modchars[modes[i]]
+            elif modes[i] in modchars.keys() and set == False:
+                #FIXME: ask for the real mode
+                self.users[channel][arg]['modchar'] = ' '
+            i=i+1
 
-	def userKicked(self, kickee, channel, kicker, message):
-		self._apirunner("userKicked",{"kickee":kickee,"channel":channel,"kicker":kicker,"message":message})
+    def userKicked(self, kickee, channel, kicker, message):
+        self._apirunner("userKicked",{"kickee":kickee,"channel":channel,"kicker":kicker,"message":message})
 
-	def userJoined(self, user, channel):
-		self._apirunner("userJoined",{"user":user,"channel":channel})
-		self.users[channel][user.split("!")[0]]={'modchar':' '}
+    def userJoined(self, user, channel):
+        self._apirunner("userJoined",{"user":user,"channel":channel})
+        self.users[channel][user.split("!")[0]]={'modchar':' '}
 
-	def userLeft(self, user, channel):
-		self._apirunner("userLeft",{"user":user,"channel":channel})
-		del self.users[channel][user.split("!")[0]]
+    def userLeft(self, user, channel):
+        self._apirunner("userLeft",{"user":user,"channel":channel})
+        del self.users[channel][user.split("!")[0]]
 
-	def userQuit(self, user, quitMessage):
-		self._apirunner("userQuit",{"user":user,"quitMessage":quitMessage})
-		for chan in self.users:
-			if self.users[chan].has_key(user):
-				del self.users[chan][user]
+    def userQuit(self, user, quitMessage):
+        self._apirunner("userQuit",{"user":user,"quitMessage":quitMessage})
+        for chan in self.users:
+            if self.users[chan].has_key(user):
+                del self.users[chan][user]
 
-	def yourHost(self, info):
-		pass
-	
-	#def ctcpQuery(self, user, channel, messages):
-	#	(query,t) = messages[0]
-	#	answer = None
-	#	#if query == "VERSION":
-	#	#	answer = "chatBot - a python IRC-Bot"
-	#	if answer: 
-	#		self.ctcpMakeReply(user.split("!")[0], [(query,answer)])
-	#		self.logger.info("Answered to CTCP "+query+" Request from "+user.split("!")[0])
+    def yourHost(self, info):
+        pass
+    
+    #def ctcpQuery(self, user, channel, messages):
+    #    (query,t) = messages[0]
+    #    answer = None
+    #    #if query == "VERSION":
+    #    #    answer = "chatBot - a python IRC-Bot"
+    #    if answer: 
+    #        self.ctcpMakeReply(user.split("!")[0], [(query,answer)])
+    #        self.logger.info("Answered to CTCP "+query+" Request from "+user.split("!")[0])
 
-		
-	def userRenamed(self, oldname, newname):
-		for chan in self.users:
-			if self.users[chan].has_key(oldname):
-				self.users[chan][newname]=self.users[chan][oldname]
-				del self.users[chan][oldname]
-		self._apirunner("userRenamed",{"oldname":oldname,"newname":newname})
+        
+    def userRenamed(self, oldname, newname):
+        for chan in self.users:
+            if self.users[chan].has_key(oldname):
+                self.users[chan][newname]=self.users[chan][oldname]
+                del self.users[chan][oldname]
+        self._apirunner("userRenamed",{"oldname":oldname,"newname":newname})
 
-	def topicUpdated(self, user, channel, newTopic):
-		self._apirunner("topicUpdated",{"user":user,"channel":channel,"newTopic":newTopic})
+    def topicUpdated(self, user, channel, newTopic):
+        self._apirunner("topicUpdated",{"user":user,"channel":channel,"newTopic":newTopic})
 
-	def lineReceived(self, line):
-		#self.logger.debug(str(line))
-		# adding a correct hostmask for join, part and quit
-		if line.split(" ")[1] == "JOIN" and line[1:].split(" ")[0].split("!")[0] != self.nickname:
-			self.userJoined(line[1:].split(" ")[0],string.lower(line.split(" ")[2][1:]))
-			#self.joined(line[1:].split(" ")[0],line.split(" ")[2][1:])
-		elif line.split(" ")[1] == "PART" and line[1:].split(" ")[0].split("!")[0] != self.nickname:
-			self.userLeft(line[1:].split(" ")[0],line.split(" ")[2])
-		elif line.split(" ")[1] == "QUIT":
-			self.userQuit(line[1:].split(" ")[0],line.split("QUIT :")[1])
-		else:
-			irc.IRCClient.lineReceived(self,line)
-			
+    def lineReceived(self, line):
+        #self.logger.debug(str(line))
+        # adding a correct hostmask for join, part and quit
+        if line.split(" ")[1] == "JOIN" and line[1:].split(" ")[0].split("!")[0] != self.nickname:
+            self.userJoined(line[1:].split(" ")[0],string.lower(line.split(" ")[2][1:]))
+            #self.joined(line[1:].split(" ")[0],line.split(" ")[2][1:])
+        elif line.split(" ")[1] == "PART" and line[1:].split(" ")[0].split("!")[0] != self.nickname:
+            self.userLeft(line[1:].split(" ")[0],line.split(" ")[2])
+        elif line.split(" ")[1] == "QUIT":
+            self.userQuit(line[1:].split(" ")[0],line.split("QUIT :")[1])
+        else:
+            irc.IRCClient.lineReceived(self,line)
+            
 class BotFactory(protocol.ReconnectingClientFactory):
-	"""The Factory for the Bot"""
-	protocol = Bot
+    """The Factory for the Bot"""
+    protocol = Bot
 
-	def __init__(self, networkname, channels):
-		self.network=networkname
-		self.channels = channels
+    def __init__(self, networkname, channels):
+        self.network=networkname
+        self.channels = channels
 
-	def clientConnectionLost(self, connector, reason):
-		clean = error.ConnectionDone()
-		if reason.getErrorMessage() == str(clean):
-			del connections[self.network]
-			corelogger.info("Disconnected from "+self.network)
-			if (len(connections) == 0):
-				corelogger.info("Not Connected to any network. Shutting down.")
-				schedulethread.stop() #for stopping, comment out, if you use autoreconnect
-				#TODO: add sth to stop modules
-				reactor.stop()
-		#else:
-		#	corelogger.error("Disconnected: "+str(reason.getErrorMessage())+". Trying to reconnect")
-		#	connector.connect()
-	#def clientConnectionFailed(self, connector, reason):
-	#	reactor.stop()
+    def clientConnectionLost(self, connector, reason):
+        clean = error.ConnectionDone()
+        if reason.getErrorMessage() == str(clean):
+            del connections[self.network]
+            corelogger.info("Disconnected from "+self.network)
+            if (len(connections) == 0):
+                corelogger.info("Not Connected to any network. Shutting down.")
+                schedulethread.stop() #for stopping, comment out, if you use autoreconnect
+                #TODO: add sth to stop modules
+                reactor.stop()
+        #else:
+        #    corelogger.error("Disconnected: "+str(reason.getErrorMessage())+". Trying to reconnect")
+        #    connector.connect()
+    #def clientConnectionFailed(self, connector, reason):
+    #    reactor.stop()
 
 try:
-	configfile=parser.configfile
+    configfile=parser.configfile
 except AttributeError:
-	configfile="config.xml"
+    configfile="config.xml"
 theconfig=loadConfig(configfile)
 
 # writing PID-File
@@ -480,18 +482,18 @@
 networks=theconfig.getNetworks()
 connections={}
 if networks:
-	for network in networks:
-		if(getBoolConfig('enabled', 'unset', 'main', network)):
-			channels=theconfig.getChannels(network)
-			if not channels:
-				channels=[]
-			for channel in channels:
-				if(not getBoolConfig('enabled','unset','main', network)):
-					channels.remove(channel)
-			f = BotFactory(network, channels)
-			if (getBoolConfig('ssl','False','main',network)):
-				s = ssl.ClientContextFactory()
-				connections[network]=reactor.connectSSL(unicode(network).encode("iso-8859-1"), int(getConfig('port','6697','main',network)), f,s);
-			else:
-				connections[network]=reactor.connectTCP(unicode(network).encode("iso-8859-1"), int(getConfig('port','6667','main',network)), f)
-	reactor.run()
+    for network in networks:
+        if(getBoolConfig('enabled', 'unset', 'main', network)):
+            channels=theconfig.getChannels(network)
+            if not channels:
+                channels=[]
+            for channel in channels:
+                if(not getBoolConfig('enabled','unset','main', network)):
+                    channels.remove(channel)
+            f = BotFactory(network, channels)
+            if (getBoolConfig('ssl','False','main',network)):
+                s = ssl.ClientContextFactory()
+                connections[network]=reactor.connectSSL(unicode(network).encode("iso-8859-1"), int(getConfig('port','6697','main',network)), f,s);
+            else:
+                connections[network]=reactor.connectTCP(unicode(network).encode("iso-8859-1"), int(getConfig('port','6667','main',network)), f)
+    reactor.run()




Mehr Informationen über die Mailingliste Otfbot-dev