From 51a52e2b0e54031cce5876f54d1d48c268b5441c Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 26 Sep 2018 18:27:17 +0100 Subject: Switch to using @Utils.hook and docstrings for event hooks --- modules/translate.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules/translate.py') diff --git a/modules/translate.py b/modules/translate.py index fd2c2c07..297b3147 100644 --- a/modules/translate.py +++ b/modules/translate.py @@ -1,17 +1,16 @@ import json, re -from src import Utils +from src import ModuleManager, Utils URL_TRANSLATE = "http://translate.googleapis.com/translate_a/single" URL_LANGUAGES = "https://cloud.google.com/translate/docs/languages" REGEX_LANGUAGES = re.compile("(\w+)?:(\w+)? ") -class Module(object): - def __init__(self, bot, events, exports): - events.on("received.command").on("translate", "tr").hook( - self.translate, help="Translate the provided phrase or the " - "last line seen.", usage="[phrase]") - +class Module(ModuleManager.BaseModule): + @Utils.hook("received.command.translate|tr", usage="[phrase]") def translate(self, event): + """ + Translate the provided phrase or the last line in thie current channel + """ phrase = event["args"] if not phrase: phrase = event["buffer"].get() -- cgit v1.3.1-10-gc9f91