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