From 194ddbc8c43f9daab0393ab5cf2ec4c7fab08506 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 12 Feb 2022 11:33:13 -0500 Subject: [PATCH] test --- setup.cfg | 10 +++-- sopel_SpiceBot_Core_Prerun/__init__.py | 18 ++++++++ .../__init__.py | 17 ++++++++ sopel_SpiceBot_Runtime_Commands/__init__.py | 42 +------------------ .../__init__.py | 17 ++++++++ 5 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 sopel_SpiceBot_Runtime_Action_Commands/__init__.py create mode 100644 sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py diff --git a/setup.cfg b/setup.cfg index d8af685..8146cb3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,8 +22,10 @@ install_requires = [options.entry_points] sopel.plugins = - SpiceBotCore = sopel_SpiceBot_Core_1 - SpiceBotPrerun = sopel_SpiceBot_Core_Prerun - SpiceBotStartup = sopel_SpiceBot_Core_Startup - SpiceBotRuntimeCommands = sopel_SpiceBot_Runtime_Commands + sopel_SpiceBot_Core_1 = sopel_SpiceBot_Core_1 + sopel_SpiceBot_Core_Prerun = sopel_SpiceBot_Core_Prerun + sopel_SpiceBot_Core_Startup = sopel_SpiceBot_Core_Startup + sopel_SpiceBot_Runtime_Commands = sopel_SpiceBot_Runtime_Commands + sopel_SpiceBot_Runtime_Nickname_Commands = sopel_SpiceBot_Runtime_Nickname_Commands + sopel_SpiceBot_Runtime_Action_Commands = sopel_SpiceBot_Runtime_Action_Commands spicemanip = spicemanip diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 03f2b14..e8d9333 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -41,6 +41,24 @@ def prerun_nickname_command(): return actual_decorator +def prerun_action_command(): + + def actual_decorator(function): + + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + + trigger_command_type = str("nickname_command") + + # Primary command used for trigger, and a list of all words + trigger_args, trigger_command, trigger_prefix = make_trigger_args(trigger.args[1], trigger_command_type) + + function(bot, trigger, *args, **kwargs) + + return internal_prerun + return actual_decorator + + def make_trigger_args(triggerargs_one, trigger_command_type='module'): trigger_args = spicemanip(triggerargs_one, 'create') if trigger_command_type in ['nickname_command']: diff --git a/sopel_SpiceBot_Runtime_Action_Commands/__init__.py b/sopel_SpiceBot_Runtime_Action_Commands/__init__.py new file mode 100644 index 0000000..dae4d3d --- /dev/null +++ b/sopel_SpiceBot_Runtime_Action_Commands/__init__.py @@ -0,0 +1,17 @@ + + +from sopel import plugin + +from sopel_SpiceBot_Core_1 import sb + +from sopel_SpiceBot_Core_Prerun import prerun_action_command + + +@prerun_action_command() +@plugin.action_command('test') +def sb_test_commands(bot, trigger): + bot.say("Testing the bot") + bot.say("Attributes: %s" % [x for x in dir(sb) if not x.startswith("__")]) + bot.say("%s" % sb.versions.dict) + + sb.osd("test", trigger.sender) diff --git a/sopel_SpiceBot_Runtime_Commands/__init__.py b/sopel_SpiceBot_Runtime_Commands/__init__.py index 6c7615a..13f5f89 100644 --- a/sopel_SpiceBot_Runtime_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Commands/__init__.py @@ -4,47 +4,7 @@ from sopel import plugin from sopel_SpiceBot_Core_1 import sb -from sopel_SpiceBot_Core_Prerun import prerun_nickname_command, prerun_command - - -@prerun_nickname_command() -@plugin.nickname_command('test') -def sb_test_commands(bot, trigger): - bot.say("Testing the bot") - bot.say("Attributes: %s" % [x for x in dir(sb) if not x.startswith("__")]) - bot.say("%s" % sb.versions.dict) - - sb.osd("test", trigger.sender) - - -@prerun_nickname_command() -@plugin.nickname_command('commands') -def sopel_commands(bot, trigger): - - bot.say("testing commands") - - bot.say(str(bot.rules._rules.values())) - - -@prerun_nickname_command() -@plugin.nickname_command('nickname_commands') -def sopel_nickname_commands(bot, trigger): - bot.say("testing nickname_commands") - - for x in sb.commands.sopel_nickname_commands: - for y in x: - bot.say(str(y)) - - -@prerun_nickname_command() -@plugin.nickname_command('action_commands') -def sopel_action_commands(bot, trigger): - - bot.say("testing action_commands") - - for x in sb.commands.sopel_action_commands: - for y in x: - bot.say(str(y)) +from sopel_SpiceBot_Core_Prerun import prerun_command @prerun_command() diff --git a/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py b/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py new file mode 100644 index 0000000..0fd989d --- /dev/null +++ b/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py @@ -0,0 +1,17 @@ + + +from sopel import plugin + +from sopel_SpiceBot_Core_1 import sb + +from sopel_SpiceBot_Core_Prerun import prerun_nickname_command + + +@prerun_nickname_command() +@plugin.nickname_command('test') +def sb_test_commands(bot, trigger): + bot.say("Testing the bot") + bot.say("Attributes: %s" % [x for x in dir(sb) if not x.startswith("__")]) + bot.say("%s" % sb.versions.dict) + + sb.osd("test", trigger.sender)