From 9347a3c1d6182b51f58b8b880826f7e9fea382dc Mon Sep 17 00:00:00 2001 From: Thomas Coppi Date: Sat, 28 Apr 2007 13:34:33 -0600 Subject: [PATCH] Add rudimentary support for loading modules. --- modules/config.py | 3 +++ scrappy.py | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/config.py b/modules/config.py index a4c16d0..26bd1ec 100644 --- a/modules/config.py +++ b/modules/config.py @@ -2,3 +2,6 @@ import sys +def __init__(scrap): + scrap.configing = True + diff --git a/scrappy.py b/scrappy.py index 58120c2..ca20c06 100755 --- a/scrappy.py +++ b/scrappy.py @@ -30,7 +30,10 @@ class scrappy: self.chanlist = [] self.irc = '' #this will be the socket self.c = '' #Thomas, explain this to me later - + + #testvar, should be gotten rid of + self.configing = False + #Experimental stuff for dynamic modules self.modulelist = [] self.privmsg_events = [] @@ -74,6 +77,7 @@ class scrappy: def main(self): self.parse_argv() self.irc = irclib_scrappy.IRC() + try: self.c = self.irc.server().connect(self.server, self.port, self.nickname, @@ -81,6 +85,7 @@ class scrappy: except irclib_scrappy.ServerConnectionError, x: print x sys.exit(1) + #if all goes well, register handlers self.c.add_global_handler("welcome", self.on_connect) self.c.add_global_handler("disconnect", self.on_disconnect) @@ -90,11 +95,12 @@ class scrappy: #register some phony modules for testing self.register_module("My phony module", 'foo', 'foo') self.register_module("Another phony module", 'foo', 'foo') - + + #register some events self.pubmsg_events.append(externfunc) - self.pubmsg_events.append(deadline) self.privmsg_events.append(deadline) + self.pubmsg_events.append(deadline) self.privmsg_events.append(self.modload_cmd) self.pubmsg_events.append(self.modload_cmd) @@ -169,6 +175,14 @@ class scrappy: def modload_cmd(self,c,list): debug("DO STUFF") + (cmd,param) = list[4].split(" ") + + debug(list[4] + "\n") + + if cmd == "modload" and list[3]: + module = __import__("modules/%s" % param) + module.__init__(self) + def modlist_cmd(self,c,list): if list[4] == "modlist" and list[3]: c.privmsg(list[0],self.modulelist) -- 2.11.4.GIT