From bf7947938c35cc0af9ba4a098b4dcebdd64e0526 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 21:49:59 -0400 Subject: [PATCH 01/18] Fixed Bug --- commands/implemented/command_chyron.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commands/implemented/command_chyron.py b/commands/implemented/command_chyron.py index 16af567..8aa0240 100644 --- a/commands/implemented/command_chyron.py +++ b/commands/implemented/command_chyron.py @@ -26,7 +26,14 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): if "update" in tempParsedMessage[1]: chyron = chyron_module.Chyron_Module() if i > 2: - chyron.main(tempParsedMessage[2]) + rightNow = "" + counter = 0 + for word in tempParsedMessage: + if counter > 1: + rightNow = rightNow + word + " " + counter = counter + 1 + rightNow = rightNow[:-1] + chyron.main(rightNow) else: chyron.main() chyron.updateChyronFile() -- 2.45.2 From 9a7c0d51527befe79f8270c282965c3bec0d707a Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 11 Apr 2021 21:49:15 -0400 Subject: [PATCH 02/18] Help Module Initial --- .gitignore | 3 +- commands/command_base.py | 7 +- commands/implemented/command_chyron.py | 15 ++-- commands/implemented/command_help.py | 35 +++++++++ .../implemented/command_lights_rgb_color.py | 13 +++- .../command_lights_rgb_color_twitch.py | 11 ++- .../implemented/command_restartBot_discord.py | 5 ++ .../implemented/command_restartBot_twitch.py | 4 + commands/implemented/command_roll_discord.py | 5 ++ commands/implemented/command_roll_twitch.py | 5 ++ .../command_shutdownBot_discord.py | 5 ++ .../implemented/command_shutdownBot_twitch.py | 4 + commands/implemented/command_test_twitch.py | 5 ++ commands/implemented/command_tts_discord.py | 5 ++ commands/implemented/command_tts_twitch.py | 5 ++ help_module.py | 73 +++++++++++++++++++ praxis-main.bat | 2 + praxis-user.bat | 2 + 18 files changed, 190 insertions(+), 14 deletions(-) create mode 100644 commands/implemented/command_help.py create mode 100644 help_module.py create mode 100644 praxis-main.bat create mode 100644 praxis-user.bat diff --git a/.gitignore b/.gitignore index 0b9935e..4349db9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ tts/ __pycache__/ credentials/ -.idea/ \ No newline at end of file +.idea/ +stream_sources/chyron.txt diff --git a/commands/command_base.py b/commands/command_base.py index 064b5c5..2eb2c0f 100644 --- a/commands/command_base.py +++ b/commands/command_base.py @@ -18,10 +18,11 @@ class AbstractCommand(metaclass=ABCMeta): TWITCH = auto() DISCORD = auto() - def __init__(self, command: str, n_args: int = 0, command_type=CommandType.NONE): + def __init__(self, command: str, n_args: int = 0, command_type=CommandType.NONE, helpText:list=["No Help"]): self.command = command self.n_args = n_args self.command_type = command_type + self.help = helpText # no touch! def get_args(self, text: str) -> list: @@ -31,6 +32,10 @@ class AbstractCommand(metaclass=ABCMeta): def get_command(self) -> str: return self.command + # no touch! + def get_help(self): + return self.help + @abstractmethod def do_command(self, bot, twitch_message): pass diff --git a/commands/implemented/command_chyron.py b/commands/implemented/command_chyron.py index 8aa0240..454f013 100644 --- a/commands/implemented/command_chyron.py +++ b/commands/implemented/command_chyron.py @@ -7,14 +7,16 @@ import random import utilities_script as utilities -class CommandRoll(AbstractCommand, metaclass=ABCMeta): +class CommandChyron(AbstractCommand, metaclass=ABCMeta): """ - this is the roll command. + this is the chyron command. """ command = "chyron" def __init__(self): - super().__init__(CommandRoll.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis) + 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\""] def do_command(self, bot, user_message): tempBool = True @@ -22,7 +24,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): tempParsedMessage = user_message.message.split(" ") i = len(tempParsedMessage) - if i > 1: + if i > 2: if "update" in tempParsedMessage[1]: chyron = chyron_module.Chyron_Module() if i > 2: @@ -39,4 +41,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): chyron.updateChyronFile() returnMessage = "@" + user_message.user + " updated the chyron!" - bot.return_message(returnMessage) \ No newline at end of file + bot.return_message(returnMessage) + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_help.py b/commands/implemented/command_help.py new file mode 100644 index 0000000..4b665fc --- /dev/null +++ b/commands/implemented/command_help.py @@ -0,0 +1,35 @@ +from abc import ABCMeta +import help_module + +from commands.command_base import AbstractCommand + +import random + +import utilities_script as utilities + +class CommandChyron(AbstractCommand, metaclass=ABCMeta): + """ + this is the help command. + """ + command = "help" + + def __init__(self): + 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\""] + + def do_command(self, bot, user_message): + tempBool = True + if tempBool == True: + tempParsedMessage = user_message.message.split(" ") + i = len(tempParsedMessage) + + if i > 1: + targetCommand = bot.commands[tempParsedMessage[1]] + helper = help_module.Help_Module_.help_command_response(targetCommand, help_module.help_command_responseType.fancy) + + returnMessage = helper.response + bot.return_message(returnMessage) + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index 243b98a..c53cbab 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -7,14 +7,16 @@ import random import utilities_script as utilities -class CommandRoll(AbstractCommand, metaclass=ABCMeta): +class CommandLights(AbstractCommand, metaclass=ABCMeta): """ - this is the roll command. + this is the lights command. """ command = "lights" def __init__(self): - super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.Praxis) + 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\""] def do_command(self, bot, user_message): tempBool = True @@ -64,4 +66,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print("Scene Command!") returnMessage = "@" + user_message.user + " changed the light's color!" - bot.return_message(returnMessage) \ No newline at end of file + bot.return_message(returnMessage) + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_lights_rgb_color_twitch.py b/commands/implemented/command_lights_rgb_color_twitch.py index a87ea3b..51025cb 100644 --- a/commands/implemented/command_lights_rgb_color_twitch.py +++ b/commands/implemented/command_lights_rgb_color_twitch.py @@ -7,14 +7,16 @@ import random import utilities_script as utilities -class CommandRoll(AbstractCommand, metaclass=ABCMeta): +class CommandLights(AbstractCommand, metaclass=ABCMeta): """ this is the roll command. """ command = "!lights" def __init__(self): - super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) + 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\""] def do_command(self, bot, twitch_message): @@ -64,4 +66,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print("Scene Command!") returnMessage = "@" + twitch_message.sender + " changed the light's color!" - bot.send_message(returnMessage) \ No newline at end of file + bot.send_message(returnMessage) + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_restartBot_discord.py b/commands/implemented/command_restartBot_discord.py index 49e38bd..17711cb 100644 --- a/commands/implemented/command_restartBot_discord.py +++ b/commands/implemented/command_restartBot_discord.py @@ -12,6 +12,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.DISCORD) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] async def do_command(self, bot, discord_message: discord.message): @@ -21,3 +23,6 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): response = str("Bot restarting...") await bot.send_message(discord_message, response) utilities.restart_self() + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_restartBot_twitch.py b/commands/implemented/command_restartBot_twitch.py index fea1299..01dfea1 100644 --- a/commands/implemented/command_restartBot_twitch.py +++ b/commands/implemented/command_restartBot_twitch.py @@ -9,6 +9,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.TWITCH) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) @@ -16,3 +18,5 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): bot.send_message("Bot restarting...") utilities.restart_self() + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_roll_discord.py b/commands/implemented/command_roll_discord.py index 47f4c69..17d8f59 100644 --- a/commands/implemented/command_roll_discord.py +++ b/commands/implemented/command_roll_discord.py @@ -18,6 +18,8 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.DISCORD) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] async def do_command(self, bot, discord_message: discord.Message): print("!roll Detected") @@ -173,3 +175,6 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print(diceRoll) return diceRoll + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_roll_twitch.py b/commands/implemented/command_roll_twitch.py index 7f1549d..46c7256 100644 --- a/commands/implemented/command_roll_twitch.py +++ b/commands/implemented/command_roll_twitch.py @@ -12,6 +12,8 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] def do_command(self, bot, twitch_message): print("!roll Detected") @@ -166,3 +168,6 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print(diceRoll) return diceRoll + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_shutdownBot_discord.py b/commands/implemented/command_shutdownBot_discord.py index 588850f..6f9296e 100644 --- a/commands/implemented/command_shutdownBot_discord.py +++ b/commands/implemented/command_shutdownBot_discord.py @@ -12,6 +12,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.DISCORD) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] async def do_command(self, bot, discord_message: discord.message): @@ -21,3 +23,6 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): response = str("Bot shutting down...") await bot.send_message(discord_message, response) utilities.hard_shutdown() + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_shutdownBot_twitch.py b/commands/implemented/command_shutdownBot_twitch.py index 1cdcb4c..a8f39e8 100644 --- a/commands/implemented/command_shutdownBot_twitch.py +++ b/commands/implemented/command_shutdownBot_twitch.py @@ -9,6 +9,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=0, command_type=AbstractCommand.CommandType.TWITCH) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) @@ -16,3 +18,5 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): bot.send_message("Bot shutting down...") utilities.hard_shutdown() + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_test_twitch.py b/commands/implemented/command_test_twitch.py index 1432e14..d35f8f8 100644 --- a/commands/implemented/command_test_twitch.py +++ b/commands/implemented/command_test_twitch.py @@ -11,7 +11,12 @@ class CommandTest(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTest.command, command_type=AbstractCommand.CommandType.TWITCH) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] def do_command(self, bot, twitch_message): print("!test Detected") bot.send_message("testing acknowledged") + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_tts_discord.py b/commands/implemented/command_tts_discord.py index 9a359b2..974101f 100644 --- a/commands/implemented/command_tts_discord.py +++ b/commands/implemented/command_tts_discord.py @@ -10,6 +10,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=1, command_type=AbstractCommand.CommandType.DISCORD) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] async def do_command(self, bot, discord_message: discord.message): args = self.get_args(discord_message.content) @@ -28,3 +30,6 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): response = str("tts deactivated on %s" % discord_message.guild.name) await bot.send_message(discord_message, response) bot.tts_enabled = False + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/command_tts_twitch.py b/commands/implemented/command_tts_twitch.py index 133d851..67229eb 100644 --- a/commands/implemented/command_tts_twitch.py +++ b/commands/implemented/command_tts_twitch.py @@ -9,6 +9,8 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(CommandTTS.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH) + self.help = ["MISSING HELP ENTRY", + "\nExample:","command \"PARAM\""] def do_command(self, bot, twitch_message): args = self.get_args(twitch_message.text) @@ -20,3 +22,6 @@ class CommandTTS(AbstractCommand, metaclass=ABCMeta): if twitch_message.sender.lower() == twitch_message.channel: bot.send_message("tts deactivated on #%s" % twitch_message.channel) bot.tts_enabled = False + + def get_help(self): + return self.help \ No newline at end of file diff --git a/help_module.py b/help_module.py new file mode 100644 index 0000000..cb8747d --- /dev/null +++ b/help_module.py @@ -0,0 +1,73 @@ +from commands.command_base import AbstractCommand +from enum import Enum +import config as config +import db + +import commands.loader as command_loader + +import credentials + +class Help_Module(): + def __init__(self): + super().__init__() + #self.dbCredential: credentials.DB_Credential + + def main(self): + print("[Help Module]> help test") + + def help_command_response(self, command:AbstractCommand, responseType): + response = help_command_response() + response.setup(command, responseType) + response.makeResponse() + return response + +class help_command_responseType(Enum): + plain = 1 # One line response + fancy = 2 # Fancy formatted response + +class help_command_response(): + def __init__(self): + super().__init__() + self.command = None + self.commandName = "" + self.helpText = "" + self.response = "" + self.responseType = help_command_responseType.plain + self.blockDecor = "\n================================================================\n" + + def setup(self, command, responseType): + self.command = command + self.commandName = command.command + self.responseType = responseType + + def makeResponse(self): + if self.responseType == help_command_responseType.plain: + self.response_plain() + elif self.responseType == help_command_responseType.fancy: + self.response_fancy() + + def response_plain(self): + tempHelpText = "" + for line in self.command.help: + tempHelpText = tempHelpText + line + " " + self.response = "Command: " + self.commandName + " : " + self.helpText + return self.response + + def response_fancy(self): + tempHelpText = "" + for line in self.command.help: + tempHelpText = tempHelpText + line + "\n" + self.response = self.blockDecor + "Command: " + self.commandName + self.blockDecor + tempHelpText + self.blockDecor + return self.response + + + +Help_Module_ = Help_Module() + +if __name__ == "__main__": + testModule = Help_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/praxis-main.bat b/praxis-main.bat new file mode 100644 index 0000000..26ec40f --- /dev/null +++ b/praxis-main.bat @@ -0,0 +1,2 @@ +cd "c:\praxis" +python "c:/Praxis/main.py" \ No newline at end of file diff --git a/praxis-user.bat b/praxis-user.bat new file mode 100644 index 0000000..3ada4bb --- /dev/null +++ b/praxis-user.bat @@ -0,0 +1,2 @@ +cd "c:\praxis" +python "c:\praxis\user_module.py" \ No newline at end of file -- 2.45.2 From 9de4b3fabe1f5f19ec8adf96be828cd1bf7315da Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 11 Apr 2021 22:39:12 -0400 Subject: [PATCH 03/18] commented out old stuff --- utilities_script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities_script.py b/utilities_script.py index 22c9a75..fa77b76 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -35,9 +35,9 @@ def does_contain_OnlyNumbers(text): return isJustNumbers def rescale_value(value, min, max): - print("trying Rescale") + #print("trying Rescale") returnValue = (value - min) / (max - min) - print("got ", returnValue) + #print("got ", returnValue) return returnValue def get_dir(selected_dir): -- 2.45.2 From 5ccf36b1bda62994814177d1fbd3fcbbe375d848 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 11 Apr 2021 23:01:03 -0400 Subject: [PATCH 04/18] Expanded Help Command --- commands/implemented/command_help.py | 13 +++++++++++++ user_module.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/commands/implemented/command_help.py b/commands/implemented/command_help.py index 4b665fc..77160ab 100644 --- a/commands/implemented/command_help.py +++ b/commands/implemented/command_help.py @@ -18,6 +18,8 @@ class CommandChyron(AbstractCommand, metaclass=ABCMeta): self.help = ["This is a command to learn more about other commands.", "\nExample:","help \"COMMAND\""] + self.blockDecor = "\n================================================================\n" + def do_command(self, bot, user_message): tempBool = True if tempBool == True: @@ -30,6 +32,17 @@ class CommandChyron(AbstractCommand, metaclass=ABCMeta): returnMessage = helper.response bot.return_message(returnMessage) + elif i == 1: + commandsList = self.blockDecor + "Commands List:" + self.blockDecor + self.GetCommandsList(bot) + self.blockDecor + print(commandsList) + + def GetCommandsList(self, bot): + commandsList = "" + i = 0 + for cmd in bot.commands: + commandsList = commandsList + cmd + "\n" + + return commandsList def get_help(self): return self.help \ No newline at end of file diff --git a/user_module.py b/user_module.py index 4e904d0..45945dc 100644 --- a/user_module.py +++ b/user_module.py @@ -17,7 +17,7 @@ class User_Module(): self.MessageLog:list = [] def main(self): - print("\nWaiting on User input...") + print("\nWaiting on User input...\n") inputLoop = True while inputLoop: keyboardInput = input() -- 2.45.2 From d1d90b4cebd3eacc513eef6e1d38cca3d83df0d2 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 11 Apr 2021 23:05:23 -0400 Subject: [PATCH 05/18] fixed lights help --- commands/implemented/command_lights_rgb_color.py | 2 +- commands/implemented/command_lights_rgb_color_twitch.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index c53cbab..0ec7641 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -16,7 +16,7 @@ class CommandLights(AbstractCommand, metaclass=ABCMeta): def __init__(self): 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\""] + "\nExample:","lights \"SCENE\"","lights \"COLOR\"","lights \"R\" \"G\" \"B\"","lights \"1\" \"0.5\" \"0\""] 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 51025cb..a2b3652 100644 --- a/commands/implemented/command_lights_rgb_color_twitch.py +++ b/commands/implemented/command_lights_rgb_color_twitch.py @@ -16,7 +16,7 @@ class CommandLights(AbstractCommand, metaclass=ABCMeta): def __init__(self): 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\""] + "\nExample:","!lights \"SCENE\"","!lights \"COLOR\"","!lights \"R\" \"G\" \"B\"","!lights \"1\" \"0.5\" \"0\""] def do_command(self, bot, twitch_message): -- 2.45.2 From 08e712c085fe6d20b38cade13198d5d81b419b82 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 11 Apr 2021 23:27:03 -0400 Subject: [PATCH 06/18] Added User Module to Main --- config.py | 6 ++++-- main.py | 15 ++++++++++++++- run.bat | 1 - user_module.py | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) delete mode 100644 run.bat diff --git a/config.py b/config.py index 53e8eec..cd67c70 100644 --- a/config.py +++ b/config.py @@ -5,8 +5,8 @@ credentialsNickname = "praxis_bot" twitch_module: bool = False discord_module: bool = False - test_module: bool = False +user_module: bool = True autoJoin_TwitchChannels = ["thecuriousnerd"] whitelisted_TwitchPowerUsers = ["thecuriousnerd"] @@ -41,10 +41,12 @@ blockAll_TTS_URL_Discord = True autoEnabled_Discord_rgbLightControl = False +#User Module Configs +blockAll_TTS_URL_UserModule = True + #Chyron Module Configs chyronListSpaceCount = 25 - #Lights Module Configs colorParse_maxDigits = 4 diff --git a/main.py b/main.py index d0f72ac..f9a47c4 100644 --- a/main.py +++ b/main.py @@ -6,9 +6,10 @@ import time import twitch_script import discord_script - import test_module +import user_module + import utilities_script as utility import config as config @@ -19,6 +20,7 @@ import threading twitchModule_: twitch_script.Twitch_Module discordModule_: discord_script.Discord_Module testModule_: test_module.Test_Module +userModule_: user_module.User_Module credentials_manager: credentials.Credentials_Module @@ -55,6 +57,10 @@ def test_module_init(dbCert, Empty): #testModule_.dbCredential = dbCert testModule_.main() +def user_module_init(dbCert, Empty): + print("-init [USER Module]") + userModule_.dbCredential = dbCert + userModule_.main() def thread_main(): if not config.skip_splashScreen: @@ -63,12 +69,14 @@ def thread_main(): global twitchModule_ global discordModule_ global testModule_ + global userModule_ credentials_manager = credentials.Credentials_Module() twitchModule_ = twitch_script.Twitch_Module() discordModule_ = discord_script.Discord_Module() testModule_ = test_module.Test_Module() + userModule_ = user_module.User_Module() credentials_manager.load_credentials() dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, config.credentialsNickname) @@ -91,6 +99,11 @@ def thread_main(): threads.append(thread_) thread_.start() + if config.user_module == True: + thread_ = threading.Thread(target=user_module_init, args=(dbCert, None)) + threads.append(thread_) + thread_.start() + print("---Post Thread Creation Test---") for t in threads: t.join() diff --git a/run.bat b/run.bat deleted file mode 100644 index caee662..0000000 --- a/run.bat +++ /dev/null @@ -1 +0,0 @@ -python "c:/Praxis/main.py" \ No newline at end of file diff --git a/user_module.py b/user_module.py index 45945dc..7891130 100644 --- a/user_module.py +++ b/user_module.py @@ -25,7 +25,7 @@ class User_Module(): message.makeMessage(message=keyboardInput) if "exit" in keyboardInput: - print("Quitting User Module Interface...") + print("Quitting [User Module] Interface...") inputLoop = False break -- 2.45.2 From 5c4d34f5961e404dfa73382ceae5f4298bf873c0 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 13 Apr 2021 18:22:16 -0400 Subject: [PATCH 07/18] Create Dockerfile --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be856a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.8-buster + +WORKDIR /Praxis + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY . . + +CMD [ "python3", "main.py"] \ No newline at end of file -- 2.45.2 From d2fb4bb8abffe21a7241d85d2676f8204af756ba Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 14 Apr 2021 01:43:44 -0400 Subject: [PATCH 08/18] fixed typo --- chyron_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chyron_module.py b/chyron_module.py index d032ac4..670151a 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -16,7 +16,7 @@ class Chyron_Module(): self.addItem( "WeekDays", "► Weekdays: ", - "Daily Stream @ 12pm Noon EST") + "Daily Streams @ 12pm Noon EST") self.addItem( "FriSat", "► Friday & Saturday: ", -- 2.45.2 From 46de27aca858ecaa183c248d2502616e6ed61ae9 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 14 Apr 2021 02:45:37 -0400 Subject: [PATCH 09/18] updated readme --- Dockerfile | 2 +- README.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index be856a2..08421bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt COPY . . -CMD [ "python3", "main.py"] \ No newline at end of file +#CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file diff --git a/README.md b/README.md index 17afa01..ea0f62d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,18 @@ A chatbot to help with live stream production and effects. ___ +# Docker: + +## Docker Info: + +Uncomment the following line in the **Dockerfile** to have **main.py** start with the Docker Container + +`#CMD [ "python3", "main.py"]` + +To start the bot with **User_Module** activated use this. + +`docker exec -ti praxis python3 main.py` + # Credentials: ## Credentials Setup: -- 2.45.2 From cfd0b84872f0e0cd580d67956ad02cf85bce05d2 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 17:03:55 -0400 Subject: [PATCH 10/18] Docker Detection --- Dockerfile | 2 +- main.py | 11 +++++++---- user_module.py | 5 +++++ utilities_script.py | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08421bf..3f7084b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt COPY . . -#CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file +CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file diff --git a/main.py b/main.py index f9a47c4..e22f2e3 100644 --- a/main.py +++ b/main.py @@ -100,16 +100,19 @@ def thread_main(): thread_.start() if config.user_module == True: - thread_ = threading.Thread(target=user_module_init, args=(dbCert, None)) - threads.append(thread_) - thread_.start() + if utility.isRunningInDocker() == False: + config.user_module = False + thread_ = threading.Thread(target=user_module_init, args=(dbCert, None)) + threads.append(thread_) + thread_.start() print("---Post Thread Creation Test---") for t in threads: t.join() print("---Point of no return---") - input() + if utility.isRunningInDocker() == False: + input() diff --git a/user_module.py b/user_module.py index 7891130..3e7becc 100644 --- a/user_module.py +++ b/user_module.py @@ -9,6 +9,8 @@ from commands.command_base import AbstractCommand from cooldowns import Cooldown_Module +import utilities_script as utility + class User_Module(): def __init__(self): super().__init__() @@ -19,6 +21,9 @@ class User_Module(): def main(self): print("\nWaiting on User input...\n") inputLoop = True + if utility.isRunningInDocker() == False: + inputLoop = False + print("\nNo User's Input Allowed") while inputLoop: keyboardInput = input() message = UserMessage() diff --git a/utilities_script.py b/utilities_script.py index fa77b76..6bcf362 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -65,6 +65,12 @@ def contains_slur(input: str): print("<{ slur detected! }> ") return containsSlur +def isRunningInDocker(): + isD = os.getenv('ISDOCKER') + if isD is None: + return False + return isD == "cat" + def hard_shutdown(): current_system_pid = os.getpid() -- 2.45.2 From b1c810e525cc0a0278d50c2b17e2c538c55bb2d6 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 17:28:13 -0400 Subject: [PATCH 11/18] fixed indentation --- utilities_script.py | 86 ++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/utilities_script.py b/utilities_script.py index 6bcf362..fdf5a81 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -14,11 +14,11 @@ clearScreen = lambda: os.system('cls' if os.name == 'nt' else 'clear') urlMatcher = re.compile("(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))") def contains_url(input: str): - containsURL = re.search(urlMatcher, input.lower()) is not None - return containsURL + containsURL = re.search(urlMatcher, input.lower()) is not None + return containsURL def get_args(text: str) -> list: - return text.split(" ") + return text.split(" ") def does_contain_OnlyNumbers(text): isJustNumbers = False @@ -51,19 +51,19 @@ def get_dir(selected_dir): return dir def contains_slur(input: str): - containsSlur: bool = False - parsedMessage = input.split(" ") - for word in parsedMessage: - for slur in config.slurList: - if word.lower() == slur: - containsSlur = True - break - if containsSlur: + containsSlur: bool = False + parsedMessage = input.split(" ") + for word in parsedMessage: + for slur in config.slurList: + if word.lower() == slur: + containsSlur = True break - if containsSlur: - print("<{ slur detected! }> ") - return containsSlur + break + + if containsSlur: + print("<{ slur detected! }> ") + return containsSlur def isRunningInDocker(): isD = os.getenv('ISDOCKER') @@ -72,45 +72,45 @@ def isRunningInDocker(): return isD == "cat" def hard_shutdown(): - current_system_pid = os.getpid() + current_system_pid = os.getpid() - ThisSystem = psutil.Process(current_system_pid) - ThisSystem.terminate() + ThisSystem = psutil.Process(current_system_pid) + ThisSystem.terminate() def restart_self(): - #current_system_pid = os.getpid() - #os.startfile("python C:/praxis/main.py") - #subprocess.run("python C:/praxis/main.py") - #subprocess.call("python main.py", shell=True) - if platform.system() == 'Windows': - os.system('start cmd /k python main.py') - hard_shutdown() - if platform.system() == 'Linux': - os.system('xfce4-terminal -e "python main.py"') - hard_shutdown() + #current_system_pid = os.getpid() + #os.startfile("python C:/praxis/main.py") + #subprocess.run("python C:/praxis/main.py") + #subprocess.call("python main.py", shell=True) + if platform.system() == 'Windows': + os.system('start cmd /k python main.py') + hard_shutdown() + if platform.system() == 'Linux': + os.system('xfce4-terminal -e "python main.py"') + hard_shutdown() - #os.system('python twitch_script.py') - #os.system('python discord_script.py') + #os.system('python twitch_script.py') + #os.system('python discord_script.py') def restart_target(): - pass + pass def launch_target(inputScript: str): - cmd = "start cmd /k python " + inputScript - os.system(cmd) + cmd = "start cmd /k python " + inputScript + os.system(cmd) def splashScreen(): - if not config.skip_splashScreenClear: - clearScreen() - art.tprint("----------",font="slant") - art.tprint("Praxis Bot",font="graffiti") - art.tprint("----------",font="slant") - print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") - print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) - print("\n\n\n") - if not config.skip_splashScreenSleep: - time.sleep(3) + if not config.skip_splashScreenClear: + clearScreen() + art.tprint("----------",font="slant") + art.tprint("Praxis Bot",font="graffiti") + art.tprint("----------",font="slant") + print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") + print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) + print("\n\n\n") + if not config.skip_splashScreenSleep: + time.sleep(3) if __name__ == "__main__": - splashScreen() \ No newline at end of file + splashScreen() \ No newline at end of file -- 2.45.2 From c01418cebef5aed4818ffd9f954b2aaa5e038753 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 17:33:56 -0400 Subject: [PATCH 12/18] tts Docker Fix --- tts.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tts.py b/tts.py index 54790c0..116c990 100644 --- a/tts.py +++ b/tts.py @@ -6,13 +6,17 @@ import requests from gtts import gTTS from playsound import playsound +import utilities_script as utility import config streamLabsUrl = "https://streamlabs.com/polly/speak" def tts(inputText: str, *args): outpath = create_speech_file(inputText) - playsound(outpath) + if utility.isRunningInDocker() == False: + print("Docker Detected, skipping playsound()") + else: + playsound(outpath) def create_speech_gtts(input_text: str): -- 2.45.2 From b7e20c56029e8d7b03736c38cf0553cae6cb0710 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 18:04:10 -0400 Subject: [PATCH 13/18] Fixed TTS Bugs Fixed Discord TTS Config Bug Fixed Docker TTS playsound() --- config.py | 2 +- discord_script.py | 8 +++++++- tts.py | 3 ++- user_module.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index cd67c70..a30d345 100644 --- a/config.py +++ b/config.py @@ -30,8 +30,8 @@ block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to D blockAll_DiscordChannelsMessaging = False # Blocks the ability to send messages to Discord channels blockAll_DiscordPrivateMessaging = False # Private Messaging not yet implemented -selected_DiscordTTSChannels = ["431129571308339210"] autoEnabled_DiscordChannelsTTS = False +selected_DiscordTTSChannels = ["431129571308339210"] block_DiscordChannelsTTS = [""] # block supersedes the tts_enabled bool blockAll_DiscordChannelsTTS = False # blockAll supersedes the force bool and force list and tts_enabled bool force_DiscordChannelsTTS = [""] # force supersedes the block list diff --git a/discord_script.py b/discord_script.py index 28a212d..bba7c16 100644 --- a/discord_script.py +++ b/discord_script.py @@ -138,7 +138,13 @@ class Discord_Module(discord.Client): #print("isBlocked: " + str(isBlocked)) #print("isForced: " + str(isForced)) if (not await self.contains_slur(message)) and (await self.isTTS_URL_Enabled(message)): - if self.tts_enabled and not isBlocked and not config.blockAll_DiscordChannelsTTS or isForced or config.forceAll_DiscordChatChannelsTTS: + print(message.channel.id, message.channel.id, message.channel.id) + isMessageChannelInList = False + for TTS_C_id in config.selected_DiscordTTSChannels: + print(TTS_C_id) + if int(TTS_C_id) == int(message.channel.id): + isMessageChannelInList = True + if self.tts_enabled and (isMessageChannelInList) and not isBlocked and not config.blockAll_DiscordChannelsTTS or isForced or config.forceAll_DiscordChatChannelsTTS: if not message.content.startswith('!'): text_to_say: str = "%s says, %s" % (message.author.display_name, message.content) channel_text = "%s user msg" % message.channel diff --git a/tts.py b/tts.py index 116c990..6e026aa 100644 --- a/tts.py +++ b/tts.py @@ -13,9 +13,10 @@ streamLabsUrl = "https://streamlabs.com/polly/speak" def tts(inputText: str, *args): outpath = create_speech_file(inputText) - if utility.isRunningInDocker() == False: + if utility.isRunningInDocker() == True: print("Docker Detected, skipping playsound()") else: + print("Playing Sound...") playsound(outpath) diff --git a/user_module.py b/user_module.py index 3e7becc..823b2ce 100644 --- a/user_module.py +++ b/user_module.py @@ -21,7 +21,7 @@ class User_Module(): def main(self): print("\nWaiting on User input...\n") inputLoop = True - if utility.isRunningInDocker() == False: + if utility.isRunningInDocker() == True: inputLoop = False print("\nNo User's Input Allowed") while inputLoop: -- 2.45.2 From 897f1c367f5ad4a8d4d513e04b60b356e4c995d1 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 18:43:17 -0400 Subject: [PATCH 14/18] Readme Update --- README.md | 7 ++----- main.py | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ea0f62d..6e82fda 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,10 @@ ___ ## Docker Info: -Uncomment the following line in the **Dockerfile** to have **main.py** start with the Docker Container +Currently to build the container you need to run the following command otherwise you get the error ***"TERM environment variable not set."*** -`#CMD [ "python3", "main.py"]` +`docker create -t -e ISDOCKER=cat --name praxis praxis` -To start the bot with **User_Module** activated use this. - -`docker exec -ti praxis python3 main.py` # Credentials: diff --git a/main.py b/main.py index e22f2e3..3040fcd 100644 --- a/main.py +++ b/main.py @@ -36,8 +36,9 @@ def twitch_module_init(dbCert, twitchCert): twitchModule_.tts_enabled = config.autoEnabled_TwitchChannelsTTS twitchModule_.whitelisted_users = config.whitelisted_TwitchPowerUsers + print("[TWITCH Module]>", "Loading Channels...") for twitchChannel in config.autoJoin_TwitchChannels: - print("joining channel function") + print("joining twitch channel:", twitchChannel) twitchModule_.join_channel(None, twitchChannel) def discord_module_init(dbCert, discordCert): -- 2.45.2 From e34b3af255542cd67b142b4fd885a4ea109eb1a3 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 18:45:07 -0400 Subject: [PATCH 15/18] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6e82fda..496b60b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ___ ## Docker Info: Currently to build the container you need to run the following command otherwise you get the error ***"TERM environment variable not set."*** +Docker Compose will also fail and result in the same error. `docker create -t -e ISDOCKER=cat --name praxis praxis` -- 2.45.2 From c735dd8664e62af3cf50e6ea4f7f6d007ee6846d Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 18:52:08 -0400 Subject: [PATCH 16/18] Fix --- README.md | 6 ++---- main.py | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 496b60b..c448b9b 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,9 @@ ___ ## Docker Info: -Currently to build the container you need to run the following command otherwise you get the error ***"TERM environment variable not set."*** -Docker Compose will also fail and result in the same error. - -`docker create -t -e ISDOCKER=cat --name praxis praxis` +To start the bot with **User_Module** activated use this. +`docker exec -ti praxis python3 main.py` # Credentials: diff --git a/main.py b/main.py index 3040fcd..98c6f60 100644 --- a/main.py +++ b/main.py @@ -64,6 +64,8 @@ def user_module_init(dbCert, Empty): userModule_.main() def thread_main(): + if utility.isRunningInDocker() == True: + print("<[DOCKER Detected]>") if not config.skip_splashScreen: utility.splashScreen() global credentials_manager -- 2.45.2 From 5959f44bf9ff0160cf12143d5cee3943b9f19348 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 19:09:01 -0400 Subject: [PATCH 17/18] Fixed Readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c448b9b..30a4c54 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ ___ ## Docker Info: +Currently to build the container run the following command. + +`docker create -p 2501:2501 -e ISDOCKER=cat --name praxistest5 praxis` + To start the bot with **User_Module** activated use this. `docker exec -ti praxis python3 main.py` -- 2.45.2 From a41b20e15cb71557701bde631115fbc689aece23 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 19:33:07 -0400 Subject: [PATCH 18/18] Fixed Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30a4c54..43acb28 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ___ Currently to build the container run the following command. -`docker create -p 2501:2501 -e ISDOCKER=cat --name praxistest5 praxis` +`docker create -p 2501:2501 -e ISDOCKER=cat --name praxis praxis` To start the bot with **User_Module** activated use this. -- 2.45.2