diff options
| author | 2018-09-26 18:27:17 +0100 | |
|---|---|---|
| committer | 2018-09-26 18:27:17 +0100 | |
| commit | 51a52e2b0e54031cce5876f54d1d48c268b5441c (patch) | |
| tree | a4c0e8e86c55aa701b06297d5b5a2ceebeaab60d /modules/isgd.py | |
| parent | Also use docstrings to check if a command has help available, allow one-string (diff) | |
Switch to using @Utils.hook and docstrings for event hooks
Diffstat (limited to 'modules/isgd.py')
| -rw-r--r-- | modules/isgd.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/isgd.py b/modules/isgd.py index 3ceacaff..6128ceb0 100644 --- a/modules/isgd.py +++ b/modules/isgd.py @@ -6,12 +6,9 @@ REGEX_URL = re.compile("https?://", re.I) class Module(object): def __init__(self, bot, events, exports): - self.bot = bot self.events = events - events.on("get.shortlink").hook(self.shortlink) - events.on("received.command.shorten").hook(self.shorten, min_args=1, - help="Shorten a URL using the is.gd service.", usage="<url>") + @Utils.hook("get.shortlink") def shortlink(self, event): url = event["url"] if not re.match(REGEX_URL, url): @@ -24,7 +21,11 @@ class Module(object): if data and data["shorturl"]: return data["shorturl"] + @Utils.hook("received.command.shorten", min_args=1, usage="<url>") def shorten(self, event): + """ + Shorten a given URL using the is.gd service + """ link = self.events.on("get.shortlink").call_for_result( url=event["args"]) if link: |
