diff --git a/.gitignore b/.gitignore index 06e3763..96f3a00 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ credentials/ .idea/ stream_sources/chyron.txt stream_sources/brb.txt -*.log \ No newline at end of file +*.log +*.log diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py index ccde22b..ef78d03 100644 --- a/commands/implemented/Command_lights_v2.py +++ b/commands/implemented/Command_lights_v2.py @@ -1,9 +1,10 @@ from abc import ABCMeta -import lights_module from commands.command_base import AbstractCommand -import utilities_script as utility +from json import loads +from urllib.parse import urlencode +import requests class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): """ @@ -20,56 +21,26 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): returnString = "" - tempBool = True - if tempBool == True: - LightModule = lights_module.Lights_Module() - LightModule.main() - #bot.return_message("\nRGB Command Detected!") - tempFix = command + " " + rest - - tempParsedMessage = tempFix.split(" ") - sceneCommand = False - if (len(tempParsedMessage)) > 2: - #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) - #bot.return_message("got XY") - LightModule.bridge_.set_group(16, "xy", xy_result) - #bot.return_message("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: - #bot.return_message("Color Command!") - xy_result = LightModule.color_string_parser(tempParsedMessage) - #bot.return_message("got XY") - LightModule.bridge_.set_group(16, "xy", xy_result) - #bot.return_message("sent color to [Lights_Module]") - - #if sceneCommand == True: - #bot.return_message("Scene Command!") - - returnString = user + " changed the light's color!" + returnString = self.dothething(user, 16, "!lights hydration", "") return returnString + def dothething(self, username, light_group, command, rest): + # todo need to url-escape command and rest + params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) + #standalone_lights + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params + resp = requests.get(url) + if resp.status_code == 200: + print("Got the following message: %s" % resp.text) + data = loads(resp.text) + msg = data['message'] + if msg is not None: + return msg + # todo send to logger and other relevent services + else: + # todo handle failed requests + pass + def get_help(self): return self.help \ No newline at end of file diff --git a/logs/standalone_channelrewards.py.log b/logs/standalone_channelrewards.py.log index bf8cf84..34a165d 100644 --- a/logs/standalone_channelrewards.py.log +++ b/logs/standalone_channelrewards.py.log @@ -10,3 +10,29 @@ INFO:root:init stuff WARNING:werkzeug: * Debugger is active! INFO:werkzeug: * Debugger PIN: 760-498-562 INFO:werkzeug: * Running on http://0.0.0.0:6969/ (Press CTRL+C to quit) +INFO:root:Application running! +INFO:root: + -Starting Logs: standalone_channelrewards.py +INFO:root:init stuff +INFO:werkzeug: * Running on http://0.0.0.0:6969/ (Press CTRL+C to quit) +INFO:werkzeug: * Restarting with stat +INFO:root:Application running! +INFO:root: + -Starting Logs: standalone_channelrewards.py +INFO:root:init stuff +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 758-762-350 +INFO:root:Application running! +INFO:root: + -Starting Logs: standalone_channelrewards.py +INFO:root:init stuff +INFO:werkzeug: * Running on http://0.0.0.0:6969/ (Press CTRL+C to quit) +INFO:werkzeug: * Restarting with stat +INFO:root:Application running! +INFO:root: + -Starting Logs: standalone_channelrewards.py +INFO:root:init stuff +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 181-543-254 +INFO:werkzeug:192.168.48.7 - - [28/Apr/2021 04:44:07] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug:192.168.48.7 - - [28/Apr/2021 04:44:13] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - diff --git a/standalone_lights.py b/standalone_lights.py index 2907fc8..1d2f850 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -11,11 +11,16 @@ import config import flask from flask import request +import os +import praxis_logging +praxis_logger_obj = praxis_logging.praxis_logger() +praxis_logger_obj.init(os.path.basename(__file__)) +praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) + api = flask.Flask(__name__) # enable/disable this to get web pages of crashes returned api.config["DEBUG"] = True - class Lights_Module(): def __init__(self): super().__init__() @@ -73,7 +78,7 @@ class Lights_Module(): # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - self.bridge_.run_scene("Downstairs", "Stream") + #self.bridge_.run_scene("Downstairs", "Stream") print("-[Lights_Module] Setup Complete") def setLight(): diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index aec0c4c..5ffb7fd 100644 --- a/standalone_twitch_pubsub.py +++ b/standalone_twitch_pubsub.py @@ -20,6 +20,12 @@ from uuid import UUID from cooldowns import Cooldown_Module +import os +import praxis_logging +praxis_logger_obj = praxis_logging.praxis_logger() +praxis_logger_obj.init(os.path.basename(__file__)) +praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) + class Twitch_Pubsub(): def __init__(self): super().__init__() diff --git a/standalone_twitch_script.py b/standalone_twitch_script.py index bb0f82d..fa3d0c9 100644 --- a/standalone_twitch_script.py +++ b/standalone_twitch_script.py @@ -12,6 +12,12 @@ from cooldowns import Cooldown_Module import commands.command_base import utilities_script as utility +import os +import praxis_logging +praxis_logger_obj = praxis_logging.praxis_logger() +praxis_logger_obj.init(os.path.basename(__file__)) +praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) + class Twitch_Module(): def __init__(self): super().__init__()