diff options
| author | 2019-05-18 19:20:09 +0100 | |
|---|---|---|
| committer | 2019-05-18 19:20:09 +0100 | |
| commit | 6f0b31cb9a516b1411ea7e0e592661dea22ca5f0 (patch) | |
| tree | 30d317ceea44395fd1ff815c696217df2e7762b5 /modules/imgur.py | |
| parent | Add a timestamp to recent_sends for EACH line sent (diff) | |
| signature | ||
Switch imgur.py to use command.regex system
Diffstat (limited to 'modules/imgur.py')
| -rw-r--r-- | modules/imgur.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/modules/imgur.py b/modules/imgur.py index 9804c96f..feefcb92 100644 --- a/modules/imgur.py +++ b/modules/imgur.py @@ -26,24 +26,22 @@ class Module(ModuleManager.BaseModule): text += "%s " % data["account_url"] return text - @utils.hook("received.message.channel", priority=EventManager.PRIORITY_LOW) - def channel_message(self, event): + @utils.hook("command.regex", pattern=REGEX_IMAGE) + def _regex_image(self, event): + """ + :command: imgur + """ if event["channel"].get_setting("auto-imgur", False): - match_gallery = REGEX_GALLERY.match(event["message"]) - match_image = REGEX_IMAGE.match(event["message"]) - - result = None - if match_gallery: - result = self._parse_gallery(match_gallery.group(1)) - elif match_image: - result = self._parse_image(match_image.group(1)) - else: - return - + event["stdout"].write(self._parse_image(event["match"].group(1))) + event.eat() + @utils.hook("command.regex", pattern=REGEX_GALLERY) + def _regex_gallery(self, event): + """ + :command: imgur + """ + if event["channel"].get_setting("auto-imgur", False): + event["stdout"].write(self._parse_gallery(event["match"].group(1))) event.eat() - - self.events.on("send.stdout").call(target=event["channel"], - module_name="Imgur", server=event["server"], message=result) def _parse_gallery(self, hash): api_key = self.bot.config["imgur-api-key"] |
