From 2c12e40ca20874b3372aa6bca7945c86a2646a51 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 30 Apr 2021 02:16:01 -0400 Subject: [PATCH 1/5] initial commit --- commands/implemented/Command_chyron_v2.py | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 commands/implemented/Command_chyron_v2.py diff --git a/commands/implemented/Command_chyron_v2.py b/commands/implemented/Command_chyron_v2.py new file mode 100644 index 0000000..b49d5cc --- /dev/null +++ b/commands/implemented/Command_chyron_v2.py @@ -0,0 +1,64 @@ +from abc import ABCMeta + +from commands.command_base import AbstractCommand + +from json import loads +from urllib.parse import urlencode +import requests + +import config + +import chyron_module + +import os +import praxis_logging +praxis_logger_obj = praxis_logging.praxis_logger() +praxis_logger_obj.init(os.path.basename(__file__)) +praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) + +class Command_chyron_v2(AbstractCommand, metaclass=ABCMeta): + """ + this is the test command. + """ + command = "!chyron" + + def __init__(self): + super().__init__(Command_chyron_v2.command, n_args=1, command_type=AbstractCommand.CommandType.Ver2) + 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, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): + returnString = "" + praxis_logger_obj.log("\n Command>: " + command + rest) + + for name in config.adminUsers_List: + print(name) + tempName = user.lower() + if name == tempName: + returnString = user + " has updated the chyron!" + temp = chyron_module.Chyron_Module() + temp.main(rest) + + + return returnString + + def send_Lights_Command(self, username, light_group, command, rest): + # todo need to url-escape command and rest + params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) + #standalone_lights + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params + resp = requests.get(url) + if resp.status_code == 200: + print("Got the following message: %s" % resp.text) + data = loads(resp.text) + msg = data['message'] + if msg is not None: + return msg + # todo send to logger and other relevent services + else: + # todo handle failed requests + return None + + def get_help(self): + return self.help \ No newline at end of file -- 2.45.2 From 1eee312407e269b43c0a2e9daf3e2c46634c3bfd Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 30 Apr 2021 02:18:55 -0400 Subject: [PATCH 2/5] Update standalone_lights.py --- standalone_lights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standalone_lights.py b/standalone_lights.py index dc47ab6..2e26541 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -19,7 +19,7 @@ praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) api = flask.Flask(__name__) # enable/disable this to get web pages of crashes returned -api.config["DEBUG"] = True +api.config["DEBUG"] = False class Lights_Module(): def __init__(self): -- 2.45.2 From 5d1c442c29c9919abb27b2f98d8be7c894793488 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 30 Apr 2021 11:48:29 -0400 Subject: [PATCH 3/5] basic command --- commands/implemented/Command_chyron_v2.py | 7 +++++-- standalone_channelrewards.py | 2 +- standalone_command.py | 2 +- standalone_tts_core.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/implemented/Command_chyron_v2.py b/commands/implemented/Command_chyron_v2.py index b49d5cc..d9e790d 100644 --- a/commands/implemented/Command_chyron_v2.py +++ b/commands/implemented/Command_chyron_v2.py @@ -37,8 +37,11 @@ class Command_chyron_v2(AbstractCommand, metaclass=ABCMeta): tempName = user.lower() if name == tempName: returnString = user + " has updated the chyron!" - temp = chyron_module.Chyron_Module() - temp.main(rest) + chyron_ = chyron_module.Chyron_Module() + chyron_.main(rest) + chyron_.chyron_stringUpdater() + chyron_.updateChyronFile() + returnString = chyron_.chyron_computedString return returnString diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index ebed9e5..64b9219 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -12,7 +12,7 @@ praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) api = flask.Flask(__name__) # enable/disable this to get web pages of crashes returned -api.config["DEBUG"] = True +api.config["DEBUG"] = False loadedRewards = {} diff --git a/standalone_command.py b/standalone_command.py index 24ad1a4..5333510 100644 --- a/standalone_command.py +++ b/standalone_command.py @@ -12,7 +12,7 @@ praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) api = flask.Flask(__name__) # enable/disable this to get web pages of crashes returned -api.config["DEBUG"] = True +api.config["DEBUG"] = False loadedCommands = {} diff --git a/standalone_tts_core.py b/standalone_tts_core.py index 7a051bf..1cca22b 100644 --- a/standalone_tts_core.py +++ b/standalone_tts_core.py @@ -14,7 +14,7 @@ praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) api = flask.Flask(__name__) # enable/disable this to get web pages of crashes returned -api.config["DEBUG"] = True +api.config["DEBUG"] = False def init(): praxis_logger_obj.log("init stuff") -- 2.45.2 From eb67d07b74d5f1f21864df2a76af4bff91de2d59 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 30 Apr 2021 13:58:24 -0400 Subject: [PATCH 4/5] working version --- commands/implemented/Command_chyron_v2.py | 21 +++++++++++++-------- standalone_discord_script.py | 8 +++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/commands/implemented/Command_chyron_v2.py b/commands/implemented/Command_chyron_v2.py index d9e790d..ece7e21 100644 --- a/commands/implemented/Command_chyron_v2.py +++ b/commands/implemented/Command_chyron_v2.py @@ -29,19 +29,24 @@ class Command_chyron_v2(AbstractCommand, metaclass=ABCMeta): self.isCommandEnabled = True def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): - returnString = "" - praxis_logger_obj.log("\n Command>: " + command + rest) + returnString = "trying to update chyron..." + praxis_logger_obj.log("\n Command>: " + command + " " + rest) for name in config.adminUsers_List: print(name) tempName = user.lower() if name == tempName: - returnString = user + " has updated the chyron!" - chyron_ = chyron_module.Chyron_Module() - chyron_.main(rest) - chyron_.chyron_stringUpdater() - chyron_.updateChyronFile() - returnString = chyron_.chyron_computedString + + try: + returnString = user + " has updated the chyron!" + chyron_ = chyron_module.Chyron_Module() + + chyron_.main(rest) + chyron_.chyron_stringUpdater() + chyron_.updateChyronFile() + except: + returnString = user + " has attempted to update the chyron but an error may have occurred!" + #returnString = chyron_.chyron_computedString return returnString diff --git a/standalone_discord_script.py b/standalone_discord_script.py index 723fc86..52378bb 100644 --- a/standalone_discord_script.py +++ b/standalone_discord_script.py @@ -111,7 +111,13 @@ class Discord_Module(discord.Client): async def exec_command(self, realMessage: discord.Message, command: str, rest: str): # todo need to url-escape command and rest - params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, 'user_name': realMessage.author.mention, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) + params = urlencode( + {'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, + 'user_name': realMessage.author.mention, + 'command_name': command, + 'rest': rest, + 'bonus_data': realMessage}) + url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: -- 2.45.2 From 5be420a2d1d889b71369d122a539c5c3e3c7157e Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 30 Apr 2021 14:16:01 -0400 Subject: [PATCH 5/5] Added Text Command --- commands/implemented/Command_chyron_v2.py | 4 +- commands/implemented/Command_text_v2.py | 100 ++++++++++++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 commands/implemented/Command_text_v2.py diff --git a/commands/implemented/Command_chyron_v2.py b/commands/implemented/Command_chyron_v2.py index ece7e21..7eed4be 100644 --- a/commands/implemented/Command_chyron_v2.py +++ b/commands/implemented/Command_chyron_v2.py @@ -24,8 +24,8 @@ class Command_chyron_v2(AbstractCommand, metaclass=ABCMeta): def __init__(self): super().__init__(Command_chyron_v2.command, n_args=1, command_type=AbstractCommand.CommandType.Ver2) - 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.help = ["The chyron string can be generated and updated with this command.", + "\nExample:","chyron update \"RIGHTNOW\""] self.isCommandEnabled = True def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): diff --git a/commands/implemented/Command_text_v2.py b/commands/implemented/Command_text_v2.py new file mode 100644 index 0000000..d79451e --- /dev/null +++ b/commands/implemented/Command_text_v2.py @@ -0,0 +1,100 @@ +from abc import ABCMeta + +from commands.command_base import AbstractCommand + +from json import loads +from urllib.parse import urlencode +import requests + +import config + +import tempText_Module + +import os +import praxis_logging +praxis_logger_obj = praxis_logging.praxis_logger() +praxis_logger_obj.init(os.path.basename(__file__)) +praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) + +class Command_Text_v2(AbstractCommand, metaclass=ABCMeta): + """ + this is the text command. + """ + command = "!text" + + def __init__(self): + super().__init__(Command_Text_v2.command, n_args=1, command_type=AbstractCommand.CommandType.Ver2) + self.help = ["The temptext string can be generated and updated with this command.", + "\nExample:","temptext update \"Name\" \"Title\" \"Content\""] + self.isCommandEnabled = True + + def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): + returnString = "trying to update text..." + praxis_logger_obj.log("\n Command>: " + command + " " + rest) + + for name in config.adminUsers_List: + print(name) + tempName = user.lower() + if name == tempName: + + #try: + # returnString = user + " has updated the text!" + # tempText_ = tempText_Module.tempText_Module() + # tempText_.main() + # testItem = tempText_Module.tempTextItem("testy","► ", rest) + # tempText_.makeItem(testItem) + # tempText_.update_tempTextFiles() + #except: + # returnString = user + " has attempted to update the text but an error may have occurred!" + #returnString = chyron_.chyron_computedString + + + bandaid_string:str = command + " " + rest + tempParsedMessage = bandaid_string.split(" ") + i = len(tempParsedMessage) + if i > 2: + if "update" in tempParsedMessage[1]: + tempTextModule:tempText_Module.tempText_Module = tempText_Module.tempText_Module() + tempText:tempText_Module.tempTextItem = tempText_Module.tempTextItem() + if i > 2: + newText = "" + counter = 0 + for word in tempParsedMessage: + if counter > 2: + newText = newText + word + " " + counter = counter + 1 + newText = newText[:-1] # Gets rid of last space + #print(tempParsedMessage[2], newText) + tempText.itemName = tempParsedMessage[2] + tempText.itemContent = newText + tempTextModule.makeItem(tempText) + else: + returnString = user + " has attempted to update the text but an error may have occurred!" + #tempTextModule.update_tempTextFiles() + + returnMessage = user + " has updated the text!" + returnString = returnMessage + + + + return returnString + + def send_Lights_Command(self, username, light_group, command, rest): + # todo need to url-escape command and rest + params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) + #standalone_lights + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params + resp = requests.get(url) + if resp.status_code == 200: + print("Got the following message: %s" % resp.text) + data = loads(resp.text) + msg = data['message'] + if msg is not None: + return msg + # todo send to logger and other relevent services + else: + # todo handle failed requests + return None + + def get_help(self): + return self.help \ No newline at end of file -- 2.45.2