Rework hook managment and add some tests
This commit is contained in:
parent
926648517f
commit
43c42e1397
8 changed files with 222 additions and 78 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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 #########################################################
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue