Rework hook managment and add some tests

This commit is contained in:
nemunaire 2015-11-16 07:19:09 +01:00
commit 43c42e1397
8 changed files with 222 additions and 78 deletions

View file

@ -242,7 +242,7 @@ def cmd_unalias(msg):
## Alias replacement
@hook.add("pre_Command")
@hook.add(["pre","Command"])
def treat_alias(msg):
if msg.cmd in context.data.getNode("aliases").index:
txt = context.data.getNode("aliases").index[msg.cmd]["origin"]

View file

@ -28,12 +28,14 @@ def load(CONF, add_hook):
URL_WHOIS = URL_WHOIS % (urllib.parse.quote(CONF.getNode("whoisxmlapi")["username"]), urllib.parse.quote(CONF.getNode("whoisxmlapi")["password"]))
import nemubot.hooks
add_hook("in_Command", nemubot.hooks.Command(cmd_whois, "netwhois",
help="Get whois information about given domains",
help_usage={"DOMAIN": "Return whois information on the given DOMAIN"}))
add_hook("in_Command", nemubot.hooks.Command(cmd_avail, "domain_available",
help="Domain availability check using whoisxmlapi.com",
help_usage={"DOMAIN": "Check if the given DOMAIN is available or not"}))
add_hook(nemubot.hooks.Command(cmd_whois, "netwhois",
help="Get whois information about given domains",
help_usage={"DOMAIN": "Return whois information on the given DOMAIN"}),
"in","Command")
add_hook(nemubot.hooks.Command(cmd_avail, "domain_available",
help="Domain availability check using whoisxmlapi.com",
help_usage={"DOMAIN": "Check if the given DOMAIN is available or not"}),
"in","Command")
# MODULE CORE #########################################################

View file

@ -30,8 +30,8 @@ def load(context):
context.data.getNode("pics").setIndex("login", "pict")
import nemubot.hooks
context.add_hook("in_Command",
nemubot.hooks.Command(cmd_whois, "whois"))
context.add_hook(nemubot.hooks.Command(cmd_whois, "whois"),
"in","Command")
class Login: