From 961c25be78a1fa8ca78f8460813efc0bd2d179d3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 14 Jun 2019 09:47:12 -0400 Subject: [PATCH] new .search start --- sopel_modules/SpiceBot/Google.py | 2 ++ .../SpiceBot_Core_Commands/Commands.py | 2 ++ .../SpiceBot_Core_Commands/Search.py | 26 +++++++++++++++++++ .../SpiceBot_Core_Commands/__init__.py | 1 + 4 files changed, 31 insertions(+) create mode 100644 sopel_modules/SpiceBot_Core_Commands/Search.py diff --git a/sopel_modules/SpiceBot/Google.py b/sopel_modules/SpiceBot/Google.py index 8d29968..c1ffffe 100644 --- a/sopel_modules/SpiceBot/Google.py +++ b/sopel_modules/SpiceBot/Google.py @@ -5,6 +5,8 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import requests from fake_useragent import UserAgent +# TODO add a cache flush + class Google(): diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index 3353ea1..8a1feef 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -11,6 +11,8 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +# TODO commands sent in privmsg don't need bot.nick + @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('nickname') diff --git a/sopel_modules/SpiceBot_Core_Commands/Search.py b/sopel_modules/SpiceBot_Core_Commands/Search.py new file mode 100644 index 0000000..0e9dfc6 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Search.py @@ -0,0 +1,26 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot search system. +""" +import sopel + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.prerun.prerun('module') +@sopel.module.commands('search', 'find', 'google', 'lookup') +def nickname_comand_commands(bot, trigger): + + searchterm = spicemanip.main(trigger.sb['args'], 0) or None + if not searchterm: + bot.osd("Not sure what you want me to look for.") + return + + searchreturn = SpiceBot.google.search(searchterm) + if not searchreturn: + bot.osd('I cannot find anything about that') + else: + bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index e4a8f3c..4f14aee 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -16,6 +16,7 @@ from .Runtime_Controls import * from .Messaging import * from .Docs import * from .BotPrivs import * +from .Search import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net'