[Otfbot-svn] r114 - trunk/modules

allo at BerliOS allo
Sa Jun 23 15:56:58 CEST 2007


Author: allo
Date: 2007-06-23 15:56:58 +0200 (Sat, 23 Jun 2007)
New Revision: 114

Modified:
   trunk/modules/rdfMod.py
Log:
rdfMod with callLater


Modified: trunk/modules/rdfMod.py
===================================================================
--- trunk/modules/rdfMod.py	2007-06-23 12:01:27 UTC (rev 113)
+++ trunk/modules/rdfMod.py	2007-06-23 13:56:58 UTC (rev 114)
@@ -25,39 +25,33 @@
 	settings={};
 	settings['rdfMod.wait']='5' #XXX: works only global at the moment
 	settings['rdfMod.numRdfs']='0'
-	settings['rdfMod.rdf1']='http://localhost/example.rss'
+	settings['rdfMod.rdf1']='http://you/need/to/set/this/in/a/channel/not/global/example.rss'
 	return settings
 		
-class chatMod(threading.Thread):
+class chatMod(chatMod.chatMod):
 	def __init__(self, bot):
-		threading.Thread.__init__(self)
 
 		self.end = 0
 		self.read = {}
 		self.bot = bot
-		self.channel = ""
 		self.logger = self.bot.logging.getLogger("rdfMod")
 		
 		self.wait=60 * float(bot.getConfig("wait", "5", "rdfMod"))
 		self.rdfUrls=[]
 		self.rdfChannels={}
+		self.bot.getReactor().callLater(10, self.run)
+		self.sleeped=0
 
 				
 	def run(self):
-		self.setName("identify")
-		while(not self.end):
+		if self.sleeped>=self.wait:
+			for rdfUrl in self.rdfUrls:
+				self.postNews(rdfUrl)
+				self.sleeped=0
+		if not self.end:
 			#splits the waittime, to support stop()
-			#can be at end, too
-			i=0
-			while(not self.end and i<self.wait):
-				time.sleep(10)
-				i+=10
-				
-			if not self.end:
-				for rdfUrl in self.rdfUrls:
-					self.postNews(rdfUrl)
-		# logging would be done after logging-subsys is closed
-		#self.logger.info("rdfMod: successfully stopped.")
+			self.sleeped+=10
+			self.bot.getReactor().callLater(10, self.run)
 
 	def postNews(self, rdfUrl):
 		unread =[]
@@ -78,10 +72,6 @@
 		unread = []#mark all as read
 		i = 0
 
-	def joined(self, channel):
-		if self.channel == "" and self.bot.getConfig("enabled","False","rdfMod",self.bot.network,channel): #only the first channel
-			self.channel = channel
-
 	def connectionLost(self, reason):
 		self.stop()
 
@@ -89,17 +79,6 @@
 		self.logger.info("Got Stop Signal.")
 		self.end=1
 
-	def setLogger(self,logger):
-		self.logger = logger
-	def auth(self, user):
-		"""check the authorisation of the user"""
-		pass
-	def privmsg(self, user, channel, msg):
-		"""a private message received"""
-		pass
-	def msg(self, user, channel, msg):
-		"""message received"""
-		pass
 	def connectionMade(self):
 		"""made connection to server"""
 		bot=self.bot
@@ -132,48 +111,3 @@
 			for key in rdf['links']:
 				if not self.read[rdfUrl].has_key(key):#sort unread
 					self.read[rdfUrl][key] = 1 #but read for all later jobs
-
-	def signedOn(self):
-		"""successfully signed on"""
-		pass
-	def left(self, channel):
-		"""we have left a channel"""
-		pass
-	def noticed(self, user, channel, msg):
-		"""we got a notice"""
-		pass
-	def action(self, user, channel, message):
-		"""action (/me) received"""
-		pass
-	def modeChanged(self, user, channel, set, modes, args):
-		"""mode changed"""
-		pass
-	def userKicked(self, kickee, channel, kicker, message):
-		"""someone kicked someone else"""
-		pass
-	def userJoined(self, user, channel):
-		"""a user joined the channel"""
-		pass
-	def userJoinedMask(self, user, channel):
-		pass
-	def userLeft(self, user, channel):
-		"""a user left the channel"""
-		pass
-	def userQuit(self, user, quitMessage):
-		"""a user disconnect from the network"""
-		pass
-	def yourHost(self, info):
-		"""info about your host"""
-		pass
-	def userRenamed(self, oldname, newname):
-		"""a user changed the nick"""
-		pass
-	def topicUpdated(self, user, channel, newTopic):
-		"""a user changed the topic of a channel"""
-		pass
-	def irc_unknown(self, prefix, command, params):
-		"""an IRC-Message, which is not handle by twisted was received"""
-		pass
-	def reload(self):
-		"""called to reload the settings of the module"""
-		pass




Mehr Informationen über die Mailingliste Otfbot-dev