From dc46744ef7f349e88b3a8771647fda15bf6b47a5 Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Fri, 27 Apr 2007 22:03:49 -0400 Subject: [PATCH] Started on modules --- scrappy.py | 57 ++++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/scrappy.py b/scrappy.py index ba07ebc..c020d29 100755 --- a/scrappy.py +++ b/scrappy.py @@ -22,6 +22,13 @@ class scrappy: self.chanlist = [] self.irc = '' #this will be the socket self.c = '' #Thomas, explain this to me later + + #Experimental stuff for dynamic modules + self.modulelist = [] + #self.privmsg_events = [] + #self.pubmsg_events = [] + #self.what_other_events? = [] + self.main() def parseArgv(self): @@ -61,7 +68,14 @@ class scrappy: self.c.add_global_handler("privmsg", self.on_privmsg) self.c.add_global_handler("pubmsg", self.on_pubmsg) + #register some phony modules for testing + self.register_module("My phony module", 'foo', 'foo') + self.register_module("Another phony module", 'foo', 'foo') + self.list_modules() + + #nothng after this executes self.irc.process_forever() + ################ #Event Handlers# @@ -85,43 +99,20 @@ class scrappy: def on_disconnect(self, c, event): sys.exit(0) + + ################ + #Module Loading# + ################ + def register_module(self, name, eventlist, function): + self.modulelist.append(name) + def list_modules(self): + """List currently loaded modules.""" + for mod in self.modulelist: + print mod if(__name__ == "__main__"): bot = scrappy() -#if(__name__ == "__main__"): - -# if len(sys.argv) < 4: -# print "Usage: " + sys.argv[0] + " [channel2 channel3 ... channelN]" -# sys.exit(1) - -# s = sys.argv[1].split(":", 1) -# server = s[0] -# if len(s) == 2: -# try: -# port = int(s[1]) -# except ValueError: -# print "Error: Erroneous port." -# sys.exit(1) -# else: -# port = 6667 - -# nickname = sys.argv[2] - -# irc = irclib_scrappy.IRC() - -# try: -# c = irc.server().connect(server, port, nickname) -# except irclib.ServerConnectionError, x: -# print x -# sys.exit(1) -# c.add_global_handler("welcome", on_connect) -# c.add_global_handler("disconnect", on_disconnect) -# c.add_global_handler("privmsg", on_privmsg) -# c.add_global_handler("pubmsg", on_pubmsg) -# -# irc.process_forever() -# -- 2.11.4.GIT