New global function: add_hook: add a hook in the current context directly associated to the current module
This commit is contained in:
parent
1b5b5af60b
commit
bbfd34fe7b
@ -151,6 +151,7 @@ class ModuleLoader(SourceLoader):
|
||||
module.print = lambda msg: print("[%s] %s"%(module.name, msg))
|
||||
module.print_debug = lambda msg: mod_print_dbg(module, msg)
|
||||
module.send_response = lambda srv, res: mod_send_response(self.context, srv, res)
|
||||
module.add_hook = lambda store, hook: self.context.hooks.add_hook(store, hook, module)
|
||||
|
||||
if not hasattr(module, "NODATA"):
|
||||
module.DATAS = xmlparser.parse_file(self.context.datas_path
|
||||
|
@ -14,8 +14,8 @@ def load(context):
|
||||
CONTEXT = context
|
||||
|
||||
from hooks import Hook
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_set, "set"))
|
||||
context.hooks.add_hook("all_pre", Hook(treat_variables))
|
||||
add_hook("cmd_hook", Hook(cmd_set, "set"))
|
||||
add_hook("all_pre", Hook(treat_variables))
|
||||
|
||||
global DATAS
|
||||
if not DATAS.hasNode("aliases"):
|
||||
|
@ -13,23 +13,23 @@ def load(context):
|
||||
WFASearch.CONF = CONF
|
||||
|
||||
from hooks import Hook
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "d"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "def"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "defini"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "definit"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "define"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(define, "definition"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(search, "search"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(search, "ddg"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(search, "g"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(calculate, "wa"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(calculate, "wfa"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(calculate, "calc"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(wiki, "w"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(wiki, "wf"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(wiki, "wfr"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(wiki, "we"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(wiki, "wen"))
|
||||
add_hook("cmd_hook", Hook(define, "d"))
|
||||
add_hook("cmd_hook", Hook(define, "def"))
|
||||
add_hook("cmd_hook", Hook(define, "defini"))
|
||||
add_hook("cmd_hook", Hook(define, "definit"))
|
||||
add_hook("cmd_hook", Hook(define, "define"))
|
||||
add_hook("cmd_hook", Hook(define, "definition"))
|
||||
add_hook("cmd_hook", Hook(search, "search"))
|
||||
add_hook("cmd_hook", Hook(search, "ddg"))
|
||||
add_hook("cmd_hook", Hook(search, "g"))
|
||||
add_hook("cmd_hook", Hook(calculate, "wa"))
|
||||
add_hook("cmd_hook", Hook(calculate, "wfa"))
|
||||
add_hook("cmd_hook", Hook(calculate, "calc"))
|
||||
add_hook("cmd_hook", Hook(wiki, "w"))
|
||||
add_hook("cmd_hook", Hook(wiki, "wf"))
|
||||
add_hook("cmd_hook", Hook(wiki, "wfr"))
|
||||
add_hook("cmd_hook", Hook(wiki, "we"))
|
||||
add_hook("cmd_hook", Hook(wiki, "wen"))
|
||||
|
||||
def reload():
|
||||
imp.reload(DDGSearch)
|
||||
|
@ -16,8 +16,8 @@ def help_full ():
|
||||
|
||||
def load(context):
|
||||
from hooks import Hook
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_sleep, "sleeptime"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_sleep, "sleepytime"))
|
||||
add_hook("cmd_hook", Hook(cmd_sleep, "sleeptime"))
|
||||
add_hook("cmd_hook", Hook(cmd_sleep, "sleepytime"))
|
||||
|
||||
|
||||
def cmd_sleep(msg):
|
||||
|
@ -15,8 +15,8 @@ def help_full ():
|
||||
|
||||
def load(context):
|
||||
from hooks import Hook
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_syno, "syno"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_syno, "synonyme"))
|
||||
add_hook("cmd_hook", Hook(cmd_syno, "syno"))
|
||||
add_hook("cmd_hook", Hook(cmd_syno, "synonyme"))
|
||||
|
||||
|
||||
def cmd_syno(msg):
|
||||
|
@ -15,10 +15,10 @@ LANG = ["ar", "zh", "cz", "en", "fr", "gr", "it",
|
||||
|
||||
def load(context):
|
||||
from hooks import Hook
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_translate, "translate"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_translate, "traduction"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_translate, "traduit"))
|
||||
context.hooks.add_hook("cmd_hook", Hook(cmd_translate, "traduire"))
|
||||
add_hook("cmd_hook", Hook(cmd_translate, "translate"))
|
||||
add_hook("cmd_hook", Hook(cmd_translate, "traduction"))
|
||||
add_hook("cmd_hook", Hook(cmd_translate, "traduit"))
|
||||
add_hook("cmd_hook", Hook(cmd_translate, "traduire"))
|
||||
|
||||
|
||||
def cmd_translate(msg):
|
||||
|
Loading…
Reference in New Issue
Block a user