[pybot-commits] CVS: pybot/pybot/modules pong.py,1.2,1.3 timer.py,1.2,1.3
Brought to you by:
niemeyer
From: Gustavo N. <nie...@us...> - 2002-05-09 15:55:46
|
Update of /cvsroot/pybot/pybot/pybot/modules In directory usw-pr-cvs1:/tmp/cvs-serv32404 Modified Files: pong.py timer.py Log Message: - Now pybot pings the server every minute as a keepalive (thanks Olive!). - Some fixes in timer module to load it first, and keep data softly stored in options object. This way, timer may reload safely. Index: pong.py =================================================================== RCS file: /cvsroot/pybot/pybot/pybot/modules/pong.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pong.py 4 Dec 2001 00:57:38 -0000 1.2 --- pong.py 9 May 2002 15:55:41 -0000 1.3 *************** *** 17,32 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! from pybot import hooks class Pong: def __init__(self, bot): hooks.register("Command", self.pong, 0) def unload(self): hooks.unregister("Command", self.pong, 0) def pong(self, cmd): if cmd.cmd == "PING": cmd.server.sendcmd("", "PONG", cmd.params, priority=10) def __loadmodule__(bot): --- 17,38 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! from pybot import hooks, mm, servers class Pong: def __init__(self, bot): hooks.register("Command", self.pong, 0) + mm.hooktimer(0, 60, self.ping, ()) def unload(self): hooks.unregister("Command", self.pong, 0) + mm.unhooktimer(0, 60, self.ping, ()) def pong(self, cmd): if cmd.cmd == "PING": cmd.server.sendcmd("", "PONG", cmd.params, priority=10) + + def ping(self): + for server in servers.getall(): + server.sendcmd("", "PING", server.user.nick) def __loadmodule__(bot): Index: timer.py =================================================================== RCS file: /cvsroot/pybot/pybot/pybot/modules/timer.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** timer.py 4 Dec 2001 00:57:38 -0000 1.2 --- timer.py 9 May 2002 15:55:41 -0000 1.3 *************** *** 17,21 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! from pybot import mm, hooks from time import time from thread import start_new_thread --- 17,21 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! from pybot import mm, hooks, options from time import time from thread import start_new_thread *************** *** 23,27 **** class Timer: def __init__(self, bot): ! self._timer = [] mm.register("hooktimer", self.mm_hooktimer) mm.register("unhooktimer", self.mm_unhooktimer) --- 23,27 ---- class Timer: def __init__(self, bot): ! self._timer = options.getsoft("Timer.data", []) mm.register("hooktimer", self.mm_hooktimer) mm.register("unhooktimer", self.mm_unhooktimer) *************** *** 63,66 **** --- 63,69 ---- del self._timer[i] return ret + + # Load first to let hooktimer() available to other modules. + __loadlevel__ = 90 def __loadmodule__(bot): |