diff --git a/Command_Management_Module.py b/Command_Management_Module.py new file mode 100644 index 0000000..9c8ec66 --- /dev/null +++ b/Command_Management_Module.py @@ -0,0 +1,47 @@ +from main import user_module_init +import config as config +import db + +import user_module + +import commands.loader as command_loader +from commands.command_base import AbstractCommand + +import credentials + +class Command_Management_Module(): + def __init__(self): + super().__init__() + self.dbCredential: credentials.DB_Credential + + def main(self): + print("[TEST Module]> test") + + tempModule = user_module.User_Module() + tempModule.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis) + print(self.getCommandsList(tempModule.commands)) + + def getCommandsList(self, targetModuleCommands): + print(type(targetModuleCommands)) + commandsList = "\n" + for cmd in targetModuleCommands: + targetCommand = targetModuleCommands[cmd] + print(targetCommand.command) + print(targetCommand.isCommandEnabled) + + + return commandsList + + def + + def getUserPermission(): + pass + + +if __name__ == "__main__": + testModule = Command_Management_Module() + + credentials_manager = credentials.Credentials_Module() + credentials_manager.load_credentials() + testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname) + testModule.main() \ No newline at end of file diff --git a/commands/command_base.py b/commands/command_base.py index 2eb2c0f..9b012f9 100644 --- a/commands/command_base.py +++ b/commands/command_base.py @@ -18,11 +18,12 @@ class AbstractCommand(metaclass=ABCMeta): TWITCH = auto() DISCORD = auto() - def __init__(self, command: str, n_args: int = 0, command_type=CommandType.NONE, helpText:list=["No Help"]): + def __init__(self, command: str, n_args: int = 0, command_type=CommandType.NONE, helpText:list=["No Help"], CommandEnabled = True): self.command = command self.n_args = n_args self.command_type = command_type self.help = helpText + self.isCommandEnabled = CommandEnabled # no touch! def get_args(self, text: str) -> list: @@ -36,6 +37,10 @@ class AbstractCommand(metaclass=ABCMeta): def get_help(self): return self.help + # no touch! + def is_command_enabled(self): + return self.isCommandEnabled + @abstractmethod def do_command(self, bot, twitch_message): pass diff --git a/commands/implemented/command_chyron.py b/commands/implemented/command_chyron.py index 454f013..41f2a3e 100644 --- a/commands/implemented/command_chyron.py +++ b/commands/implemented/command_chyron.py @@ -17,6 +17,7 @@ class CommandChyron(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandChyron.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis) self.help = ["The chyron string can be generated and updated with this command.", "\nExample:","chyron update \"RIGHTNOW\""] + self.isCommandEnabled = True def do_command(self, bot, user_message): tempBool = True diff --git a/commands/implemented/command_help.py b/commands/implemented/command_help.py index 77160ab..17bb368 100644 --- a/commands/implemented/command_help.py +++ b/commands/implemented/command_help.py @@ -17,6 +17,7 @@ class CommandChyron(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandChyron.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis) self.help = ["This is a command to learn more about other commands.", "\nExample:","help \"COMMAND\""] + self.isCommandEnabled = True self.blockDecor = "\n================================================================\n" diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index 0ec7641..7841d03 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -17,6 +17,7 @@ class CommandLights(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandLights.command, n_args=3, command_type=AbstractCommand.CommandType.Praxis) self.help = ["This command allows you to modify the lights via the Lights_Module.", "\nExample:","lights \"SCENE\"","lights \"COLOR\"","lights \"R\" \"G\" \"B\"","lights \"1\" \"0.5\" \"0\""] + self.isCommandEnabled = True def do_command(self, bot, user_message): tempBool = True diff --git a/commands/implemented/command_lights_rgb_color_twitch.py b/commands/implemented/command_lights_rgb_color_twitch.py index a2b3652..7d93cb3 100644 --- a/commands/implemented/command_lights_rgb_color_twitch.py +++ b/commands/implemented/command_lights_rgb_color_twitch.py @@ -17,6 +17,7 @@ class CommandLights(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandLights.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["This command allows you to modify the lights via the Lights_Module.", "\nExample:","!lights \"SCENE\"","!lights \"COLOR\"","!lights \"R\" \"G\" \"B\"","!lights \"1\" \"0.5\" \"0\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): diff --git a/commands/implemented/command_restartBot_discord.py b/commands/implemented/command_restartBot_discord.py index 17711cb..7185021 100644 --- a/commands/implemented/command_restartBot_discord.py +++ b/commands/implemented/command_restartBot_discord.py @@ -14,6 +14,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.DISCORD) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True async def do_command(self, bot, discord_message: discord.message): diff --git a/commands/implemented/command_restartBot_twitch.py b/commands/implemented/command_restartBot_twitch.py index 01dfea1..4730972 100644 --- a/commands/implemented/command_restartBot_twitch.py +++ b/commands/implemented/command_restartBot_twitch.py @@ -11,6 +11,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) diff --git a/commands/implemented/command_roll_discord.py b/commands/implemented/command_roll_discord.py index 17d8f59..4d89101 100644 --- a/commands/implemented/command_roll_discord.py +++ b/commands/implemented/command_roll_discord.py @@ -20,6 +20,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.DISCORD) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True async def do_command(self, bot, discord_message: discord.Message): print("!roll Detected") diff --git a/commands/implemented/command_roll_twitch.py b/commands/implemented/command_roll_twitch.py index 46c7256..1ec08ac 100644 --- a/commands/implemented/command_roll_twitch.py +++ b/commands/implemented/command_roll_twitch.py @@ -14,6 +14,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): print("!roll Detected") diff --git a/commands/implemented/command_shutdownBot_discord.py b/commands/implemented/command_shutdownBot_discord.py index 6f9296e..dc61a47 100644 --- a/commands/implemented/command_shutdownBot_discord.py +++ b/commands/implemented/command_shutdownBot_discord.py @@ -14,6 +14,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.DISCORD) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True async def do_command(self, bot, discord_message: discord.message): diff --git a/commands/implemented/command_shutdownBot_twitch.py b/commands/implemented/command_shutdownBot_twitch.py index a8f39e8..5f7b04d 100644 --- a/commands/implemented/command_shutdownBot_twitch.py +++ b/commands/implemented/command_shutdownBot_twitch.py @@ -11,6 +11,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) diff --git a/commands/implemented/command_test_twitch.py b/commands/implemented/command_test_twitch.py index d35f8f8..85f917d 100644 --- a/commands/implemented/command_test_twitch.py +++ b/commands/implemented/command_test_twitch.py @@ -13,6 +13,7 @@ class CommandTest(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTest.command, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): print("!test Detected") diff --git a/commands/implemented/command_tts_discord.py b/commands/implemented/command_tts_discord.py index 974101f..5392b10 100644 --- a/commands/implemented/command_tts_discord.py +++ b/commands/implemented/command_tts_discord.py @@ -12,6 +12,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=1, command_type=AbstractCommand.CommandType.DISCORD) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True async def do_command(self, bot, discord_message: discord.message): args = self.get_args(discord_message.content) diff --git a/commands/implemented/command_tts_twitch.py b/commands/implemented/command_tts_twitch.py index 67229eb..21df227 100644 --- a/commands/implemented/command_tts_twitch.py +++ b/commands/implemented/command_tts_twitch.py @@ -11,6 +11,7 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandTTS.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH) self.help = ["MISSING HELP ENTRY", "\nExample:","command \"PARAM\""] + self.isCommandEnabled = True def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) diff --git a/config.py b/config.py index cd67c70..3d8b39a 100644 --- a/config.py +++ b/config.py @@ -25,6 +25,9 @@ blockAll_TTS_URL_Twitch = True autoEnabled_Twitch_rgbLightControl = False +twitch_defaultCommandEnabledState = True +#twitch_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams. + #Discord Module Configs block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to Discord channels blockAll_DiscordChannelsMessaging = False # Blocks the ability to send messages to Discord channels @@ -41,6 +44,9 @@ blockAll_TTS_URL_Discord = True autoEnabled_Discord_rgbLightControl = False +#discord_defaultCommandEnabledState = True +#discord_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams. + #User Module Configs blockAll_TTS_URL_UserModule = True diff --git a/help_module.py b/help_module.py index cb8747d..b67a4bf 100644 --- a/help_module.py +++ b/help_module.py @@ -14,6 +14,7 @@ class Help_Module(): def main(self): print("[Help Module]> help test") + self.isCommandEnabled = True def help_command_response(self, command:AbstractCommand, responseType): response = help_command_response() diff --git a/test_module.py b/test_module.py index 605d286..9594d9b 100644 --- a/test_module.py +++ b/test_module.py @@ -6,7 +6,7 @@ import credentials class Test_Module(): def __init__(self): super().__init__() - #self.dbCredential: credentials.DB_Credential + self.dbCredential: credentials.DB_Credential def main(self): print("[TEST Module]> test")