From fe60378a68a54c63a201638a24552bdf3934deff Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 8 May 2019 12:25:14 -0400 Subject: [PATCH] add dummy command --- sopel_modules/SpiceBot_AI/AI.py | 3 ++ sopel_modules/SpiceBot_SBTools/__init__.py | 41 +++++++++++++++++++ .../SpiceBot_SopelPatches/Patches.py | 9 +++- .../SpiceBot_dummycommand.py | 11 +++++ sopel_modules/SpiceBot_Update/Update.py | 34 +-------------- 5 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 764ebaa..e2b583a 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -12,6 +12,9 @@ from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, googlesearch, bot_ @sopel.module.nickname_commands('(.*)') def bot_command_gender(bot, trigger): + while not bot_events_check(bot, ['1004', '2002']): + pass + triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') if not triggercommand: diff --git a/sopel_modules/SpiceBot_SBTools/__init__.py b/sopel_modules/SpiceBot_SBTools/__init__.py index 906a928..cd98d6c 100644 --- a/sopel_modules/SpiceBot_SBTools/__init__.py +++ b/sopel_modules/SpiceBot_SBTools/__init__.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # coding=utf-8 """Useful miscellaneous tools and shortcuts for SpiceBot Sopel modules """ @@ -318,6 +319,46 @@ def channel_list_current(bot): """Environment Functions""" +def stock_modules_begone(bot): + + # Remove stock modules, if present + main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__)) + modules_dir = os.path.join(main_sopel_dir, 'modules') + stockdir = os.path.join(modules_dir, "stock") + if not os.path.exists(stockdir) or not os.path.isdir(stockdir): + os.system("sudo mkdir " + stockdir) + if "SpiceBot_dummycommand.py" not in os.listdir(modules_dir): + import sopel_modules + for plugin_dir in set(sopel_modules.__path__): + for pathname in os.listdir(plugin_dir): + if pathname == 'SpiceBot_SopelPatches': + pypi_modules_dir = os.path.join(plugin_dir, pathname) + if "SpiceBot_dummycommand.py" in os.listdir(pypi_modules_dir): + if "SpiceBot_dummycommand.py" not in os.listdir(modules_dir): + os.system("sudo cp " + os.path.join(pypi_modules_dir, "SpiceBot_dummycommand.py") + " " + modules_dir) + for pathname in os.listdir(modules_dir): + path = os.path.join(modules_dir, pathname) + if (os.path.isfile(path) and pathname.endswith('.py') and not pathname.startswith('_')): + if not pathname in ["__init__.py", "SpiceBot_dummycommand.py"]: + os.system("sudo mv " + path + " " + stockdir) + + +def spicebot_update(bot, deps=False): + + pipcommand = "sudo pip3 install --upgrade" + if not deps: + pipcommand += " --no-deps" + pipcommand += " --force-reinstall" + pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) + + bot_logging(bot, 'SpiceBot_Update', "Running `" + pipcommand + "`") + # for line in os.popen(pipcommand).read().split('\n'): + # bot_logging(bot, 'SpiceBot_Update', " " + line) + os.system(pipcommand) + + stock_modules_begone(bot) + + def spicebot_reload(bot, log_from='service_manip', quitmessage='Recieved QUIT'): # service_manip(bot, bot.nick, 'restart', log_from) bot.restart(quitmessage) diff --git a/sopel_modules/SpiceBot_SopelPatches/Patches.py b/sopel_modules/SpiceBot_SopelPatches/Patches.py index 90b1433..ee7fc20 100644 --- a/sopel_modules/SpiceBot_SopelPatches/Patches.py +++ b/sopel_modules/SpiceBot_SopelPatches/Patches.py @@ -3,12 +3,19 @@ from __future__ import unicode_literals, absolute_import, print_function, division # sopel imports +import sopel import sopel.module -from sopel_modules.SpiceBot_SBTools import bot_logging +from sopel_modules.SpiceBot_SBTools import bot_logging, stock_modules_begone + +import os def setup(bot): + bot_logging(bot, 'Sopel_Patch', "Patching Sopels built-in url_callbacks") if 'url_callbacks' not in bot.memory: bot.memory['url_callbacks'] = sopel.tools.SopelMemory() + + bot_logging(bot, 'Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") + stock_modules_begone(bot) diff --git a/sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py b/sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py new file mode 100644 index 0000000..5bab9f4 --- /dev/null +++ b/sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +# coding=utf-8 +"""dummycommand""" +from __future__ import unicode_literals, absolute_import, print_function, division + +import sopel.module + + +@sopel.module.commands("?zz_dummycommand") +def dummycommand(bot, trigger): + return diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index fbd833a..6d58141 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -6,11 +6,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel.module from sopel.config.types import StaticSection, ValidatedAttribute -import os - import spicemanip -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, bot_logging, spicebot_reload +from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, bot_logging, spicebot_reload, spicebot_update class SpiceBot_Update_MainSection(StaticSection): @@ -60,33 +58,3 @@ def nickname_comand_update(bot, trigger): # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') spicebot_reload(bot, 'SpiceBot_Update', quitmessage) - - -def spicebot_update(bot, deps=False): - - pipcommand = "sudo pip3 install --upgrade" - if not deps: - pipcommand += " --no-deps" - pipcommand += " --force-reinstall" - pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) - - bot_logging(bot, 'SpiceBot_Update', "Running `" + pipcommand + "`") - # for line in os.popen(pipcommand).read().split('\n'): - # bot_logging(bot, 'SpiceBot_Update', " " + line) - os.system(pipcommand) - - stock_modules_begone(bot) - - -def stock_modules_begone(bot): - - # Remove stock modules, if present - main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__)) - modules_dir = os.path.join(main_sopel_dir, 'modules') - stockdir = os.path.join(modules_dir, "stock") - if not os.path.exists(stockdir) or not os.path.isdir(stockdir): - os.system("sudo mkdir " + stockdir) - for pathname in os.listdir(modules_dir): - path = os.path.join(modules_dir, pathname) - if (os.path.isfile(path) and pathname.endswith('.py') and not pathname.startswith('_')): - os.system("sudo mv " + path + " " + stockdir)