From 7bbffecd869e91b676f60e63adacc34b57152657 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 20 Sep 2019 10:09:11 -0400 Subject: [PATCH] test search dictcom --- .../SpiceBot_DictComs/search/testsearch.json | 7 +++++++ .../SpiceBot_Core_Commands/DictComs.py | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 sopel_modules/SpiceBot_Configs/SpiceBot_DictComs/search/testsearch.json diff --git a/sopel_modules/SpiceBot_Configs/SpiceBot_DictComs/search/testsearch.json b/sopel_modules/SpiceBot_Configs/SpiceBot_DictComs/search/testsearch.json new file mode 100644 index 0000000..977daa2 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/SpiceBot_DictComs/search/testsearch.json @@ -0,0 +1,7 @@ +{ +"?default": { + "type": "search", + "responses": "test", + "search_fail": ["Test search failed"], + }, +} diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 67e07ed..5bc2d47 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -34,7 +34,7 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict["target"] = False botcom.dict["success"] = True - if botcom.dict["dict"][botcom.dict["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]: + if botcom.dict["dict"][botcom.dict["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses", "search"]: return bot_dictcom_responses(bot, trigger, botcom) else: command_function_run = str('bot_dictcom_' + botcom.dict["dict"][botcom.dict["responsekey"]]["type"] + '(bot, trigger, botcom)') @@ -293,4 +293,18 @@ def bot_dictcom_feeds(bot, trigger, botcom): def bot_dictcom_search(bot, trigger, botcom): - bot.say("testing done") + + if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"] and not botcom.dict["completestring"]: + botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_fail"] + return bot_dictcom_reply_shared(bot, trigger, botcom) + elif botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"] and botcom.dict["completestring"]: + searchterm = [botcom.dict["completestring"]] + else: + searchterm = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] + + if searchterm: + 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)])