From 533d69787f61a2455079f4f8bf97b26600e37068 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 5 Apr 2021 14:42:31 -0400 Subject: [PATCH 01/26] I think it works --- commands/implemented/command_roll_discord.py | 152 +++++++++++++++---- 1 file changed, 125 insertions(+), 27 deletions(-) diff --git a/commands/implemented/command_roll_discord.py b/commands/implemented/command_roll_discord.py index 4f89c74..f91a209 100644 --- a/commands/implemented/command_roll_discord.py +++ b/commands/implemented/command_roll_discord.py @@ -28,6 +28,72 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): #await discord_message.channel.send("Rolling Dice...") print("Rolling Dice...") + if "f" in discord_message.content.lower(): + await diceRoll = self.roll(2, discord_message) + else: + await diceRoll = self.roll(1, discord_message) + + #======================== + #Old Code Below + #======================== + + # temp_preParsedMessage = discord_message.content.split("+") + + # tempParsedMessage = temp_preParsedMessage[0].split(" ") + # temp_dice_stmt: str = tempParsedMessage[1] + # parsedMessage = temp_dice_stmt.lower().split("d") + + # loopBool: bool = False + # if parsedMessage[0] != "": + # loopBool = True + # if loopBool == True: + # if int(parsedMessage[0]) == 1: + # loopBool = False + + # # If roll is in xdx+x format + # if loopBool == True: + # rolls: list = [] + # for x in range(int(parsedMessage[0])): + # rolls.append(random.randint(1, int(parsedMessage[1]))) + + # rollTotal = 0 + # for roll in rolls: + # rollTotal = rollTotal + roll + # diceRoll = diceRoll + str(roll) + ", " + # diceRoll = diceRoll[:-2] # This removes the last two characters in the string + + # if len(temp_preParsedMessage) == 2: + # diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + # rollTotal + int(temp_preParsedMessage[1])) + # else: + # diceRoll = diceRoll + " = " + str(rollTotal) + # # If roll is in dx+x format + # if loopBool == False: + # roll: int = random.randint(1, int(parsedMessage[1])) + + # if len(temp_preParsedMessage) == 2: + # diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + # roll + int(temp_preParsedMessage[1])) + # else: + # diceRoll = str(roll) + + # diceRoll = discord_message.author.mention + " rolled: " + diceRoll + # print(diceRoll) + + #======================== + #Old Code Above + #======================== + + + + await bot.send_message(discord_message, diceRoll) + #await discord_message.channel.send(diceRoll) + + async def roll(self, roll_type, discord_message: discord.Message): + switch = { + 1: "Standard", + 2: "Fudge Dice" + } temp_preParsedMessage = discord_message.content.split("+") tempParsedMessage = temp_preParsedMessage[0].split(" ") @@ -41,34 +107,66 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): if int(parsedMessage[0]) == 1: loopBool = False - # If roll is in xdx+x format - if loopBool == True: - rolls: list = [] - for x in range(int(parsedMessage[0])): - rolls.append(random.randint(1, int(parsedMessage[1]))) + if roll_type == 1: + # If roll is in xdx+x format + if loopBool == True: + rolls: list = [] + for x in range(int(parsedMessage[0])): + rolls.append(random.randint(1, int(parsedMessage[1]))) # This is the roller - rollTotal = 0 - for roll in rolls: - rollTotal = rollTotal + roll - diceRoll = diceRoll + str(roll) + ", " - diceRoll = diceRoll[:-2] # This removes the last two characters in the string + rollTotal = 0 + for roll in rolls: + rollTotal = rollTotal + roll + diceRoll = diceRoll + str(roll) + ", " + diceRoll = diceRoll[:-2] # This removes the last two characters in the string - if len(temp_preParsedMessage) == 2: - diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( - rollTotal + int(temp_preParsedMessage[1])) - else: - diceRoll = diceRoll + " = " + str(rollTotal) - # If roll is in dx+x format - if loopBool == False: - roll: int = random.randint(1, int(parsedMessage[1])) + if len(temp_preParsedMessage) == 2: + diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + rollTotal + int(temp_preParsedMessage[1])) + else: + diceRoll = diceRoll + " = " + str(rollTotal) + # If roll is in dx+x format + if loopBool == False: + roll: int = random.randint(1, int(parsedMessage[1])) # This is the roller - if len(temp_preParsedMessage) == 2: - diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( - roll + int(temp_preParsedMessage[1])) - else: - diceRoll = str(roll) + if len(temp_preParsedMessage) == 2: + diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + roll + int(temp_preParsedMessage[1])) + else: + diceRoll = str(roll) - diceRoll = discord_message.author.mention + " rolled: " + diceRoll - print(diceRoll) - await bot.send_message(discord_message, diceRoll) - #await discord_message.channel.send(diceRoll) + diceRoll = discord_message.author.mention + " rolled: " + diceRoll + print(diceRoll) + + if roll_type == 2: + # If roll is in xdx+x format + if loopBool == True: + rolls: list = [] + for x in range(int(parsedMessage[0])): + rolls.append(random.randint(1, 3)) # This is the roller + + rollTotal = 0 + for roll in rolls: + rollTotal = rollTotal + roll + diceRoll = diceRoll + str(roll) + ", " + diceRoll = diceRoll[:-2] # This removes the last two characters in the string + + if len(temp_preParsedMessage) == 2: + diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + rollTotal + int(temp_preParsedMessage[1])) + else: + diceRoll = diceRoll + " = " + str(rollTotal) + # If roll is in dx+x format + if loopBool == False: + roll: int = random.randint(1, 3) # This is the roller + + if len(temp_preParsedMessage) == 2: + diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + roll + int(temp_preParsedMessage[1])) + else: + diceRoll = str(roll) + + diceRoll = discord_message.author.mention + " rolled: " + diceRoll + print(diceRoll) + + return diceRoll From fee939331fa02c85cc49f093713518fb024a1db7 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 13:17:56 -0400 Subject: [PATCH 02/26] Fixed Command --- commands/implemented/command_roll.py | 154 +++++++++++++++---- commands/implemented/command_roll_discord.py | 10 +- 2 files changed, 133 insertions(+), 31 deletions(-) diff --git a/commands/implemented/command_roll.py b/commands/implemented/command_roll.py index 48a87cb..7f1549d 100644 --- a/commands/implemented/command_roll.py +++ b/commands/implemented/command_roll.py @@ -21,6 +21,72 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): bot.send_message("Rolling Dice...") print("Rolling Dice...") + if ("f") in twitch_message.text.lower(): + diceRoll = self.roll(2, twitch_message) + else: + diceRoll = self.roll(1, twitch_message) + + #======================== + #Old Code Below + #======================== + + # temp_preParsedMessage = twitch_message.text.split("+") + + # tempParsedMessage = temp_preParsedMessage[0].split(" ") + # temp_dice_stmt: str = tempParsedMessage[1] + # parsedMessage = temp_dice_stmt.lower().split("d") + + # loopBool: bool = False + # if parsedMessage[0] != "": + # loopBool = True + # if loopBool == True: + # if int(parsedMessage[0]) == 1: + # loopBool = False + + # # If roll is in xdx+x format + # if loopBool == True: + # rolls: list = [] + # for x in range(int(parsedMessage[0])): + # rolls.append(random.randint(1, int(parsedMessage[1]))) + + # rollTotal = 0 + # for roll in rolls: + # rollTotal = rollTotal + roll + # diceRoll = diceRoll + str(roll) + ", " + # diceRoll = diceRoll[:-2] # This removes the last two characters in the string + + # if len(temp_preParsedMessage) == 2: + # diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + # rollTotal + int(temp_preParsedMessage[1])) + # else: + # diceRoll = diceRoll + " = " + str(rollTotal) + # # If roll is in dx+x format + # if loopBool == False: + # roll: int = random.randint(1, int(parsedMessage[1])) + + # if len(temp_preParsedMessage) == 2: + # diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + # roll + int(temp_preParsedMessage[1])) + # else: + # diceRoll = str(roll) + + # diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll + # print(diceRoll) + + + #======================== + #Old Code Above + #======================== + + bot.send_message(diceRoll) + + + def roll(self, roll_type, twitch_message): + diceRoll = "" + switch = { + 1: "Standard", + 2: "Fate Dice" + } temp_preParsedMessage = twitch_message.text.split("+") tempParsedMessage = temp_preParsedMessage[0].split(" ") @@ -34,33 +100,69 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): if int(parsedMessage[0]) == 1: loopBool = False - # If roll is in xdx+x format - if loopBool == True: - rolls: list = [] - for x in range(int(parsedMessage[0])): - rolls.append(random.randint(1, int(parsedMessage[1]))) + if roll_type == 1: + # If roll is in xdx+x format + if loopBool == True: + rolls: list = [] + for x in range(int(parsedMessage[0])): + rolls.append(random.randint(1, int(parsedMessage[1]))) # This is the roller - rollTotal = 0 - for roll in rolls: - rollTotal = rollTotal + roll - diceRoll = diceRoll + str(roll) + ", " - diceRoll = diceRoll[:-2] # This removes the last two characters in the string + rollTotal = 0 + for roll in rolls: + rollTotal = rollTotal + roll + diceRoll = diceRoll + str(roll) + ", " + diceRoll = diceRoll[:-2] # This removes the last two characters in the string - if len(temp_preParsedMessage) == 2: - diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( - rollTotal + int(temp_preParsedMessage[1])) - else: - diceRoll = diceRoll + " = " + str(rollTotal) - # If roll is in dx+x format - if loopBool == False: - roll: int = random.randint(1, int(parsedMessage[1])) + if len(temp_preParsedMessage) == 2: + diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + rollTotal + int(temp_preParsedMessage[1])) + else: + diceRoll = diceRoll + " = " + str(rollTotal) + # If roll is in dx+x format + if loopBool == False: + roll: int = random.randint(1, int(parsedMessage[1])) # This is the roller - if len(temp_preParsedMessage) == 2: - diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( - roll + int(temp_preParsedMessage[1])) - else: - diceRoll = str(roll) + if len(temp_preParsedMessage) == 2: + diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + roll + int(temp_preParsedMessage[1])) + else: + diceRoll = str(roll) - diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll - print(diceRoll) - bot.send_message(diceRoll) \ No newline at end of file + diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll + print(diceRoll) + + if roll_type == 2: + + print("fate Rolling....") + # !roll 4df + # If roll is in xdx+x format + if loopBool == True: + rolls: list = [] + for x in range(int(parsedMessage[0])): + rolls.append(random.randint(-1, 1)) # This is the roller + + rollTotal = 0 + for roll in rolls: + rollTotal = rollTotal + roll + diceRoll = diceRoll + str(roll) + ", " + diceRoll = diceRoll[:-2] # This removes the last two characters in the string + + if len(temp_preParsedMessage) == 2: + diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str( + rollTotal + int(temp_preParsedMessage[1])) + else: + diceRoll = diceRoll + " = " + str(rollTotal) + # If roll is in dx+x format + if loopBool == False: + roll: int = random.randint(-1, 1) # This is the roller + + if len(temp_preParsedMessage) == 2: + diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( + roll + int(temp_preParsedMessage[1])) + else: + diceRoll = str(roll) + + diceRoll = "@" + twitch_message.sender + " fate rolled: " + diceRoll + print(diceRoll) + + return diceRoll diff --git a/commands/implemented/command_roll_discord.py b/commands/implemented/command_roll_discord.py index f91a209..86244ea 100644 --- a/commands/implemented/command_roll_discord.py +++ b/commands/implemented/command_roll_discord.py @@ -28,10 +28,10 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): #await discord_message.channel.send("Rolling Dice...") print("Rolling Dice...") - if "f" in discord_message.content.lower(): - await diceRoll = self.roll(2, discord_message) + if ("f") in discord_message.content.lower(): + diceRoll = await self.roll(2, discord_message) else: - await diceRoll = self.roll(1, discord_message) + diceRoll = await self.roll(1, discord_message) #======================== #Old Code Below @@ -92,7 +92,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): async def roll(self, roll_type, discord_message: discord.Message): switch = { 1: "Standard", - 2: "Fudge Dice" + 2: "Fate Dice" } temp_preParsedMessage = discord_message.content.split("+") @@ -166,7 +166,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): else: diceRoll = str(roll) - diceRoll = discord_message.author.mention + " rolled: " + diceRoll + diceRoll = discord_message.author.mention + " fate rolled: " + diceRoll print(diceRoll) return diceRoll From 381882eda9ca43acbbd81131064a6b63b17cd49f Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 14:17:24 -0400 Subject: [PATCH 03/26] group & light detection --- lights_module.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lights_module.py diff --git a/lights_module.py b/lights_module.py new file mode 100644 index 0000000..aa53036 --- /dev/null +++ b/lights_module.py @@ -0,0 +1,54 @@ +import phue +from phue import Bridge + +import credentials +import config + +class Lights_Modules(): + def __init__(self): + super().__init__() + + def main(self): + print("Starting up Lights_Modules....") + b = Bridge('192.168.191.146') + b.connect + + b.get_api() + + light_list = b.lights + group_list:list = [] + groups = b.get_group() + groupCount = 0 + + print("\n -Listing Lights...") + for l in light_list: + print(l.name) + print("\n -Counting Groups...") + for g in groups: + print(g) + groupCount = int(g) + + + for gc in range(groupCount): + try: + #print(gc) + group = b.get_group(gc ,'name') + print(group) + #group_list.append(group) + print(" --done adding") + except: + print(" --adding failed") + + + print("\n finished doing the thing") + + +if __name__ == "__main__": + testModule = Lights_Modules() + + credentials_manager = credentials.Credentials_Module() + credentials_manager.load_credentials() + #testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname) + #testModule.discordCredential = credentials_manager.find_Discord_Credential(config.credentialsNickname) + + testModule.main() \ No newline at end of file From 1c4d5d5b014682d747ce10fd3613c237bfa455d1 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 14:38:49 -0400 Subject: [PATCH 04/26] Basic Control --- lights_module.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lights_module.py b/lights_module.py index aa53036..13c8811 100644 --- a/lights_module.py +++ b/lights_module.py @@ -31,7 +31,7 @@ class Lights_Modules(): for gc in range(groupCount): try: - #print(gc) + print("group n:" + str(gc)) group = b.get_group(gc ,'name') print(group) #group_list.append(group) @@ -39,8 +39,41 @@ class Lights_Modules(): except: print(" --adding failed") + #b.set_group(18, "bri", 254) #This is max Brightness + #b.set_group(18, "on", True) #This is will turn ON + xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy + b.set_group(18, "xy", xy_result) #This will make the lights in the group turn blue - print("\n finished doing the thing") + print("\n finished doing the things") + + + + def rgb_to_xy(self, red, green, blue): + """ conversion of RGB colors to CIE1931 XY colors + Formulas implemented from: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d + Args: + red (float): a number between 0.0 and 1.0 representing red in the RGB space + green (float): a number between 0.0 and 1.0 representing green in the RGB space + blue (float): a number between 0.0 and 1.0 representing blue in the RGB space + Returns: + xy (list): x and y + """ + # gamma correction + red = pow((red + 0.055) / (1.0 + 0.055), 2.4) if red > 0.04045 else (red / 12.92) + green = pow((green + 0.055) / (1.0 + 0.055), 2.4) if green > 0.04045 else (green / 12.92) + blue = pow((blue + 0.055) / (1.0 + 0.055), 2.4) if blue > 0.04045 else (blue / 12.92) + + # convert rgb to xyz + x = red * 0.649926 + green * 0.103455 + blue * 0.197109 + y = red * 0.234327 + green * 0.743075 + blue * 0.022598 + z = green * 0.053077 + blue * 1.035763 + + # convert xyz to xy + x = x / (x + y + z) + y = y / (x + y + z) + + # TODO check color gamut if known + return [x, y] if __name__ == "__main__": From e4f185678be421ac3b04642737f35c481760de5b Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 15:19:46 -0400 Subject: [PATCH 05/26] Added Rave Function --- lights_module.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lights_module.py b/lights_module.py index 13c8811..3e78f60 100644 --- a/lights_module.py +++ b/lights_module.py @@ -1,6 +1,9 @@ +from time import sleep import phue from phue import Bridge +import random + import credentials import config @@ -42,7 +45,16 @@ class Lights_Modules(): #b.set_group(18, "bri", 254) #This is max Brightness #b.set_group(18, "on", True) #This is will turn ON xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy - b.set_group(18, "xy", xy_result) #This will make the lights in the group turn blue + b.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue + + # The Following will make a rave + for rave in range(2000): + rgb_r = random.random() + rgb_g = random.random() + rgb_b = random.random() + xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy + b.set_group(16, "xy", xy_result) + sleep(0.5) print("\n finished doing the things") From 114b19373e7ebb1ffe02d4b951ccf41cdad879bb Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 15:51:38 -0400 Subject: [PATCH 06/26] Added Scenes & Started Twitch Command --- commands/implemented/command_light_color.py | 24 +++++++++++++++++++++ lights_module.py | 18 ++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 commands/implemented/command_light_color.py diff --git a/commands/implemented/command_light_color.py b/commands/implemented/command_light_color.py new file mode 100644 index 0000000..49d4d93 --- /dev/null +++ b/commands/implemented/command_light_color.py @@ -0,0 +1,24 @@ +from abc import ABCMeta + +from commands.command_base import AbstractCommand + +import random + +class CommandRoll(AbstractCommand, metaclass=ABCMeta): + """ + this is the roll command. + """ + command = "!color" + + def __init__(self): + super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) + + def do_command(self, bot, twitch_message): + tempParsedMessage = twitch_message.text.split(" ") + + rgb_r = float(tempParsedMessage[1]) + rgb_g = float(tempParsedMessage[2]) + rgb_b = float(tempParsedMessage[3]) + + diceRoll = "@" + twitch_message.sender + " changed the colors!" + bot.send_message(diceRoll) \ No newline at end of file diff --git a/lights_module.py b/lights_module.py index 3e78f60..c4350fe 100644 --- a/lights_module.py +++ b/lights_module.py @@ -7,7 +7,7 @@ import random import credentials import config -class Lights_Modules(): +class Lights_Module(): def __init__(self): super().__init__() @@ -48,13 +48,19 @@ class Lights_Modules(): b.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue # The Following will make a rave - for rave in range(2000): + for rave in range(20): rgb_r = random.random() rgb_g = random.random() rgb_b = random.random() - xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy - b.set_group(16, "xy", xy_result) - sleep(0.5) + #xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy + #b.set_group(16, "xy", xy_result) + #sleep(0.1) + + #for stuffz in b.scenes: + #print(stuffz) + + # This will set the group Downstairs to the Stream scene + #b.run_scene("Downstairs", "Stream") print("\n finished doing the things") @@ -89,7 +95,7 @@ class Lights_Modules(): if __name__ == "__main__": - testModule = Lights_Modules() + testModule = Lights_Module() credentials_manager = credentials.Credentials_Module() credentials_manager.load_credentials() From 93c0e182ed7ed965286e17dc5de9cb850e6c5e34 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 16:37:30 -0400 Subject: [PATCH 07/26] Expanded Module & Twitch RGB Command --- commands/implemented/command_light_color.py | 24 -------- .../implemented/command_light_rgb_color.py | 39 +++++++++++++ lights_module.py | 56 +++++++++++++------ utilities_script.py | 10 ++++ 4 files changed, 88 insertions(+), 41 deletions(-) delete mode 100644 commands/implemented/command_light_color.py create mode 100644 commands/implemented/command_light_rgb_color.py diff --git a/commands/implemented/command_light_color.py b/commands/implemented/command_light_color.py deleted file mode 100644 index 49d4d93..0000000 --- a/commands/implemented/command_light_color.py +++ /dev/null @@ -1,24 +0,0 @@ -from abc import ABCMeta - -from commands.command_base import AbstractCommand - -import random - -class CommandRoll(AbstractCommand, metaclass=ABCMeta): - """ - this is the roll command. - """ - command = "!color" - - def __init__(self): - super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) - - def do_command(self, bot, twitch_message): - tempParsedMessage = twitch_message.text.split(" ") - - rgb_r = float(tempParsedMessage[1]) - rgb_g = float(tempParsedMessage[2]) - rgb_b = float(tempParsedMessage[3]) - - diceRoll = "@" + twitch_message.sender + " changed the colors!" - bot.send_message(diceRoll) \ No newline at end of file diff --git a/commands/implemented/command_light_rgb_color.py b/commands/implemented/command_light_rgb_color.py new file mode 100644 index 0000000..8177eae --- /dev/null +++ b/commands/implemented/command_light_rgb_color.py @@ -0,0 +1,39 @@ +from abc import ABCMeta +import lights_module + +from commands.command_base import AbstractCommand + +import random + +import utilities_script as utilities + +class CommandRoll(AbstractCommand, metaclass=ABCMeta): + """ + this is the roll command. + """ + command = "!rgb" + + def __init__(self): + super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) + + def do_command(self, bot, twitch_message): + LightModule = lights_module.Lights_Module() + LightModule.main() + + tempParsedMessage = twitch_message.text.split(" ") + + run_lightsCommand = False + if (utilities.does_contain_OnlyNumbers(tempParsedMessage[1]) & + utilities.does_contain_OnlyNumbers(tempParsedMessage[2]) & + utilities.does_contain_OnlyNumbers(tempParsedMessage[3])) == True: + 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) + LightModule.bridge_.set_group(16, "xy", xy_result) + else: + xy_result = LightModule.color_string_parser(tempParsedMessage) + LightModule.bridge_.set_group(16, "xy", xy_result) + + returnMessage = "@" + twitch_message.sender + " changed the colors!" + bot.send_message(returnMessage) \ No newline at end of file diff --git a/lights_module.py b/lights_module.py index c4350fe..f7ddea6 100644 --- a/lights_module.py +++ b/lights_module.py @@ -10,17 +10,17 @@ import config class Lights_Module(): def __init__(self): super().__init__() + self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): print("Starting up Lights_Modules....") - b = Bridge('192.168.191.146') - b.connect + self.b.connect - b.get_api() + self.b.get_api() - light_list = b.lights + light_list = self.b.lights group_list:list = [] - groups = b.get_group() + groups = self.b.get_group() groupCount = 0 print("\n -Listing Lights...") @@ -35,36 +35,46 @@ class Lights_Module(): for gc in range(groupCount): try: print("group n:" + str(gc)) - group = b.get_group(gc ,'name') + group = self.b.get_group(gc ,'name') print(group) #group_list.append(group) print(" --done adding") except: print(" --adding failed") - #b.set_group(18, "bri", 254) #This is max Brightness - #b.set_group(18, "on", True) #This is will turn ON - xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy - b.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue + #self.b.set_group(18, "bri", 254) #This is max Brightness + #self.b.set_group(18, "on", True) #This is will turn ON + #xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy + #self.b.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue # The Following will make a rave - for rave in range(20): - rgb_r = random.random() - rgb_g = random.random() - rgb_b = random.random() + #for rave in range(10): + #rgb_r = random.random() + #rgb_g = random.random() + #rgb_b = random.random() #xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy - #b.set_group(16, "xy", xy_result) + #self.b.set_group(16, "xy", xy_result) #sleep(0.1) #for stuffz in b.scenes: #print(stuffz) # This will set the group Downstairs to the Stream scene - #b.run_scene("Downstairs", "Stream") + #self.b.run_scene("Downstairs", "Stream") - print("\n finished doing the things") + print("\n Setup Complete") + def setLight(): + pass + def setLights(): + pass + + def setGroup(): + pass + + def setGroups(): + pass def rgb_to_xy(self, red, green, blue): """ conversion of RGB colors to CIE1931 XY colors @@ -93,6 +103,18 @@ class Lights_Module(): # TODO check color gamut if known return [x, y] + def color_string_parser(self, message): + xy_color = 0 + for text in message: + if "red" in message.lower(): + xy_color = self.rgb_to_xy(1,0,0) + if "blue" in message.lower(): + xy_color = self.rgb_to_xy(0,0,1) + if "green" in message.lower(): + xy_color = self.rgb_to_xy(0,1,0) + + return xy_color + if __name__ == "__main__": testModule = Lights_Module() diff --git a/utilities_script.py b/utilities_script.py index 91c7380..4ce9b16 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -20,6 +20,16 @@ def contains_url(self, input: str): def get_args(text: str) -> list: return text.split(" ") +def does_contain_OnlyNumbers(self, text): + isJustNumbers = False + for x in range(10): + if str(x) in text: + isJustNumbers = True + else: + isJustNumbers = False + + return isJustNumbers + def contains_slur(self, input: str): containsSlur: bool = False parsedMessage = input.split(" ") From 0e4d2455bb4e8da6c6469c55584ce45a217f20c8 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 16:39:59 -0400 Subject: [PATCH 08/26] Fixed Typo --- lights_module.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lights_module.py b/lights_module.py index f7ddea6..ebfa7b1 100644 --- a/lights_module.py +++ b/lights_module.py @@ -14,13 +14,13 @@ class Lights_Module(): def main(self): print("Starting up Lights_Modules....") - self.b.connect + self.bridge_.connect() - self.b.get_api() + self.bridge_.get_api() - light_list = self.b.lights + light_list = self.bridge_.lights group_list:list = [] - groups = self.b.get_group() + groups = self.bridge_.get_group() groupCount = 0 print("\n -Listing Lights...") @@ -35,17 +35,17 @@ class Lights_Module(): for gc in range(groupCount): try: print("group n:" + str(gc)) - group = self.b.get_group(gc ,'name') + group = self.bridge_.get_group(gc ,'name') print(group) #group_list.append(group) print(" --done adding") except: print(" --adding failed") - #self.b.set_group(18, "bri", 254) #This is max Brightness - #self.b.set_group(18, "on", True) #This is will turn ON + #self.bridge_.set_group(18, "bri", 254) #This is max Brightness + #self.bridge_.set_group(18, "on", True) #This is will turn ON #xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy - #self.b.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue + #self.bridge_.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue # The Following will make a rave #for rave in range(10): @@ -53,14 +53,14 @@ class Lights_Module(): #rgb_g = random.random() #rgb_b = random.random() #xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy - #self.b.set_group(16, "xy", xy_result) + #self.bridge_.set_group(16, "xy", xy_result) #sleep(0.1) - #for stuffz in b.scenes: + #for stuffz in .bridge_.scenes: #print(stuffz) # This will set the group Downstairs to the Stream scene - #self.b.run_scene("Downstairs", "Stream") + #self.bridge_.run_scene("Downstairs", "Stream") print("\n Setup Complete") From 8f60e00a6d046f92c1d1b16de54126676865bf90 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 16:43:05 -0400 Subject: [PATCH 09/26] Commented out stuff --- lights_module.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lights_module.py b/lights_module.py index ebfa7b1..c8f1176 100644 --- a/lights_module.py +++ b/lights_module.py @@ -25,22 +25,24 @@ class Lights_Module(): print("\n -Listing Lights...") for l in light_list: - print(l.name) + pass + #print(l.name) print("\n -Counting Groups...") for g in groups: - print(g) + #print(g) groupCount = int(g) for gc in range(groupCount): try: - print("group n:" + str(gc)) + #print("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - print(group) - #group_list.append(group) - print(" --done adding") + #print(group) + group_list.append(group) + #print(" --done adding") except: - print(" --adding failed") + pass + #print(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -56,7 +58,7 @@ class Lights_Module(): #self.bridge_.set_group(16, "xy", xy_result) #sleep(0.1) - #for stuffz in .bridge_.scenes: + #for stuffz in self.bridge_.scenes: #print(stuffz) # This will set the group Downstairs to the Stream scene From b519a507025bec8fe03e58ec352bad8b820278da Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:24:37 -0400 Subject: [PATCH 10/26] Fixed Light Command Able to use RGB Values (0 to 1) ex: !lights 1 1 1 Able to use Colors ex: !lights red --- ..._rgb_color.py => command_lights_rgb_color.py} | 16 ++++++++++------ lights_module.py | 13 +++++++++---- utilities_script.py | 14 +++++++++----- 3 files changed, 28 insertions(+), 15 deletions(-) rename commands/implemented/{command_light_rgb_color.py => command_lights_rgb_color.py} (75%) diff --git a/commands/implemented/command_light_rgb_color.py b/commands/implemented/command_lights_rgb_color.py similarity index 75% rename from commands/implemented/command_light_rgb_color.py rename to commands/implemented/command_lights_rgb_color.py index 8177eae..aac049e 100644 --- a/commands/implemented/command_light_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -11,7 +11,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): """ this is the roll command. """ - command = "!rgb" + command = "!lights" def __init__(self): super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) @@ -19,21 +19,25 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): def do_command(self, bot, twitch_message): LightModule = lights_module.Lights_Module() LightModule.main() + print("\nRGB Command Detected!") tempParsedMessage = twitch_message.text.split(" ") - - run_lightsCommand = False - if (utilities.does_contain_OnlyNumbers(tempParsedMessage[1]) & - utilities.does_contain_OnlyNumbers(tempParsedMessage[2]) & - utilities.does_contain_OnlyNumbers(tempParsedMessage[3])) == True: + print("\nParsed Command! ", twitch_message.text) + if (len(tempParsedMessage)) > 2: + print("\nRGB 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) + print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") else: + print("\nColor Command!") xy_result = LightModule.color_string_parser(tempParsedMessage) + print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") returnMessage = "@" + twitch_message.sender + " changed the colors!" bot.send_message(returnMessage) \ No newline at end of file diff --git a/lights_module.py b/lights_module.py index c8f1176..261c51a 100644 --- a/lights_module.py +++ b/lights_module.py @@ -106,13 +106,18 @@ class Lights_Module(): return [x, y] def color_string_parser(self, message): - xy_color = 0 + print("trying to find color") + xy_color = [0, 0] for text in message: - if "red" in message.lower(): + print("testing word") + if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - if "blue" in message.lower(): + print("found: red") + if "blue" in text.lower(): + print("found: blue") xy_color = self.rgb_to_xy(0,0,1) - if "green" in message.lower(): + if "green" in text.lower(): + print("found: green") xy_color = self.rgb_to_xy(0,1,0) return xy_color diff --git a/utilities_script.py b/utilities_script.py index 4ce9b16..e62dc9d 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -21,14 +21,18 @@ def get_args(text: str) -> list: return text.split(" ") def does_contain_OnlyNumbers(self, text): - isJustNumbers = False + isJustNumbers = False + print("checking numbers") + try: for x in range(10): - if str(x) in text: + if str(x) in str(text): isJustNumbers = True - else: - isJustNumbers = False + else: + isJustNumbers = False + except: + pass - return isJustNumbers + return isJustNumbers def contains_slur(self, input: str): containsSlur: bool = False From 435ef1521195d0992b896175b2dea42a6a14ad84 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:29:46 -0400 Subject: [PATCH 11/26] Changed Bot Response --- commands/implemented/command_lights_rgb_color.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index aac049e..4fb3a51 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -39,5 +39,5 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): LightModule.bridge_.set_group(16, "xy", xy_result) print("sent color") - returnMessage = "@" + twitch_message.sender + " changed the colors!" + returnMessage = "@" + twitch_message.sender + " changed the light's color!" bot.send_message(returnMessage) \ No newline at end of file From 7f1c99167229309275435ff80bf58273c354365f Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:30:15 -0400 Subject: [PATCH 12/26] Update requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 087181f..4045979 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ gTTS playsound discord.py psutil -art \ No newline at end of file +art +phue \ No newline at end of file From 1b317282c5e8b577cc26b09ac994fa0026fe76d0 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:36:55 -0400 Subject: [PATCH 13/26] Added RGB Config Controls --- .../implemented/command_lights_rgb_color.py | 45 ++++++++++--------- config.py | 7 ++- twitch_script.py | 2 + 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index 4fb3a51..bc5b6d4 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -17,27 +17,28 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) def do_command(self, bot, twitch_message): - LightModule = lights_module.Lights_Module() - LightModule.main() - print("\nRGB Command Detected!") + if bot.allow_rgbLightControl == True: + LightModule = lights_module.Lights_Module() + LightModule.main() + print("\nRGB Command Detected!") - tempParsedMessage = twitch_message.text.split(" ") - print("\nParsed Command! ", twitch_message.text) - if (len(tempParsedMessage)) > 2: - print("\nRGB 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) - print("got XY") - LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") - else: - print("\nColor Command!") - xy_result = LightModule.color_string_parser(tempParsedMessage) - print("got XY") - LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + tempParsedMessage = twitch_message.text.split(" ") + print("\nParsed Command! ", twitch_message.text) + if (len(tempParsedMessage)) > 2: + print("\nRGB 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) + print("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") + else: + print("\nColor Command!") + xy_result = LightModule.color_string_parser(tempParsedMessage) + print("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") - returnMessage = "@" + twitch_message.sender + " changed the light's color!" - bot.send_message(returnMessage) \ No newline at end of file + returnMessage = "@" + twitch_message.sender + " changed the light's color!" + bot.send_message(returnMessage) \ No newline at end of file diff --git a/config.py b/config.py index bce47c4..db465fd 100644 --- a/config.py +++ b/config.py @@ -11,7 +11,7 @@ test_module: bool = False autoJoin_TwitchChannels = ["thecuriousnerd"] whitelisted_TwitchPowerUsers = ["thecuriousnerd"] - +#Twitch Module Configs block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels blockAll_TwitchChatChannelsMessaging = False # Blocks the ability to send messages to twitch channels @@ -23,7 +23,9 @@ forceAll_TwitchChatChannelsTTS = False # forceAll supersedes the blockAll bool a blockAll_TTS_URL_Twitch = True +autoEnabled_Twitch_rgbLightControl = False +#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 blockAll_DiscordPrivateMessaging = False # Private Messaging not yet implemented @@ -37,6 +39,9 @@ forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool blockAll_TTS_URL_Discord = True +autoEnabled_Discord_rgbLightControl = False + + skip_splashScreen = False skip_splashScreenClear = False diff --git a/twitch_script.py b/twitch_script.py index 9e16e6a..2c886f0 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -39,6 +39,8 @@ class Twitch_Module(): self.cooldownModule:Cooldown_Module = Cooldown_Module() self.cooldownModule.setupCooldown("twitchChat", 20, 32) + self.allow_rgbLightControl = config.autoEnabled_Twitch_rgbLightControl + def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str): channel_name = "#" + channel_name print("Connecting to Channel: " + channel_name + "...") From fb9d58a231cac370d17f8d0db516ede6c52d41a6 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:44:38 -0400 Subject: [PATCH 14/26] Commented Line --- lights_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lights_module.py b/lights_module.py index 261c51a..c966a59 100644 --- a/lights_module.py +++ b/lights_module.py @@ -109,7 +109,7 @@ class Lights_Module(): print("trying to find color") xy_color = [0, 0] for text in message: - print("testing word") + #print("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) print("found: red") From 5ab2abc24249b2bc668f3aead721ef2638ffe617 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 17:55:28 -0400 Subject: [PATCH 15/26] Added rescale function --- utilities_script.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utilities_script.py b/utilities_script.py index e62dc9d..c21075e 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -34,6 +34,9 @@ def does_contain_OnlyNumbers(self, text): return isJustNumbers +def rescale_value(self, value, min, max): + return (value - min) / (max - min) + def contains_slur(self, input: str): containsSlur: bool = False parsedMessage = input.split(" ") From 84b36622b3521d247d0c8d8de5496cd29ad8ce4e Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 7 Apr 2021 18:22:32 -0400 Subject: [PATCH 16/26] Fixed Utilities and Value Rescaling --- lights_module.py | 27 +++++++++++++++++++++++++++ utilities_script.py | 13 ++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lights_module.py b/lights_module.py index c966a59..e5fe489 100644 --- a/lights_module.py +++ b/lights_module.py @@ -3,6 +3,7 @@ import phue from phue import Bridge import random +import utilities_script as utilities import credentials import config @@ -106,6 +107,7 @@ class Lights_Module(): return [x, y] def color_string_parser(self, message): + maxDigits = 4 print("trying to find color") xy_color = [0, 0] for text in message: @@ -120,6 +122,31 @@ class Lights_Module(): print("found: green") xy_color = self.rgb_to_xy(0,1,0) + + if "cyan" in text.lower(): + print("found: cyan") + xy_color = self.rgb_to_xy(0,1,1) + if "aquamarine" in text.lower(): + print("found: aquamarine") + xy_color = self.rgb_to_xy( + round(utilities.rescale_value(111,0,254),maxDigits), + round(utilities.rescale_value(218,0,254),maxDigits), + round(utilities.rescale_value(146,0,254),maxDigits)) + + if "turquoise" in text.lower(): + print("found: turquoise") + xy_color = self.rgb_to_xy( + round(utilities.rescale_value(172,0,254),maxDigits), + round(utilities.rescale_value(233,0,254),maxDigits), + round(utilities.rescale_value(232,0,254),maxDigits)) + + if "orange" in text.lower(): + print("found: orange") + xy_color = self.rgb_to_xy( + 1, + round(utilities.rescale_value(126,0,254),maxDigits), + 0) + return xy_color diff --git a/utilities_script.py b/utilities_script.py index c21075e..9abf53c 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -13,14 +13,14 @@ 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(self, input: str): +def contains_url(input: str): containsURL = re.search(urlMatcher, input.lower()) is not None return containsURL def get_args(text: str) -> list: return text.split(" ") -def does_contain_OnlyNumbers(self, text): +def does_contain_OnlyNumbers(text): isJustNumbers = False print("checking numbers") try: @@ -34,10 +34,13 @@ def does_contain_OnlyNumbers(self, text): return isJustNumbers -def rescale_value(self, value, min, max): - return (value - min) / (max - min) +def rescale_value(value, min, max): + print("trying Rescale") + returnValue = (value - min) / (max - min) + print("got ", returnValue) + return returnValue -def contains_slur(self, input: str): +def contains_slur(input: str): containsSlur: bool = False parsedMessage = input.split(" ") for word in parsedMessage: From 505860fe5963d2767985e29e0eb705e43b3dbe74 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 13:06:51 -0400 Subject: [PATCH 17/26] More Lights --- .../implemented/command_lights_rgb_color.py | 23 +++++++--- lights_module.py | 43 ++++++++++++++++++- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index bc5b6d4..4d743ee 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -34,11 +34,24 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): LightModule.bridge_.set_group(16, "xy", xy_result) print("sent color") else: - print("\nColor Command!") - xy_result = LightModule.color_string_parser(tempParsedMessage) - print("got XY") - LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + if "stream" in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "Stream") + elif ("normal" or "regular" or "bright" or "daylight") in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "Bright") + elif ("haxor") in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "hacker vibes") + elif "off" in tempParsedMessage: + LightModule.bridge_.set_group("Downstairs", "on", False) + elif "on" in tempParsedMessage: + LightModule.bridge_.set_group("Downstairs", "on", True) + elif "ravemode" in tempParsedMessage: + LightModule.raveMode() + else: + print("\nColor Command!") + xy_result = LightModule.color_string_parser(tempParsedMessage) + print("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") returnMessage = "@" + twitch_message.sender + " changed the light's color!" bot.send_message(returnMessage) \ No newline at end of file diff --git a/lights_module.py b/lights_module.py index e5fe489..63a366b 100644 --- a/lights_module.py +++ b/lights_module.py @@ -79,6 +79,16 @@ class Lights_Module(): def setGroups(): pass + def raveMode(self): + for rave in range(30): + rgb_r = random.random() + rgb_g = random.random() + rgb_b = random.random() + xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy + self.bridge_.set_group(16, "xy", xy_result) + sleep(0.3) + self.bridge_.run_scene("Downstairs", "Stream") + def rgb_to_xy(self, red, green, blue): """ conversion of RGB colors to CIE1931 XY colors Formulas implemented from: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d @@ -122,6 +132,13 @@ class Lights_Module(): print("found: green") xy_color = self.rgb_to_xy(0,1,0) + if "yellow" in text.lower(): + print("found: yellow") + xy_color = self.rgb_to_xy( + 0.7, + 0.64, + 0) + if "cyan" in text.lower(): print("found: cyan") @@ -132,7 +149,6 @@ class Lights_Module(): round(utilities.rescale_value(111,0,254),maxDigits), round(utilities.rescale_value(218,0,254),maxDigits), round(utilities.rescale_value(146,0,254),maxDigits)) - if "turquoise" in text.lower(): print("found: turquoise") xy_color = self.rgb_to_xy( @@ -147,6 +163,28 @@ class Lights_Module(): round(utilities.rescale_value(126,0,254),maxDigits), 0) + + if "magenta" in text.lower(): + print("found: magenta") + xy_color = self.rgb_to_xy( + 1, + 0, + 1) + + if "purple" in text.lower(): + print("found: purple") + xy_color = self.rgb_to_xy( + round(utilities.rescale_value(159,0,254),maxDigits), + round(utilities.rescale_value(32,0,254),maxDigits), + round(utilities.rescale_value(239,0,254),maxDigits)) + + if "violet" in text.lower(): + print("found: violet") + xy_color = self.rgb_to_xy( + round(utilities.rescale_value(237,0,254),maxDigits), + round(utilities.rescale_value(129,0,254),maxDigits), + round(utilities.rescale_value(237,0,254),maxDigits)) + return xy_color @@ -158,4 +196,5 @@ if __name__ == "__main__": #testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname) #testModule.discordCredential = credentials_manager.find_Discord_Credential(config.credentialsNickname) - testModule.main() \ No newline at end of file + testModule.main() + testModule.raveMode() \ No newline at end of file From a535aafb1ec3362bc4931953770e5a392a3b43c1 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 13:46:38 -0400 Subject: [PATCH 18/26] fixed discord roll command --- commands/implemented/command_roll_discord.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/implemented/command_roll_discord.py b/commands/implemented/command_roll_discord.py index 86244ea..47f4c69 100644 --- a/commands/implemented/command_roll_discord.py +++ b/commands/implemented/command_roll_discord.py @@ -90,6 +90,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): #await discord_message.channel.send(diceRoll) async def roll(self, roll_type, discord_message: discord.Message): + diceRoll = "" switch = { 1: "Standard", 2: "Fate Dice" @@ -139,11 +140,13 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print(diceRoll) if roll_type == 2: + print("fate Rolling....") + # !roll 4df # If roll is in xdx+x format if loopBool == True: rolls: list = [] for x in range(int(parsedMessage[0])): - rolls.append(random.randint(1, 3)) # This is the roller + rolls.append(random.randint(-1, 1)) # This is the roller rollTotal = 0 for roll in rolls: @@ -158,7 +161,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): diceRoll = diceRoll + " = " + str(rollTotal) # If roll is in dx+x format if loopBool == False: - roll: int = random.randint(1, 3) # This is the roller + roll: int = random.randint(-1, 1) # This is the roller if len(temp_preParsedMessage) == 2: diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str( From aea69fb4bf615bc7c27f7502ca03a3c6369abbd4 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 14:27:47 -0400 Subject: [PATCH 19/26] Chyron Module --- chyron_config.py | 0 chyron_module.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 chyron_config.py create mode 100644 chyron_module.py diff --git a/chyron_config.py b/chyron_config.py new file mode 100644 index 0000000..e69de29 diff --git a/chyron_module.py b/chyron_module.py new file mode 100644 index 0000000..0fe5c29 --- /dev/null +++ b/chyron_module.py @@ -0,0 +1,40 @@ +import chyron_config + +class Chyron_Module(): + def __init__(self): + super().__init__() + self.chyron_string = "" + self.chyron_items:list = [] + + def testmain(): + pass + + def chyron_string_updater(self): + pass + + def addItem(self, name, title, content): + newItem = ChyronItem.setupItem(name, title, content) + self.chyron_items.append(newItem) + + def removeItem(self, name): + for c in self.chyron_items: + if c.itemName == name: + self.chyron_items.remove(c) + + +class ChyronItem(): + def __init__(self): + super().__init__() + self.itemName = "" + self.itemTitle = "" + self.itemContent = "" + + def setupItem(self, name, title, content): + self.itemName = name + self.itemTitle = title + self.itemContent = content + + +if __name__ == "__main__": + testModule = Chyron_Module() + testModule.testmain() \ No newline at end of file From ecffe6083b01e72e2f4c835ea6bac90c6dbc2068 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 15:00:36 -0400 Subject: [PATCH 20/26] Added Test --- chyron_config.py | 0 chyron_module.py | 62 +++++++++++++++++++++++++++++++++++++++++------- config.py | 22 +++++++++-------- 3 files changed, 65 insertions(+), 19 deletions(-) delete mode 100644 chyron_config.py diff --git a/chyron_config.py b/chyron_config.py deleted file mode 100644 index e69de29..0000000 diff --git a/chyron_module.py b/chyron_module.py index 0fe5c29..9952bfd 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -1,19 +1,23 @@ -import chyron_config +import config class Chyron_Module(): def __init__(self): super().__init__() - self.chyron_string = "" + self.chyron_computedString = "" self.chyron_items:list = [] - def testmain(): - pass - - def chyron_string_updater(self): - pass + def chyron_stringUpdater(self): + newString = "" + for c in self.chyron_items: + c.item_stringUpdater() + newString = newString + c.itemComputedString + for x in range(config.chyronListSpaceCount): + newString = newString + " " + self.chyron_computedString = newString def addItem(self, name, title, content): - newItem = ChyronItem.setupItem(name, title, content) + newItem:ChyronItem = ChyronItem() + newItem.setupItem(name, title, content) self.chyron_items.append(newItem) def removeItem(self, name): @@ -26,15 +30,55 @@ class ChyronItem(): def __init__(self): super().__init__() self.itemName = "" + + self.includeTitle = True self.itemTitle = "" self.itemContent = "" + self.itemComputedString = "" + def setupItem(self, name, title, content): + print("Setting up Item {", name,"}[", title, content, "]") self.itemName = name self.itemTitle = title self.itemContent = content + def item_stringUpdater(self): + newString = "" + if self.includeTitle == True: + newString = newString + self.itemTitle + newString = newString + self.itemContent + self.itemComputedString = newString + + if __name__ == "__main__": testModule = Chyron_Module() - testModule.testmain() \ No newline at end of file + testModule.addItem( + "test", + "Now: ", + "Coding Stream") + testModule.addItem( + "FriSat", + "► Friday & Saturday: ", + "Coding Stream") + testModule.addItem( + "Commands", + "► Commands: ", + "!animal, !climateclock, !discord, !page, !roll") + testModule.addItem( + "Website", + "► Want to read about my various projects? visit: ", + "TheCuriousNerd.com") + testModule.addItem( + "Follow", + "", + "► If you like what you see, hit that follow button to see more!") + testModule.addItem( + "Discord", + "► Want to join our discord? type \" !d \" in chat to get the link or visit: ", + "discord.io/thecuriousnerd") + testModule.chyron_stringUpdater() + + test = testModule.chyron_computedString + "<<<|" + print(test) \ No newline at end of file diff --git a/config.py b/config.py index db465fd..a0a077a 100644 --- a/config.py +++ b/config.py @@ -41,19 +41,15 @@ blockAll_TTS_URL_Discord = True autoEnabled_Discord_rgbLightControl = False +#Chyron Module Configs +chyronListSpaceCount = 25 - +#General Configs skip_splashScreen = False skip_splashScreenClear = False skip_splashScreenSleep = False - -class Speaker(Enum): - GOOGLE_TEXT_TO_SPEECH = 1 - STREAMLABS_API = 2 - -currentSpeaker = Speaker.GOOGLE_TEXT_TO_SPEECH - +botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy") class FileNameStrategy(Enum): TIME_BASED = 1 @@ -69,6 +65,13 @@ class DBStrategy(Enum): dbStrategy = DBStrategy.SQLite +#TTS Configs +class Speaker(Enum): + GOOGLE_TEXT_TO_SPEECH = 1 + STREAMLABS_API = 2 + +currentSpeaker = Speaker.GOOGLE_TEXT_TO_SPEECH + class PollyVoices(Enum): Aditi = "Aditi" Amy = "Amy" @@ -134,8 +137,7 @@ class PollyVoices(Enum): PollyVoice = PollyVoices.Justin -botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy") - +#Misc Configs slurList = badwords.slurList praxisVersion_Alpha = "A.0 " From 1519e878596bcaac441846cc55ff1f6bc4b5756d Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 15:48:08 -0400 Subject: [PATCH 21/26] Create user_module.py --- user_module.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 user_module.py diff --git a/user_module.py b/user_module.py new file mode 100644 index 0000000..a7f6899 --- /dev/null +++ b/user_module.py @@ -0,0 +1,41 @@ +import config as config +import db + +import credentials + +class User_Module(): + def __init__(self): + super().__init__() + self.dbCredential: credentials.DB_Credential + + def main(self): + print("Waiting on User input...") + while True: + keyboardInput = input() + + if "exit" or "quit" or "stop" in keyboardInput: + print("Quitting User Module Interface...") + break + + self.parseInput(keyboardInput) + + def parseInput(self, input): + if self.isCommand(input): + self.runCommand(input) + else: + pass + + def isCommand(self, input): + isCommand = False + return isCommand + + def runCommand(self, input): + pass + +if __name__ == "__main__": + testModule = User_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 From dadf75364e3d7717a25af108bf321520d50145f5 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:06:09 -0400 Subject: [PATCH 22/26] Added Command Support --- commands/command_base.py | 1 + ....py => command_lights_rgb_color_twitch.py} | 0 ...artBot.py => command_restartBot_twitch.py} | 0 ...command_roll.py => command_roll_twitch.py} | 0 ...wnBot.py => command_shutdownBot_twitch.py} | 0 ...command_test.py => command_test_twitch.py} | 0 .../{command_tts.py => command_tts_twitch.py} | 0 user_module.py | 46 +++++++++++++++++-- 8 files changed, 43 insertions(+), 4 deletions(-) rename commands/implemented/{command_lights_rgb_color.py => command_lights_rgb_color_twitch.py} (100%) rename commands/implemented/{command_restartBot.py => command_restartBot_twitch.py} (100%) rename commands/implemented/{command_roll.py => command_roll_twitch.py} (100%) rename commands/implemented/{command_shutdownBot.py => command_shutdownBot_twitch.py} (100%) rename commands/implemented/{command_test.py => command_test_twitch.py} (100%) rename commands/implemented/{command_tts.py => command_tts_twitch.py} (100%) diff --git a/commands/command_base.py b/commands/command_base.py index 9bcbcb3..064b5c5 100644 --- a/commands/command_base.py +++ b/commands/command_base.py @@ -14,6 +14,7 @@ class AbstractCommand(metaclass=ABCMeta): class CommandType(Enum): NONE = auto() + Praxis = auto() TWITCH = auto() DISCORD = auto() diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color_twitch.py similarity index 100% rename from commands/implemented/command_lights_rgb_color.py rename to commands/implemented/command_lights_rgb_color_twitch.py diff --git a/commands/implemented/command_restartBot.py b/commands/implemented/command_restartBot_twitch.py similarity index 100% rename from commands/implemented/command_restartBot.py rename to commands/implemented/command_restartBot_twitch.py diff --git a/commands/implemented/command_roll.py b/commands/implemented/command_roll_twitch.py similarity index 100% rename from commands/implemented/command_roll.py rename to commands/implemented/command_roll_twitch.py diff --git a/commands/implemented/command_shutdownBot.py b/commands/implemented/command_shutdownBot_twitch.py similarity index 100% rename from commands/implemented/command_shutdownBot.py rename to commands/implemented/command_shutdownBot_twitch.py diff --git a/commands/implemented/command_test.py b/commands/implemented/command_test_twitch.py similarity index 100% rename from commands/implemented/command_test.py rename to commands/implemented/command_test_twitch.py diff --git a/commands/implemented/command_tts.py b/commands/implemented/command_tts_twitch.py similarity index 100% rename from commands/implemented/command_tts.py rename to commands/implemented/command_tts_twitch.py diff --git a/user_module.py b/user_module.py index a7f6899..ad2635f 100644 --- a/user_module.py +++ b/user_module.py @@ -1,19 +1,27 @@ import config as config import db +import tts import credentials +import commands.loader as command_loader +from commands.command_base import AbstractCommand + +from cooldowns import Cooldown_Module + class User_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential + self.MessageLog:list = [] def main(self): print("Waiting on User input...") - while True: + inputLoop = True + while inputLoop: keyboardInput = input() - if "exit" or "quit" or "stop" in keyboardInput: + if "exit" in keyboardInput: print("Quitting User Module Interface...") break @@ -26,11 +34,41 @@ class User_Module(): pass def isCommand(self, input): - isCommand = False + isCommand = True + #MAKE THIS return isCommand def runCommand(self, input): - pass + self.eval_commands(input) + + def eval_commands(self, message): + # containsURL: bool = self.contains_url(message) + try: + #first_space_idx = message.text.index(' ') + + # This fixes a error where if you send a command without arguments it fails because + # it cant find the substring. + if message.content.find(" ") != -1: + first_space_idx = message.content.index(' ') + else: + first_space_idx = -1 + + command_text = ' ' + if first_space_idx > -1: + command_text = message.content[0:first_space_idx] + else: + command_text = message.content + + command = self.commands[command_text] + if command is not None and command.command_type is AbstractCommand.CommandType.Praxis: + command.do_command(self, message) + except Exception as e: + # Undo the following for debug stuff + #print(e) + pass # we don't care + + def tts_message(self, message): + tts.tts(message) if __name__ == "__main__": testModule = User_Module() From 15abdc16f3dd6fcace419e8885c7e93a015fe8c5 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:06:55 -0400 Subject: [PATCH 23/26] loop --- user_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/user_module.py b/user_module.py index ad2635f..6ffd978 100644 --- a/user_module.py +++ b/user_module.py @@ -23,6 +23,7 @@ class User_Module(): if "exit" in keyboardInput: print("Quitting User Module Interface...") + inputLoop = False break self.parseInput(keyboardInput) From 0ae1cd880d89046683784bf89416ae43fbc223e0 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:24:57 -0400 Subject: [PATCH 24/26] Added Lights Command to User Module --- .../implemented/command_lights_rgb_color.py | 58 +++++++++++++++++++ user_module.py | 39 ++++++++----- 2 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 commands/implemented/command_lights_rgb_color.py diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py new file mode 100644 index 0000000..180a868 --- /dev/null +++ b/commands/implemented/command_lights_rgb_color.py @@ -0,0 +1,58 @@ +from abc import ABCMeta +import lights_module + +from commands.command_base import AbstractCommand + +import random + +import utilities_script as utilities + +class CommandRoll(AbstractCommand, metaclass=ABCMeta): + """ + this is the roll command. + """ + command = "!lights" + + def __init__(self): + super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.Praxis) + + def do_command(self, bot, user_message): + tempBool = True + if tempBool == True: + LightModule = lights_module.Lights_Module() + LightModule.main() + print("\nRGB Command Detected!") + + tempParsedMessage = user_message.message.split(" ") + print("\nParsed Command! ", user_message.message) + if (len(tempParsedMessage)) > 2: + print("\nRGB 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) + print("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") + else: + if "stream" in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "Stream") + elif ("normal" or "regular" or "bright" or "daylight") in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "Bright") + elif ("haxor") in tempParsedMessage: + LightModule.bridge_.run_scene("Downstairs", "hacker vibes") + elif "off" in tempParsedMessage: + LightModule.bridge_.set_group("Downstairs", "on", False) + elif "on" in tempParsedMessage: + LightModule.bridge_.set_group("Downstairs", "on", True) + elif "ravemode" in tempParsedMessage: + LightModule.raveMode() + else: + print("\nColor Command!") + xy_result = LightModule.color_string_parser(tempParsedMessage) + print("got XY") + LightModule.bridge_.set_group(16, "xy", xy_result) + print("sent color") + + returnMessage = "@" + user_message.user + " changed the light's color!" + bot.send_message(returnMessage) \ No newline at end of file diff --git a/user_module.py b/user_module.py index 6ffd978..70cd445 100644 --- a/user_module.py +++ b/user_module.py @@ -13,34 +13,37 @@ class User_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential + self.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis) self.MessageLog:list = [] def main(self): - print("Waiting on User input...") + print("\nWaiting on User input...") inputLoop = True while inputLoop: keyboardInput = input() + message = UserMessage() + message.makeMessage(message=keyboardInput) if "exit" in keyboardInput: print("Quitting User Module Interface...") inputLoop = False break - self.parseInput(keyboardInput) + self.parseInput(message) - def parseInput(self, input): - if self.isCommand(input): - self.runCommand(input) + def parseInput(self, message): + if self.isCommand(message) == True: + self.runCommand(message) else: pass - def isCommand(self, input): + def isCommand(self, message): isCommand = True #MAKE THIS return isCommand - def runCommand(self, input): - self.eval_commands(input) + def runCommand(self, message): + self.eval_commands(message) def eval_commands(self, message): # containsURL: bool = self.contains_url(message) @@ -49,16 +52,16 @@ class User_Module(): # This fixes a error where if you send a command without arguments it fails because # it cant find the substring. - if message.content.find(" ") != -1: - first_space_idx = message.content.index(' ') + if message.message.find(" ") != -1: + first_space_idx = message.message.index(' ') else: first_space_idx = -1 command_text = ' ' if first_space_idx > -1: - command_text = message.content[0:first_space_idx] + command_text = message.message[0:first_space_idx] else: - command_text = message.content + command_text = message.message command = self.commands[command_text] if command is not None and command.command_type is AbstractCommand.CommandType.Praxis: @@ -68,9 +71,19 @@ class User_Module(): #print(e) pass # we don't care - def tts_message(self, message): + def tts(self, message): tts.tts(message) +class UserMessage(): + def __init__(self): + super().__init__() + self.user = "User" + self.message = "" + + def makeMessage(self, user = "User", message = ""): + self.user = user + self.message = message + if __name__ == "__main__": testModule = User_Module() From 79a4977b3831a26002e5b36f9525383626bdd4a5 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:28:21 -0400 Subject: [PATCH 25/26] Return Message --- commands/implemented/command_lights_rgb_color.py | 6 +++--- user_module.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index 180a868..0454f74 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -37,9 +37,9 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): else: if "stream" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "Stream") - elif ("normal" or "regular" or "bright" or "daylight") in tempParsedMessage: + elif "normal" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "Bright") - elif ("haxor") in tempParsedMessage: + elif "haxor" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "hacker vibes") elif "off" in tempParsedMessage: LightModule.bridge_.set_group("Downstairs", "on", False) @@ -55,4 +55,4 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): print("sent color") returnMessage = "@" + user_message.user + " changed the light's color!" - bot.send_message(returnMessage) \ No newline at end of file + bot.return_message(returnMessage) \ No newline at end of file diff --git a/user_module.py b/user_module.py index 70cd445..4e904d0 100644 --- a/user_module.py +++ b/user_module.py @@ -71,6 +71,9 @@ class User_Module(): #print(e) pass # we don't care + def return_message(self, returnedMessage): + print(returnedMessage) + def tts(self, message): tts.tts(message) From 932eb56f9787c0222d28c6abe6fab035fce04c80 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:30:26 -0400 Subject: [PATCH 26/26] fixed light command --- commands/implemented/command_lights_rgb_color_twitch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color_twitch.py b/commands/implemented/command_lights_rgb_color_twitch.py index 4d743ee..909ae16 100644 --- a/commands/implemented/command_lights_rgb_color_twitch.py +++ b/commands/implemented/command_lights_rgb_color_twitch.py @@ -36,9 +36,9 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): else: if "stream" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "Stream") - elif ("normal" or "regular" or "bright" or "daylight") in tempParsedMessage: + elif "normal" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "Bright") - elif ("haxor") in tempParsedMessage: + elif "haxor" in tempParsedMessage: LightModule.bridge_.run_scene("Downstairs", "hacker vibes") elif "off" in tempParsedMessage: LightModule.bridge_.set_group("Downstairs", "on", False)