master branch updates #19

Merged
alex_orid merged 32 commits from master into db-module 2021-04-09 20:43:03 +00:00
4 changed files with 88 additions and 41 deletions
Showing only changes of commit 93c0e182ed - Show all commits

View File

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

View File

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

View File

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

View File

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