From: Chang <pe...@us...> - 2001-10-31 17:33:28
|
perky 01/10/31 09:33:26 Modified: lib core.py plugin.py Log: Adding CronHandler, MailingList Digest Plugin. Revision Changes Path 1.2 +14 -2 SugarCube/lib/core.py Index: core.py =================================================================== RCS file: /cvsroot/sugarcube/SugarCube/lib/core.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- core.py 2001/10/30 07:57:10 1.1 +++ core.py 2001/10/31 17:33:26 1.2 @@ -2,12 +2,12 @@ # # this framework was based on joel rosdahl's # -# $Id: core.py,v 1.1 2001/10/30 07:57:10 perky Exp $ +# $Id: core.py,v 1.2 2001/10/31 17:33:26 perky Exp $ # import sys import string -from UserDict import UserDict +from time import time from irclib import IRC from irclib import nm_to_n, irc_lower, all_events @@ -69,7 +69,19 @@ def start(self): self.connect() + tmev_run = int(time()) + 1 while self.goahead: + while tmev_run < time(): + for hdl in handler['minutes']: + try: + hdl(self.connection, tmev_run) + except excepts.StopProcessing: + break + except: + import traceback, sys + traceback.print_exc(file=sys.stdout) + tmev_run += 60 # XXX: this can causes time skew disaster + # on unusual async state when not scheduled once over 1 min. self.ircobj.process_once(10) def _connected_checker(self): 1.2 +4 -2 SugarCube/lib/plugin.py Index: plugin.py =================================================================== RCS file: /cvsroot/sugarcube/SugarCube/lib/plugin.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- plugin.py 2001/10/30 07:57:10 1.1 +++ plugin.py 2001/10/31 17:33:26 1.2 @@ -1,11 +1,13 @@ # ex:ts=4 -# $Id: plugin.py,v 1.1 2001/10/30 07:57:10 perky Exp $ +# $Id: plugin.py,v 1.2 2001/10/31 17:33:26 perky Exp $ import os, os.path import glob from globals import conf, handler, plugins from irclib import generated_events, protocol_events +cube_events = ['minutes'] + def init(): load_plugins() @@ -13,7 +15,7 @@ print "Loading Modules...", plugins.clear() handler.clear() - for hdlname in generated_events + protocol_events: + for hdlname in generated_events + protocol_events + cube_events: handler[hdlname] = [] for hdl in glob.glob("plugins/*/handler.py"): hdlname = hdl.split(os.sep)[1] |