Improved Commands
This commit is contained in:
parent
cd5b1b0df8
commit
3bbd5d1611
23
commands/implemented/command_clear.py
Normal file
23
commands/implemented/command_clear.py
Normal file
@ -0,0 +1,23 @@
|
||||
from abc import ABCMeta
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
import utilities_script as utility
|
||||
|
||||
class Command_Clear(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the clear command.
|
||||
"""
|
||||
command = "clear"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(Command_Clear.command, n_args=1, command_type=AbstractCommand.CommandType.Praxis)
|
||||
self.help = ["This is a command to clear the screen.",
|
||||
"\nExample:","clear"]
|
||||
self.isCommandEnabled = True
|
||||
|
||||
def do_command(self, bot, user_message):
|
||||
utility.clearScreen()
|
||||
|
||||
def get_help(self):
|
||||
return self.help
|
||||
25
commands/implemented/command_exit.py
Normal file
25
commands/implemented/command_exit.py
Normal file
@ -0,0 +1,25 @@
|
||||
from abc import ABCMeta
|
||||
|
||||
import time
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
class Command_Exit(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the exit command.
|
||||
"""
|
||||
command = "exit"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(Command_Exit.command, n_args=1, command_type=AbstractCommand.CommandType.Praxis)
|
||||
self.help = ["This is a command to exit [User Module].",
|
||||
"\nExample:","exit"]
|
||||
self.isCommandEnabled = True
|
||||
|
||||
def do_command(self, bot, user_message):
|
||||
bot.return_message("\nQuitting [User Module] Interface...")
|
||||
time.sleep(0.2)
|
||||
bot.inputLoop = False
|
||||
|
||||
def get_help(self):
|
||||
return self.help
|
||||
@ -7,14 +7,14 @@ import random
|
||||
|
||||
import utilities_script as utilities
|
||||
|
||||
class CommandChyron(AbstractCommand, metaclass=ABCMeta):
|
||||
class Command_Help(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the help command.
|
||||
"""
|
||||
command = "help"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(CommandChyron.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis)
|
||||
super().__init__(Command_Help.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis)
|
||||
self.help = ["This is a command to learn more about other commands.",
|
||||
"\nExample:","help \"COMMAND\""]
|
||||
self.isCommandEnabled = True
|
||||
@ -35,7 +35,7 @@ class CommandChyron(AbstractCommand, metaclass=ABCMeta):
|
||||
bot.return_message(returnMessage)
|
||||
elif i == 1:
|
||||
commandsList = "\n" + self.blockDecor + "Commands List:" + self.blockDecor + self.GetCommandsList(bot) + self.blockDecor
|
||||
print(commandsList)
|
||||
bot.return_message(commandsList)
|
||||
|
||||
def GetCommandsList(self, bot):
|
||||
commandsList = ""
|
||||
|
||||
@ -24,19 +24,19 @@ class CommandLights_Praxis(AbstractCommand, metaclass=ABCMeta):
|
||||
if tempBool == True:
|
||||
LightModule = lights_module.Lights_Module()
|
||||
LightModule.main()
|
||||
#print("\nRGB Command Detected!")
|
||||
#bot.return_message("\nRGB Command Detected!")
|
||||
|
||||
tempParsedMessage = user_message.message.split(" ")
|
||||
sceneCommand = False
|
||||
if (len(tempParsedMessage)) > 2:
|
||||
print("RGB Command!")
|
||||
bot.return_message("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")
|
||||
#bot.return_message("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color to [Lights_Module]")
|
||||
bot.return_message("sent color to [Lights_Module]")
|
||||
else:
|
||||
if "stream" in tempParsedMessage:
|
||||
sceneCommand = True
|
||||
@ -57,16 +57,16 @@ class CommandLights_Praxis(AbstractCommand, metaclass=ABCMeta):
|
||||
sceneCommand = True
|
||||
LightModule.raveMode()
|
||||
else:
|
||||
print("Color Command!")
|
||||
bot.return_message("Color Command!")
|
||||
xy_result = LightModule.color_string_parser(tempParsedMessage)
|
||||
#print("got XY")
|
||||
#bot.return_message("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color to [Lights_Module]")
|
||||
bot.return_message("sent color to [Lights_Module]")
|
||||
|
||||
if sceneCommand == True:
|
||||
print("Scene Command!")
|
||||
bot.return_message("Scene Command!")
|
||||
|
||||
returnMessage = "@" + user_message.user + " changed the light's color!"
|
||||
returnMessage = "@" + user_message.user.name + " changed the light's color!\n"
|
||||
bot.return_message(returnMessage)
|
||||
|
||||
def get_help(self):
|
||||
@ -132,7 +132,7 @@ class CommandLights_Twitch(AbstractCommand, metaclass=ABCMeta):
|
||||
if sceneCommand == True:
|
||||
print("Scene Command!")
|
||||
|
||||
returnMessage = "@" + twitch_message.sender + " changed the light's color!"
|
||||
returnMessage = "@" + twitch_message.sender + " changed the light's color!\n"
|
||||
bot.send_message(returnMessage)
|
||||
|
||||
def get_help(self):
|
||||
|
||||
@ -14,7 +14,7 @@ class Lights_Module():
|
||||
self.bridge_:Bridge = Bridge('192.168.191.146')
|
||||
|
||||
def main(self):
|
||||
print("Starting up [Lights_Module]...")
|
||||
print("\nStarting up [Lights_Module]...")
|
||||
self.bridge_.connect()
|
||||
|
||||
self.bridge_.get_api()
|
||||
|
||||
@ -23,24 +23,20 @@ class User_Module():
|
||||
UserFlagTypes.REACTIVE: self.eval_commands_Special_Reactive}
|
||||
|
||||
self.currentUser:User = User()
|
||||
self.inputLoop = True
|
||||
|
||||
def main(self):
|
||||
time.sleep(.01)
|
||||
print("\nWaiting on User input...\n\n")
|
||||
inputLoop = True
|
||||
if utility.isRunningInDocker() == True:
|
||||
inputLoop = False
|
||||
self.inputLoop = False
|
||||
print("\nNo User's Input Allowed")
|
||||
while inputLoop:
|
||||
|
||||
while self.inputLoop:
|
||||
keyboardInput = input()
|
||||
message = UserMessage()
|
||||
message.makeMessage(self.currentUser, keyboardInput)
|
||||
|
||||
if "exit" in keyboardInput:
|
||||
print("Quitting [User Module] Interface...")
|
||||
inputLoop = False
|
||||
break
|
||||
|
||||
self.parseInput(message)
|
||||
|
||||
def parseInput(self, message):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user