Command-Management-Module & Command File Simplification/Reduction #27

Merged
alex_orid merged 4 commits from Command-Management-Module into master 2021-04-16 05:35:51 +00:00
18 changed files with 74 additions and 2 deletions
Showing only changes of commit 4c1fb203b9 - Show all commits

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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")

View File

@ -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")

View File

@ -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):

View File

@ -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)

View File

@ -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")

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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")