diff options
| author | 2018-09-26 18:27:17 +0100 | |
|---|---|---|
| committer | 2018-09-26 18:27:17 +0100 | |
| commit | 51a52e2b0e54031cce5876f54d1d48c268b5441c (patch) | |
| tree | a4c0e8e86c55aa701b06297d5b5a2ceebeaab60d /modules/google.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/google.py')
| -rw-r--r-- | modules/google.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/google.py b/modules/google.py index 1d7b6e8c..f98ed2ad 100644 --- a/modules/google.py +++ b/modules/google.py @@ -10,12 +10,12 @@ URL_GOOGLESUGGEST = "http://google.com/complete/search" class Module(object): def __init__(self, bot, events, exports): self.bot = bot - events.on("received.command").on("google", "g").hook(self.google, - help="Google feeling lucky", usage="[search term]") - events.on("received.command.suggest").hook(self.suggest, - help="Get suggested phrases from Google", usage="[phrase]") + @Utils.hook("received.command.google|g", usage="[search term]") def google(self, event): + """ + Get first Google result for a given search term + """ phrase = event["args"] or event["buffer"].get() if phrase: page = Utils.get_url(URL_GOOGLESEARCH, get_params={ @@ -34,7 +34,11 @@ class Module(object): else: event["stderr"].write("No phrase provided") + @Utils.hook("received.command.suggest", usage="[phrase]") def suggest(self, event): + """ + Get suggested phrases from Google + """ phrase = event["args"] or event["buffer"].get() if phrase: page = Utils.get_url(URL_GOOGLESUGGEST, get_params={ |
