2019-08-01 16:59:36 +00:00
|
|
|
from src import ModuleManager, utils
|
|
|
|
|
|
|
|
API = "http://acronyms.silmaril.ie/cgi-bin/xaa?%s"
|
|
|
|
|
|
|
|
class Module(ModuleManager.BaseModule):
|
|
|
|
@utils.hook("received.command.acronym")
|
|
|
|
@utils.kwarg("min_args", 1)
|
|
|
|
@utils.kwarg("help", "Find possible acronym meanings")
|
|
|
|
@utils.kwarg("usage", "<acronym>")
|
|
|
|
def acronym(self, event):
|
|
|
|
query = event["args_split"][0].upper()
|
2019-11-26 11:35:56 +00:00
|
|
|
response = utils.http.request(API % query)
|
|
|
|
|
|
|
|
acronyms = []
|
|
|
|
for element in response.soup().find_all("acro"):
|
|
|
|
acronyms.append(element.expan.string)
|
|
|
|
|
|
|
|
if acronyms:
|
2019-08-01 16:59:36 +00:00
|
|
|
event["stdout"].write("%s: %s" % (query, ", ".join(acronyms)))
|
|
|
|
else:
|
2019-11-18 12:06:59 +00:00
|
|
|
raise utils.EventResultsError()
|