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

allo at BerliOS allo
Di Jun 12 14:13:08 CEST 2007


Author: allo
Date: 2007-06-12 14:13:07 +0200 (Tue, 12 Jun 2007)
New Revision: 109

Added:
   trunk/scheduler.py
Modified:
   trunk/modules/kiMod.py
   trunk/modules/reminderMod.py
   trunk/otfbot.py
Log:
scheduler in seperate file + fix for errormsg on wrong timeformat


Modified: trunk/modules/kiMod.py
===================================================================
--- trunk/modules/kiMod.py	2007-06-12 10:41:35 UTC (rev 108)
+++ trunk/modules/kiMod.py	2007-06-12 12:13:07 UTC (rev 109)
@@ -263,7 +263,7 @@
 			self.responder.learn(msg)
 		if reply!="":
 			#reply=re.sub(" "+self.bot.nickname, " "+user, reply) #more secure to match only the name
-			reply=re.sub(self.bot.nickname, user, reply, re.I) 
+			reply=re.sub(self.lnickname, user, reply, re.I) 
 			for key in self.wordpairs.keys():
 				reply=re.sub(key, self.wordpairs[key], reply, re.I)
 			

Modified: trunk/modules/reminderMod.py
===================================================================
--- trunk/modules/reminderMod.py	2007-06-12 10:41:35 UTC (rev 108)
+++ trunk/modules/reminderMod.py	2007-06-12 12:13:07 UTC (rev 109)
@@ -50,7 +50,7 @@
 			try:
 				wait=int(tmp[1])
 			except ValueError:
-				self.bot.sendmsg(channel, user.split("!")[0]+": invalid number format \""+msg[1]+"\".")
+				self.bot.sendmsg(channel, user.split("!")[0]+": invalid number format \""+tmp[1]+"\".")
 				return
 			text=str(tmp[2])
 			

Modified: trunk/otfbot.py
===================================================================
--- trunk/otfbot.py	2007-06-12 10:41:35 UTC (rev 108)
+++ trunk/otfbot.py	2007-06-12 12:13:07 UTC (rev 109)
@@ -24,8 +24,8 @@
 from twisted.words.protocols import irc
 
 from twisted.internet import reactor, protocol, error, ssl
-import os, random, string, re, threading, time, sys, traceback, threading, atexit
-import functions, config
+import os, random, string, re, sys, traceback, atexit
+import functions, config, scheduler
 
 modchars={'a':'!','o':'@','h':'%','v':'+'}
 modcharvals={'!':4,'@':3,'%':2,'+':1,' ':0}
@@ -175,36 +175,7 @@
 	file.write(theconfig.exportxml())
 	file.close()
 
-class Schedule(threading.Thread):
-	def __init__(self):
-		threading.Thread.__init__(self)
-		self.times=[]
-		self.functions=[]
-		self.stopme=False
-
-	def stop(self):
-		self.stopme=True
-
-	def run(self):
-		while not self.stopme:
-			time.sleep(60)
-			toremove=[]
-			for i in range(len(self.times)):
-				self.times[i]=self.times[i]-1
-				if self.times[i]<=0:
-					self.functions[i]()
-					toremove.append(i)
-			toremove.reverse()
-			for i in toremove:
-				del self.times[i]
-				del self.functions[i]
-
-
-	def addScheduleJob(self, wait, function):
-		self.times.append( int(wait) )
-		self.functions.append(function)
-
-schedulethread=Schedule()
+schedulethread=scheduler.Schedule()
 schedulethread.start()
 
 def addScheduleJob(time, function):

Added: trunk/scheduler.py
===================================================================
--- trunk/scheduler.py	2007-06-12 10:41:35 UTC (rev 108)
+++ trunk/scheduler.py	2007-06-12 12:13:07 UTC (rev 109)
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+#
+# 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, 2007 by Alexander Schier
+
+import threading, time
+class Schedule(threading.Thread):
+	def __init__(self):
+		threading.Thread.__init__(self)
+		self.times=[]
+		self.functions=[]
+		self.stopme=False
+
+	def stop(self):
+		self.stopme=True
+
+	def run(self):
+		while not self.stopme:
+			time.sleep(60)
+			toremove=[]
+			for i in range(len(self.times)):
+				self.times[i]=self.times[i]-1
+				if self.times[i]<=0:
+					self.functions[i]()
+					toremove.append(i)
+			toremove.reverse()
+			for i in toremove:
+				del self.times[i]
+				del self.functions[i]
+
+
+	def addScheduleJob(self, wait, function):
+		self.times.append( int(wait) )
+		self.functions.append(function)




Mehr Informationen über die Mailingliste Otfbot-dev