diff options
| author | 2018-09-26 18:27:17 +0100 | |
|---|---|---|
| committer | 2018-09-26 18:27:17 +0100 | |
| commit | 51a52e2b0e54031cce5876f54d1d48c268b5441c (patch) | |
| tree | a4c0e8e86c55aa701b06297d5b5a2ceebeaab60d /modules/translate.py | |
| parent | Also use docstrings to check if a command has help available, allow one-string (diff) | |
| signature | ||
Switch to using @Utils.hook and docstrings for event hooks
Diffstat (limited to 'modules/translate.py')
| -rw-r--r-- | modules/translate.py | 13 |
1 files changed, 6 insertions, 7 deletions
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() |
