X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/0c33848ce27a8ba3d3b2b23528c2c47279d085ae..c0601d1e22c5c3749ea94c1c4359f9223b732fe4:/src/modpython.py diff --git a/src/modpython.py b/src/modpython.py index c0fc06c..1f7c83c 100644 --- a/src/modpython.py +++ b/src/modpython.py @@ -11,7 +11,8 @@ # - provide helper functions for scripts to do common things like msg a person or a channel, # reply, etc. -import svc +import _svc +import plugins import math @@ -33,7 +34,7 @@ class irc: self.target = target #the channel message was in (if public) def send_target_privmsg(self, source, target, message): - svc.send_target_privmsg(source, target, "%s "%(message)) + _svc.send_target_privmsg(source, target, "%s "%(message)) def reply(self, message): """ Send a private reply to the user using convenience values""" @@ -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, @@ -60,11 +62,36 @@ class handler: return 0 def join(self, irc, channel, nick): - user = svc.get_user(nick) + #user = _svc.get_user(nick) #print "DEBUG: handler.join()" - self.plugins.callhandler("join", irc, [channel, nick], [channel, nick]) + return self.plugins.callhandler("join", irc, [channel, nick], [channel, nick]) + + def server_link(self, server): + for plugin in self.newplugins: + if plugin.server_link(server): + return 1 return 0 - + + 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 cmd_run(self, irc, cmd): #print "DEBUG: handler.cmd_run: %s"%cmd eval(cmd) @@ -79,13 +106,12 @@ class handler: def cmd_command(self, irc, plugin, cmd, args): #print "DEBUG: handel.cmd_command; %s %s; args= %s"%(plugin, cmd, args) - self.plugins.callhandler("command", irc, [plugin, cmd], [args]) - return 0 + return self.plugins.callhandler("command", irc, [plugin, cmd], [args]) def load(self, irc, plugin): return self.plugins.load(plugin) -class plugins: +class plugins_: """Class to handle loading/unloading of plugins""" loaded_plugins = {} hooks = [] @@ -143,14 +169,16 @@ class plugins: def callhandler(self, event, irc, filter, args): for hook in self.findhooksforevent(event, filter): - hook.trigger(irc, args) + if(hook.trigger(irc, args)): + return 1 + return 0 def load(self, name): """ Loads a plugin by name """ 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):