Change bitly.py to use delimited events
This commit is contained in:
parent
fc8e3818fe
commit
908d64f5c6
1 changed files with 5 additions and 6 deletions
|
@ -10,10 +10,9 @@ class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.events = events
|
self.events = events
|
||||||
events.on("get").on("shortlink").hook(self.shortlink)
|
events.on("get.shortlink").hook(self.shortlink)
|
||||||
events.on("received").on("command").on("shorten"
|
events.on("received.command.shorten").hook(self.shorten, min_args=1,
|
||||||
).hook(self.shorten, min_args=1, help="Shorten a URL.",
|
help="Shorten a URL.", usage="<url>")
|
||||||
usage="<url>")
|
|
||||||
|
|
||||||
def shortlink(self, event):
|
def shortlink(self, event):
|
||||||
url = event["url"]
|
url = event["url"]
|
||||||
|
@ -26,8 +25,8 @@ class Module(object):
|
||||||
return data["data"]["url"]
|
return data["data"]["url"]
|
||||||
|
|
||||||
def shorten(self, event):
|
def shorten(self, event):
|
||||||
link = self.events.on("get").on("shortlink"
|
link = self.events.on("get.shortlink").call_for_result(
|
||||||
).call_for_result(url=event["args"])
|
url=event["args"])
|
||||||
if link:
|
if link:
|
||||||
event["stdout"].write("Short URL: %s" % link)
|
event["stdout"].write("Short URL: %s" % link)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue