From 292b54d353ad51a679e3d0557d54c243e8bbac37 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 16:41:38 -0400 Subject: [PATCH 1/5] 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(" ") From 684b22f451af7dd921f3cfcf4c80c8806f57d029 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:02:18 -0400 Subject: [PATCH 2/5] 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: ", From 974385242f4ebfd6adf040e02f1cbd037434b12c Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:33:06 -0400 Subject: [PATCH 3/5] 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 From 2f03daafa7cac09bde8889032d909c4ab4aa5770 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 17:57:54 -0400 Subject: [PATCH 4/5] 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 From a38de89275fe49585f6f01ee4c127491e455582c Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Fri, 9 Apr 2021 18:00:22 -0400 Subject: [PATCH 5/5] 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: ",