aboutsummaryrefslogtreecommitdiff
path: root/modules/bitly.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-08-31 12:55:52 +0100
committerGravatar jesopo2018-08-31 12:55:52 +0100
commit9874f79b498e1f8ae5ebec9a240963e908b645b0 (patch)
treed5d887ac82f3e50f0ea295953981363c1c5e7c5a /modules/bitly.py
parentMerge pull request #7 from dngfx/master (diff)
signature
Give modules event objects with "context"s, to facilitate purging all the event
hooks for a module
Diffstat (limited to 'modules/bitly.py')
-rw-r--r--modules/bitly.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/bitly.py b/modules/bitly.py
index f31ca347..05489fb0 100644
--- a/modules/bitly.py
+++ b/modules/bitly.py
@@ -7,10 +7,11 @@ URL_BITLYSHORTEN = "https://api-ssl.bitly.com/v3/shorten"
REGEX_URL = re.compile("https?://", re.I)
class Module(object):
- def __init__(self, bot):
+ def __init__(self, bot, events):
self.bot = bot
- bot.events.on("get").on("shortlink").hook(self.shortlink)
- bot.events.on("received").on("command").on("shorten"
+ self.events = events
+ events.on("get").on("shortlink").hook(self.shortlink)
+ events.on("received").on("command").on("shorten"
).hook(self.shorten, min_args=1, help="Shorten a URL.",
usage="<url>")
@@ -25,7 +26,7 @@ class Module(object):
return data["data"]["url"]
def shorten(self, event):
- link = self.bot.events.on("get").on("shortlink"
+ link = self.events.on("get").on("shortlink"
).call_for_result(url=event["args"])
if link:
event["stdout"].write("Short URL: %s" % link)