Initial Commit
This commit is contained in:
parent
08e712c085
commit
4c1fb203b9
47
Command_Management_Module.py
Normal file
47
Command_Management_Module.py
Normal 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()
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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):
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user