master updates #22

Merged
alex_orid merged 10 commits from master into db-module 2021-04-09 22:06:25 +00:00
7 changed files with 151 additions and 59 deletions

View File

@ -1,4 +1,6 @@
import config
import utilities_script as utilities
import os
class Chyron_Module():
def __init__(self):
@ -6,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:
@ -14,6 +46,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()
@ -25,6 +58,17 @@ class Chyron_Module():
if c.itemName == name:
self.chyron_items.remove(c)
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():
def __init__(self):
@ -54,31 +98,10 @@ class ChyronItem():
if __name__ == "__main__":
testModule = Chyron_Module()
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.main()
testModule.chyron_stringUpdater()
test = testModule.chyron_computedString + "<<<|"
print(test)
print(test)
testModule.updateChyronFile()

View File

@ -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)

View File

@ -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)
@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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),

View File

@ -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(" ")