From abed9cf4ea71dcbad2dd2c049683b8d14b942e09 Mon Sep 17 00:00:00 2001 From: dngfx Date: Fri, 31 Aug 2018 10:50:37 +0100 Subject: Reformat --- modules/google.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'modules/google.py') diff --git a/modules/google.py b/modules/google.py index b8d5c653..f525fc61 100644 --- a/modules/google.py +++ b/modules/google.py @@ -1,29 +1,31 @@ -#--require-config google-api-key -#--require-config google-search-id +# --require-config google-api-key +# --require-config google-search-id import Utils URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1" + class Module(object): def __init__(self, bot): self.bot = bot bot.events.on("received").on("command").on("google", - "g").hook(self.google, help="Google feeling lucky", - usage="[search term]") + "g").hook(self.google, + help="Google feeling lucky", + usage="[search term]") def google(self, event): phrase = event["args"] or event["buffer"].get() if phrase: page = Utils.get_url(URL_GOOGLESEARCH, get_params={ "q": phrase, "key": self.bot.config[ - "google-api-key"], "cx": self.bot.config[ - "google-search-id"], "prettyPrint": "true", + "google-api-key"], "cx": self.bot.config[ + "google-search-id"], "prettyPrint": "true", "num": 1, "gl": "gb"}, json=True) if page: if "items" in page and len(page["items"]): event["stdout"].write(page["items"][0][ - "link"]) + "link"]) else: event["stderr"].write("No results found") else: -- cgit v1.3.1-10-gc9f91