]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/modpython.py
Minor typo in previous commit where returning 0 when it should have been 1 from opser...
[irc/evilnet/x3.git] / src / modpython.py
index 892322de8f1c12ad023c654d91aa02967be6458b..1f7c83c97606e2004651ab08fa4a69e68803eb5c 100644 (file)
@@ -12,6 +12,7 @@
 #   reply, etc.
 
 import _svc
+import plugins
 
 import math
 
@@ -48,9 +49,10 @@ class handler:
 
     def __init__(self):
         #print "DEBUG: constructor for handler initing"
-        self.plugins = plugins(self)
+        self.plugins = plugins_(self)
         if(not self.plugins):
             print "DEBUG: unable to make self.plugins!?!"
+        self.newplugins = plugins.load()
 
     def init(self, irc): # not to be confused with __init__!
         """ This gets called once all the objects are up and running. Otherwise,
@@ -64,17 +66,32 @@ class handler:
         #print "DEBUG: handler.join()"
         return self.plugins.callhandler("join", irc, [channel, nick], [channel, nick])
 
-    def server_link(self, irc, name, desc):
-        return self.plugins.callhandler("server_link", irc, [name, desc], [name, desc])
+    def server_link(self, server):
+        for plugin in self.newplugins:
+            if plugin.server_link(server):
+                return 1
+        return 0
 
-    def new_user(self, irc, nick, ident, hostname, info):
-        # we may filter on all the user fields, but we only pass the nick because
-        # the plugin can get the rest itself
-        return self.plugins.callhandler("new_user", irc, [nick, ident, hostname, info], [nick])
+    def new_user(self, user):
+        for plugin in self.newplugins:
+            if plugin.new_user(user):
+                return 1
+        return 0
+
+    def nick_change(self, user, oldnick):
+        for plugin in self.newplugins:
+            plugin.nick_change(user, oldnick)
+
+    def del_user(self, user, killer, why):
+        for plugin in self.newplugins:
+            plugin.del_user(user, killer, why)
+
+    def topic(self, who, chan, old_topic):
+        for plugin in self.newplugins:
+            if plugin.topic(who, chan, old_topic):
+                return 1
+        return 0
 
-    def nick_change(self, irc, nick, old_nick):
-        return self.plugins.callhandler("nick_change", irc, [nick, old_nick], [nick, old_nick])
-        
     def cmd_run(self, irc, cmd):
         #print "DEBUG: handler.cmd_run: %s"%cmd
         eval(cmd)
@@ -94,7 +111,7 @@ class handler:
     def load(self, irc, plugin):
         return self.plugins.load(plugin)
 
-class plugins:
+class plugins_:
     """Class to handle loading/unloading of plugins"""
     loaded_plugins = {}
     hooks = []
@@ -161,7 +178,7 @@ class plugins:
         mod_name = "plugins.%s"%name
         need_reload = False
         if(sys.modules.has_key(mod_name)):
-            need_reload = true
+            need_reload = True
         #TODO: try to catch compile errors etc.
 
         if(need_reload == False):