Support denoting command response [prefix] in docstring
This commit is contained in:
parent
ded6ff03ce
commit
b778ad2902
2 changed files with 7 additions and 8 deletions
|
@ -124,8 +124,8 @@ class Module(ModuleManager.BaseModule):
|
|||
if is_channel and hook.kwargs.get("private_only"):
|
||||
return
|
||||
|
||||
module_name = ""
|
||||
if hasattr(hook.function, "__self__"):
|
||||
module_name = self._get_prefix(hook) or ""
|
||||
if not module_name and hasattr(hook.function, "__self__"):
|
||||
module_name = hook.function.__self__._name
|
||||
|
||||
msgid = event["tags"].get("draft/msgid", None)
|
||||
|
@ -195,6 +195,8 @@ class Module(ModuleManager.BaseModule):
|
|||
return hook.get_kwarg("help", None) or hook.docstring.description
|
||||
def _get_usage(self, hook):
|
||||
return hook.get_kwarg("usage", None)
|
||||
def _get_prefix(self, hook):
|
||||
return hook.get_kwarg("prefix", None)
|
||||
|
||||
@utils.hook("received.command.help")
|
||||
def help(self, event):
|
||||
|
|
|
@ -9,9 +9,8 @@ class Module(ModuleManager.BaseModule):
|
|||
"""
|
||||
:help: Get all addresses for a given hostname (IPv4/IPv6)
|
||||
:usage: <hostname>
|
||||
:prefix: DNS
|
||||
"""
|
||||
event["stdout"].set_prefix("DNS")
|
||||
event["stderr"].set_prefix("DNS")
|
||||
hostname = event["args_split"][0]
|
||||
try:
|
||||
address_info = socket.getaddrinfo(hostname, 1, 0,
|
||||
|
@ -30,11 +29,10 @@ class Module(ModuleManager.BaseModule):
|
|||
"""
|
||||
:help: Get geoip data on a given IPv4/IPv6 address
|
||||
:usage: <IP>
|
||||
:prefix: GeoIP
|
||||
"""
|
||||
page = utils.http.get_url(URL_GEOIP % event["args_split"][0],
|
||||
json=True)
|
||||
event["stdout"].set_prefix("GeoIP")
|
||||
event["stderr"].set_prefix("GeoIP")
|
||||
if page:
|
||||
if page["status"] == "success":
|
||||
data = page["query"]
|
||||
|
@ -57,9 +55,8 @@ class Module(ModuleManager.BaseModule):
|
|||
"""
|
||||
:help: Do a reverse-DNS look up on an IPv4/IPv6 address
|
||||
:usage: <IP>
|
||||
:prefix: rDNS
|
||||
"""
|
||||
event["stdout"].set_prefix("rDNS")
|
||||
event["stderr"].set_prefix("rDNS")
|
||||
try:
|
||||
hostname, alias, ips = socket.gethostbyaddr(event["args_split"][0])
|
||||
except (socket.herror, socket.gaierror) as e:
|
||||
|
|
Loading…
Reference in a new issue