diff options
| author | 2019-02-07 10:07:11 +0000 | |
|---|---|---|
| committer | 2019-02-07 10:07:11 +0000 | |
| commit | 90591ec5b4e010b14428c9eef33f1f1a5aa9a262 (patch) | |
| tree | 63e24131525778c5e790a65a70aa67d4e0db27a6 /modules | |
| parent | Implement `Exports.get_one()` (diff) | |
| signature | ||
Change isgd.py to use Exports to offer url shortening, not events
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/isgd.py | 10 | ||||
| -rw-r--r-- | modules/tweets.py | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/modules/isgd.py b/modules/isgd.py index 470c0dda..7674439c 100644 --- a/modules/isgd.py +++ b/modules/isgd.py @@ -5,9 +5,10 @@ ISGD_API_URL = "https://is.gd/create.php" REGEX_URL = re.compile("https?://", re.I) class Module(ModuleManager.BaseModule): - @utils.hook("get.shortlink") - def shortlink(self, event): - url = event["url"] + def on_load(self): + self.exports.add("shortlink", self._shortlink) + + def _shortlink(self, url): if not re.match(REGEX_URL, url): url = "http://%s" % url @@ -23,8 +24,7 @@ class Module(ModuleManager.BaseModule): :help: Shorten a given URL using the is.gd service :usage: <url> """ - link = self.events.on("get.shortlink").call_for_result( - url=event["args"]) + link = self._shortlink(event["args"]) if link: event["stdout"].write("Shortened URL: %s" % link) else: diff --git a/modules/tweets.py b/modules/tweets.py index 73091171..55cf28e4 100644 --- a/modules/tweets.py +++ b/modules/tweets.py @@ -64,8 +64,7 @@ class Module(ModuleManager.BaseModule): tweet_link = "https://twitter.com/%s/status/%s" % (username, linked_id) - short_url = self.events.on("get.shortlink").call_for_result( - url=tweet_link) + short_url = self.exports.get_one("shortlink")(tweet_link) short_url = " - %s" % short_url if short_url else "" if "retweeted_status" in tweet: |
