From 292b54d353ad51a679e3d0557d54c243e8bbac37 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:41:38 -0400 Subject: [PATCH 1/7] Chyron Output --- chyron_module.py | 4 ++++ utilities_script.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/chyron_module.py b/chyron_module.py index 9952bfd..090112c 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -1,4 +1,5 @@ import config +import utilities_script as utilities class Chyron_Module(): def __init__(self): @@ -25,6 +26,9 @@ class Chyron_Module(): if c.itemName == name: self.chyron_items.remove(c) + def updateChyronFile(self): + dir = utilities.get_dir("stream_sources") + class ChyronItem(): def __init__(self): diff --git a/utilities_script.py b/utilities_script.py index 9abf53c..22c9a75 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -40,6 +40,16 @@ def rescale_value(value, min, max): print("got ", returnValue) return returnValue +def get_dir(selected_dir): + """ + Checks for the tts directory, and will create it if it does not exist + :return: the relative file path of the tts dir + """ + dir = os.path.join(os.getcwd(), selected_dir) # this is platform-agnostic + if not os.path.exists(dir): + os.mkdir(dir) + return dir + def contains_slur(input: str): containsSlur: bool = False parsedMessage = input.split(" ") -- 2.45.2 From 684b22f451af7dd921f3cfcf4c80c8806f57d029 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:02:18 -0400 Subject: [PATCH 2/7] updated chyron test --- chyron_module.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chyron_module.py b/chyron_module.py index 090112c..2e6e842 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -59,17 +59,21 @@ class ChyronItem(): if __name__ == "__main__": testModule = Chyron_Module() testModule.addItem( - "test", + "RightNow", "Now: ", "Coding Stream") + testModule.addItem( + "WeekDays", + "► Weekdays: ", + "Daily Stream @ 12pm Noon EST") testModule.addItem( "FriSat", "► Friday & Saturday: ", - "Coding Stream") + "FFxiv (Express Delivery Raid Team) @ 7pm EST") testModule.addItem( "Commands", "► Commands: ", - "!animal, !climateclock, !discord, !page, !roll") + "!animal, !climateclock, !discord, !lights, !page, !roll") testModule.addItem( "Website", "► Want to read about my various projects? visit: ", -- 2.45.2 From 2da73490305e44af1bd78ee913de4492f9f0fd61 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:19:22 -0400 Subject: [PATCH 3/7] Improved Lights Module --- .../implemented/command_lights_rgb_color.py | 25 +++++++++----- .../command_lights_rgb_color_twitch.py | 26 +++++++++----- config.py | 5 +++ lights_module.py | 34 +++++++++---------- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/commands/implemented/command_lights_rgb_color.py b/commands/implemented/command_lights_rgb_color.py index 0454f74..7606798 100644 --- a/commands/implemented/command_lights_rgb_color.py +++ b/commands/implemented/command_lights_rgb_color.py @@ -21,38 +21,47 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): if tempBool == True: LightModule = lights_module.Lights_Module() LightModule.main() - print("\nRGB Command Detected!") + #print("\nRGB Command Detected!") tempParsedMessage = user_message.message.split(" ") - print("\nParsed Command! ", user_message.message) + sceneCommand = False if (len(tempParsedMessage)) > 2: - print("\nRGB Command!") + print("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) - print("got XY") + #print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + print("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: - print("\nColor Command!") + print("Color Command!") xy_result = LightModule.color_string_parser(tempParsedMessage) - print("got XY") + #print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + print("sent color to [Lights_Module]") + + if sceneCommand == True: + print("Scene Command!") returnMessage = "@" + user_message.user + " changed the light's color!" bot.return_message(returnMessage) \ 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 909ae16..a87ea3b 100644 --- a/commands/implemented/command_lights_rgb_color_twitch.py +++ b/commands/implemented/command_lights_rgb_color_twitch.py @@ -17,41 +17,51 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta): super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH) def do_command(self, bot, twitch_message): + if bot.allow_rgbLightControl == True: LightModule = lights_module.Lights_Module() LightModule.main() - print("\nRGB Command Detected!") + #print("\nRGB Command Detected!") tempParsedMessage = twitch_message.text.split(" ") - print("\nParsed Command! ", twitch_message.text) + sceneCommand = False if (len(tempParsedMessage)) > 2: - print("\nRGB Command!") + print("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) - print("got XY") + #print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + print("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: - print("\nColor Command!") + print("Color Command!") xy_result = LightModule.color_string_parser(tempParsedMessage) - print("got XY") + #print("got XY") LightModule.bridge_.set_group(16, "xy", xy_result) - print("sent color") + print("sent color to [Lights_Module]") + + if sceneCommand == True: + print("Scene Command!") 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 a0a077a..53e8eec 100644 --- a/config.py +++ b/config.py @@ -44,6 +44,11 @@ autoEnabled_Discord_rgbLightControl = False #Chyron Module Configs chyronListSpaceCount = 25 + +#Lights Module Configs +colorParse_maxDigits = 4 + + #General Configs skip_splashScreen = False skip_splashScreenClear = False diff --git a/lights_module.py b/lights_module.py index 63a366b..4fb9d08 100644 --- a/lights_module.py +++ b/lights_module.py @@ -14,7 +14,7 @@ class Lights_Module(): self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - print("Starting up Lights_Modules....") + print("Starting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -24,11 +24,11 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - print("\n -Listing Lights...") + #print("\n -Listing Lights...") for l in light_list: pass #print(l.name) - print("\n -Counting Groups...") + #print("\n -Counting Groups...") for g in groups: #print(g) groupCount = int(g) @@ -65,7 +65,7 @@ class Lights_Module(): # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - print("\n Setup Complete") + print("-[Lights_Module] Setup Complete") def setLight(): pass @@ -117,23 +117,23 @@ class Lights_Module(): return [x, y] def color_string_parser(self, message): - maxDigits = 4 - print("trying to find color") + maxDigits = config.colorParse_maxDigits + print("Searching for color...") xy_color = [0, 0] for text in message: #print("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - print("found: red") + print("-found: red") if "blue" in text.lower(): - print("found: blue") + print("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - print("found: green") + print("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - print("found: yellow") + print("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -141,23 +141,23 @@ class Lights_Module(): if "cyan" in text.lower(): - print("found: cyan") + print("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - print("found: aquamarine") + 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") + 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") + print("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -165,21 +165,21 @@ class Lights_Module(): if "magenta" in text.lower(): - print("found: magenta") + print("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - print("found: purple") + 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") + 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), -- 2.45.2 From 974385242f4ebfd6adf040e02f1cbd037434b12c Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:33:06 -0400 Subject: [PATCH 4/7] chyron file creation --- chyron_module.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/chyron_module.py b/chyron_module.py index 2e6e842..dfcc559 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -1,5 +1,6 @@ import config import utilities_script as utilities +import os class Chyron_Module(): def __init__(self): @@ -15,6 +16,7 @@ class Chyron_Module(): for x in range(config.chyronListSpaceCount): newString = newString + " " self.chyron_computedString = newString + return newString def addItem(self, name, title, content): newItem:ChyronItem = ChyronItem() @@ -28,6 +30,14 @@ class Chyron_Module(): def updateChyronFile(self): dir = utilities.get_dir("stream_sources") + script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in + relative_path = "stream_sources/chyron.txt" + real_file_path = os.path.join(script_dir, relative_path) + + file = open(real_file_path, "wb") + chyron = self.chyron_stringUpdater().encode("utf8") + file.write(chyron) + file.close class ChyronItem(): @@ -89,4 +99,6 @@ if __name__ == "__main__": testModule.chyron_stringUpdater() test = testModule.chyron_computedString + "<<<|" - print(test) \ No newline at end of file + print(test) + + testModule.updateChyronFile() \ No newline at end of file -- 2.45.2 From 2f03daafa7cac09bde8889032d909c4ab4aa5770 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:57:54 -0400 Subject: [PATCH 5/7] Added Chyron Command --- chyron_module.py | 59 ++++++++++++++------------ commands/implemented/command_chyron.py | 35 +++++++++++++++ 2 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 commands/implemented/command_chyron.py diff --git a/chyron_module.py b/chyron_module.py index dfcc559..c5713a7 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -8,6 +8,36 @@ class Chyron_Module(): self.chyron_computedString = "" self.chyron_items:list = [] + def main(self, rightNow_ = "Chill Stream"): + self.addItem( + "RightNow", + "► Now: ", + rightNow_) + self.addItem( + "WeekDays", + "► Weekdays: ", + "Daily Stream @ 12pm Noon EST") + self.addItem( + "FriSat", + "► Friday & Saturday: ", + "FFxiv (Express Delivery Raid Team) @ 7pm EST") + self.addItem( + "Commands", + "► Commands: ", + "!animal, !climateclock, !discord, !lights, !page, !roll") + self.addItem( + "Website", + "► Want to read about my various projects? visit: ", + "TheCuriousNerd.com") + self.addItem( + "Follow", + "", + "► If you like what you see, hit that follow button to see more!") + self.addItem( + "Discord", + "► Want to join our discord? type \" !d \" in chat to get the link or visit: ", + "discord.io/thecuriousnerd") + def chyron_stringUpdater(self): newString = "" for c in self.chyron_items: @@ -68,34 +98,7 @@ class ChyronItem(): if __name__ == "__main__": testModule = Chyron_Module() - testModule.addItem( - "RightNow", - "Now: ", - "Coding Stream") - testModule.addItem( - "WeekDays", - "► Weekdays: ", - "Daily Stream @ 12pm Noon EST") - testModule.addItem( - "FriSat", - "► Friday & Saturday: ", - "FFxiv (Express Delivery Raid Team) @ 7pm EST") - testModule.addItem( - "Commands", - "► Commands: ", - "!animal, !climateclock, !discord, !lights, !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.main() testModule.chyron_stringUpdater() test = testModule.chyron_computedString + "<<<|" diff --git a/commands/implemented/command_chyron.py b/commands/implemented/command_chyron.py new file mode 100644 index 0000000..16af567 --- /dev/null +++ b/commands/implemented/command_chyron.py @@ -0,0 +1,35 @@ +from abc import ABCMeta +import chyron_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 = "chyron" + + def __init__(self): + super().__init__(CommandRoll.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis) + + def do_command(self, bot, user_message): + tempBool = True + if tempBool == True: + tempParsedMessage = user_message.message.split(" ") + i = len(tempParsedMessage) + + if i > 1: + if "update" in tempParsedMessage[1]: + chyron = chyron_module.Chyron_Module() + if i > 2: + chyron.main(tempParsedMessage[2]) + else: + chyron.main() + chyron.updateChyronFile() + + returnMessage = "@" + user_message.user + " updated the chyron!" + bot.return_message(returnMessage) \ No newline at end of file -- 2.45.2 From a38de89275fe49585f6f01ee4c127491e455582c Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 18:00:22 -0400 Subject: [PATCH 6/7] typo --- chyron_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chyron_module.py b/chyron_module.py index c5713a7..d032ac4 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -31,8 +31,8 @@ class Chyron_Module(): "TheCuriousNerd.com") self.addItem( "Follow", - "", - "► If you like what you see, hit that follow button to see more!") + "► ", + "If you like what you see, hit that follow button to see more!") self.addItem( "Discord", "► Want to join our discord? type \" !d \" in chat to get the link or visit: ", -- 2.45.2 From dbff4e9e3c69da5f9b8646cdab7c66a291388d17 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 18:04:01 -0400 Subject: [PATCH 7/7] fixed typo --- 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 7606798..243b98a 100644 --- a/commands/implemented/command_lights_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 = "!lights" + command = "lights" def __init__(self): super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.Praxis) -- 2.45.2