From 0e1dc8b05b125ac56e42de20b1a6e31eefca4e11 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 21 Apr 2021 19:47:12 -0400 Subject: [PATCH] Added v2 lights --- commands/implemented/Command_lights_v2.py | 75 +++++++++++++++++++++++ commands/implemented/Command_roll_v2.py | 4 +- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 commands/implemented/Command_lights_v2.py diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py new file mode 100644 index 0000000..ccde22b --- /dev/null +++ b/commands/implemented/Command_lights_v2.py @@ -0,0 +1,75 @@ +from abc import ABCMeta + +import lights_module +from commands.command_base import AbstractCommand + +import utilities_script as utility + +class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): + """ + this is the test command. + """ + command = "!lights" + + def __init__(self): + super().__init__(Command_lights_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 = "" + + tempBool = True + if tempBool == True: + LightModule = lights_module.Lights_Module() + LightModule.main() + #bot.return_message("\nRGB Command Detected!") + tempFix = command + " " + rest + + tempParsedMessage = tempFix.split(" ") + sceneCommand = False + if (len(tempParsedMessage)) > 2: + #bot.return_message("RGB Command!") + rgb_r = float(tempParsedMessage[1]) + rgb_g = float(tempParsedMessage[2]) + rgb_b = float(tempParsedMessage[3]) + xy_result = LightModule.rgb_to_xy(rgb_r, rgb_g, rgb_b) + #bot.return_message("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + #bot.return_message("sent color to [Lights_Module]") + else: + if "stream" in tempParsedMessage: + sceneCommand = True + LightModule.bridge_.run_scene("Downstairs", "Stream") + elif "normal" in tempParsedMessage: + sceneCommand = True + LightModule.bridge_.run_scene("Downstairs", "Bright") + elif "haxor" in tempParsedMessage: + sceneCommand = True + LightModule.bridge_.run_scene("Downstairs", "hacker vibes") + elif "off" in tempParsedMessage: + sceneCommand = True + LightModule.bridge_.set_group("Downstairs", "on", False) + elif "on" in tempParsedMessage: + sceneCommand = True + LightModule.bridge_.set_group("Downstairs", "on", True) + elif "ravemode" in tempParsedMessage: + sceneCommand = True + LightModule.raveMode() + else: + #bot.return_message("Color Command!") + xy_result = LightModule.color_string_parser(tempParsedMessage) + #bot.return_message("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + #bot.return_message("sent color to [Lights_Module]") + + #if sceneCommand == True: + #bot.return_message("Scene Command!") + + returnString = user + " changed the light's color!" + + return returnString + + def get_help(self): + return self.help \ No newline at end of file diff --git a/commands/implemented/Command_roll_v2.py b/commands/implemented/Command_roll_v2.py index d8928f1..a174567 100644 --- a/commands/implemented/Command_roll_v2.py +++ b/commands/implemented/Command_roll_v2.py @@ -5,14 +5,14 @@ from commands.command_base import AbstractCommand import random import utilities_script as utility -class Command_test_v2(AbstractCommand, metaclass=ABCMeta): +class Command_roll_v2(AbstractCommand, metaclass=ABCMeta): """ this is the test command. """ command = "!roll" def __init__(self): - super().__init__(Command_test_v2.command, n_args=1, command_type=AbstractCommand.CommandType.Ver2) + super().__init__(Command_roll_v2.command, n_args=1, command_type=AbstractCommand.CommandType.Ver2) self.help = ["This will roll dice, based on your inputs.", "\nExample:","roll \"d20\"", "roll \"1D20+5\"", "roll \"10df\"", "roll \"10Df+3\""] self.isCommandEnabled = True