Added Lights Command to User Module
This commit is contained in:
parent
15abdc16f3
commit
0ae1cd880d
58
commands/implemented/command_lights_rgb_color.py
Normal file
58
commands/implemented/command_lights_rgb_color.py
Normal file
@ -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)
|
||||||
@ -13,34 +13,37 @@ class User_Module():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.dbCredential: credentials.DB_Credential
|
self.dbCredential: credentials.DB_Credential
|
||||||
|
self.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis)
|
||||||
self.MessageLog:list = []
|
self.MessageLog:list = []
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
print("Waiting on User input...")
|
print("\nWaiting on User input...")
|
||||||
inputLoop = True
|
inputLoop = True
|
||||||
while inputLoop:
|
while inputLoop:
|
||||||
keyboardInput = input()
|
keyboardInput = input()
|
||||||
|
message = UserMessage()
|
||||||
|
message.makeMessage(message=keyboardInput)
|
||||||
|
|
||||||
if "exit" in keyboardInput:
|
if "exit" in keyboardInput:
|
||||||
print("Quitting User Module Interface...")
|
print("Quitting User Module Interface...")
|
||||||
inputLoop = False
|
inputLoop = False
|
||||||
break
|
break
|
||||||
|
|
||||||
self.parseInput(keyboardInput)
|
self.parseInput(message)
|
||||||
|
|
||||||
def parseInput(self, input):
|
def parseInput(self, message):
|
||||||
if self.isCommand(input):
|
if self.isCommand(message) == True:
|
||||||
self.runCommand(input)
|
self.runCommand(message)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def isCommand(self, input):
|
def isCommand(self, message):
|
||||||
isCommand = True
|
isCommand = True
|
||||||
#MAKE THIS
|
#MAKE THIS
|
||||||
return isCommand
|
return isCommand
|
||||||
|
|
||||||
def runCommand(self, input):
|
def runCommand(self, message):
|
||||||
self.eval_commands(input)
|
self.eval_commands(message)
|
||||||
|
|
||||||
def eval_commands(self, message):
|
def eval_commands(self, message):
|
||||||
# containsURL: bool = self.contains_url(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
|
# This fixes a error where if you send a command without arguments it fails because
|
||||||
# it cant find the substring.
|
# it cant find the substring.
|
||||||
if message.content.find(" ") != -1:
|
if message.message.find(" ") != -1:
|
||||||
first_space_idx = message.content.index(' ')
|
first_space_idx = message.message.index(' ')
|
||||||
else:
|
else:
|
||||||
first_space_idx = -1
|
first_space_idx = -1
|
||||||
|
|
||||||
command_text = ' '
|
command_text = ' '
|
||||||
if first_space_idx > -1:
|
if first_space_idx > -1:
|
||||||
command_text = message.content[0:first_space_idx]
|
command_text = message.message[0:first_space_idx]
|
||||||
else:
|
else:
|
||||||
command_text = message.content
|
command_text = message.message
|
||||||
|
|
||||||
command = self.commands[command_text]
|
command = self.commands[command_text]
|
||||||
if command is not None and command.command_type is AbstractCommand.CommandType.Praxis:
|
if command is not None and command.command_type is AbstractCommand.CommandType.Praxis:
|
||||||
@ -68,9 +71,19 @@ class User_Module():
|
|||||||
#print(e)
|
#print(e)
|
||||||
pass # we don't care
|
pass # we don't care
|
||||||
|
|
||||||
def tts_message(self, message):
|
def tts(self, message):
|
||||||
tts.tts(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__":
|
if __name__ == "__main__":
|
||||||
testModule = User_Module()
|
testModule = User_Module()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user