Switch imgur.py to use command.regex system
This commit is contained in:
parent
105351d6f3
commit
6f0b31cb9a
1 changed files with 14 additions and 16 deletions
|
@ -26,24 +26,22 @@ class Module(ModuleManager.BaseModule):
|
||||||
text += "%s " % data["account_url"]
|
text += "%s " % data["account_url"]
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@utils.hook("received.message.channel", priority=EventManager.PRIORITY_LOW)
|
@utils.hook("command.regex", pattern=REGEX_IMAGE)
|
||||||
def channel_message(self, event):
|
def _regex_image(self, event):
|
||||||
|
"""
|
||||||
|
:command: imgur
|
||||||
|
"""
|
||||||
if event["channel"].get_setting("auto-imgur", False):
|
if event["channel"].get_setting("auto-imgur", False):
|
||||||
match_gallery = REGEX_GALLERY.match(event["message"])
|
event["stdout"].write(self._parse_image(event["match"].group(1)))
|
||||||
match_image = REGEX_IMAGE.match(event["message"])
|
event.eat()
|
||||||
|
@utils.hook("command.regex", pattern=REGEX_GALLERY)
|
||||||
result = None
|
def _regex_gallery(self, event):
|
||||||
if match_gallery:
|
"""
|
||||||
result = self._parse_gallery(match_gallery.group(1))
|
:command: imgur
|
||||||
elif match_image:
|
"""
|
||||||
result = self._parse_image(match_image.group(1))
|
if event["channel"].get_setting("auto-imgur", False):
|
||||||
else:
|
event["stdout"].write(self._parse_gallery(event["match"].group(1)))
|
||||||
return
|
|
||||||
|
|
||||||
event.eat()
|
event.eat()
|
||||||
|
|
||||||
self.events.on("send.stdout").call(target=event["channel"],
|
|
||||||
module_name="Imgur", server=event["server"], message=result)
|
|
||||||
|
|
||||||
def _parse_gallery(self, hash):
|
def _parse_gallery(self, hash):
|
||||||
api_key = self.bot.config["imgur-api-key"]
|
api_key = self.bot.config["imgur-api-key"]
|
||||||
|
|
Loading…
Reference in a new issue