From 642c3cde5d22acc9266e034fa585545b9ea1f163 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 14:56:11 -0400 Subject: [PATCH 01/14] initial script --- standalone_lights.py | 274 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 standalone_lights.py diff --git a/standalone_lights.py b/standalone_lights.py new file mode 100644 index 0000000..09bb245 --- /dev/null +++ b/standalone_lights.py @@ -0,0 +1,274 @@ +from time import sleep +import phue +from phue import Bridge + +import random +import utilities_script as utilities + +import credentials +import config + +import flask +from flask import request + +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__() + self.bridge_:Bridge = Bridge('192.168.191.146') + + def main(self): + print("\nStarting up [Lights_Module]...") + self.bridge_.connect() + + self.bridge_.get_api() + + light_list = self.bridge_.lights + group_list:list = [] + groups = self.bridge_.get_group() + groupCount = 0 + + #print("\n -Listing Lights...") + for l in light_list: + pass + #print(l.name) + #print("\n -Counting Groups...") + for g in groups: + #print(g) + groupCount = int(g) + + + for gc in range(groupCount): + try: + #print("group n:" + str(gc)) + group = self.bridge_.get_group(gc ,'name') + #print(group) + group_list.append(group) + #print(" --done adding") + except: + pass + #print(" --adding failed") + + #self.bridge_.set_group(18, "bri", 254) #This is max Brightness + #self.bridge_.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.bridge_.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(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 + #self.bridge_.set_group(16, "xy", xy_result) + #sleep(0.1) + + #for stuffz in self.bridge_.scenes: + #print(stuffz) + + # This will set the group Downstairs to the Stream scene + #self.bridge_.run_scene("Downstairs", "Stream") + + print("-[Lights_Module] Setup Complete") + + def setLight(): + pass + + def setLights(): + pass + + def setGroup(): + pass + + def setGroups(): + pass + + def raveMode(self): + for rave in range(30): + 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 + self.bridge_.set_group(16, "xy", xy_result) + sleep(0.3) + self.bridge_.run_scene("Downstairs", "Stream") + + def rgb_to_xy(self, red, green, blue): + """ conversion of RGB colors to CIE1931 XY colors + Formulas implemented from: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d + Args: + red (float): a number between 0.0 and 1.0 representing red in the RGB space + green (float): a number between 0.0 and 1.0 representing green in the RGB space + blue (float): a number between 0.0 and 1.0 representing blue in the RGB space + Returns: + xy (list): x and y + """ + # gamma correction + red = pow((red + 0.055) / (1.0 + 0.055), 2.4) if red > 0.04045 else (red / 12.92) + green = pow((green + 0.055) / (1.0 + 0.055), 2.4) if green > 0.04045 else (green / 12.92) + blue = pow((blue + 0.055) / (1.0 + 0.055), 2.4) if blue > 0.04045 else (blue / 12.92) + + # convert rgb to xyz + x = red * 0.649926 + green * 0.103455 + blue * 0.197109 + y = red * 0.234327 + green * 0.743075 + blue * 0.022598 + z = green * 0.053077 + blue * 1.035763 + + # convert xyz to xy + x = x / (x + y + z) + y = y / (x + y + z) + + # TODO check color gamut if known + return [x, y] + + def color_string_parser(self, message): + 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") + if "blue" in text.lower(): + print("-found: blue") + xy_color = self.rgb_to_xy(0,0,1) + if "green" in text.lower(): + print("-found: green") + xy_color = self.rgb_to_xy(0,1,0) + + if "yellow" in text.lower(): + print("-found: yellow") + xy_color = self.rgb_to_xy( + 0.7, + 0.64, + 0) + + + if "cyan" in text.lower(): + print("-found: cyan") + xy_color = self.rgb_to_xy(0,1,1) + if "aquamarine" in text.lower(): + 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") + 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") + xy_color = self.rgb_to_xy( + 1, + round(utilities.rescale_value(126,0,254),maxDigits), + 0) + + + if "magenta" in text.lower(): + print("-found: magenta") + xy_color = self.rgb_to_xy( + 1, + 0, + 1) + + if "purple" in text.lower(): + 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") + xy_color = self.rgb_to_xy( + round(utilities.rescale_value(237,0,254),maxDigits), + round(utilities.rescale_value(129,0,254),maxDigits), + round(utilities.rescale_value(237,0,254),maxDigits)) + + return xy_color + + +RGB_Lights = Lights_Module() + +def init(): + RGB_Lights.main() + +def do_light_command(user="", lightGroup="all", command = "", rest = ""): + returnString = "" + + tempBool = True + if tempBool == True: + #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 = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) + #bot.return_message("got XY") + RGB_Lights.bridge_.set_group(16, "xy", xy_result) + #bot.return_message("sent color to [Lights_Module]") + else: + if "stream" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "Stream") + elif "normal" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "Bright") + elif "haxor" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "hacker vibes") + elif "off" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.set_group("Downstairs", "on", False) + elif "on" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.set_group("Downstairs", "on", True) + elif "ravemode" in tempParsedMessage: + sceneCommand = True + RGB_Lights.raveMode() + else: + #bot.return_message("Color Command!") + xy_result = RGB_Lights.color_string_parser(tempParsedMessage) + #bot.return_message("got XY") + RGB_Lights.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!" + + return returnString + + + +@api.route('/api/v1/exec_lights', methods=['GET']) +def exec_command(): + if 'user_name' not in request.args: + user_name="User" + else: + user_name=request.args['user_name'] + if 'light_group' not in request.args: + return flask.make_response('{\"text\":"Argument \'light_group\' not in request"}', 400) + if 'command' not in request.args: + return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) + + return do_light_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) + +if __name__ == "__main__": + init() + + #testModule.raveMode() \ No newline at end of file -- 2.45.2 From 41afb81df073b9fc4d58f12fc239955c6151a521 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 16:28:21 -0400 Subject: [PATCH 02/14] Lights API Commands --- Dockerfile_standalone_channelRewards | 2 +- Dockerfile_standalone_lights | 11 +++ .../implemented/ChannelReward_Hydration.py | 21 ++++ docker-compose.yaml | 6 ++ makedockerimages.bat | 1 + standalone_channelrewards.py | 19 ++-- standalone_lights.py | 95 ++++++++++--------- 7 files changed, 103 insertions(+), 52 deletions(-) create mode 100644 Dockerfile_standalone_lights diff --git a/Dockerfile_standalone_channelRewards b/Dockerfile_standalone_channelRewards index b5d541e..67dac01 100644 --- a/Dockerfile_standalone_channelRewards +++ b/Dockerfile_standalone_channelRewards @@ -1,4 +1,4 @@ -FROM python:3.10.0a7-alpine3.13 +FROM python:3.7.10-alpine3.12 WORKDIR /Praxis diff --git a/Dockerfile_standalone_lights b/Dockerfile_standalone_lights new file mode 100644 index 0000000..aba1f7e --- /dev/null +++ b/Dockerfile_standalone_lights @@ -0,0 +1,11 @@ +FROM python:3.7.10-alpine3.12 + +WORKDIR /Praxis + +COPY requirements_sa_command.txt requirements_sa_command.txt +RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/* +RUN pip3 install -r requirements_sa_command.txt + +COPY . . + +CMD [ "python3", "standalone_lights.py"] \ No newline at end of file diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index e3d94cb..d777da2 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -2,6 +2,10 @@ from abc import ABCMeta from channel_rewards.channelRewards_base import AbstractChannelRewards +from json import loads +from urllib.parse import urlencode +import requests + class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): """ this is the hydration reward. @@ -14,8 +18,25 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): self.isChannelRewardEnabled = True def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None): + self.dothething(user, "16", "lights hydration") return None + def dothething(self, username, light_group, command): + # todo need to url-escape command and rest + params = urlencode({'user_name': username, 'light_group': light_group, 'command': command}) + 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: + pass + # 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/docker-compose.yaml b/docker-compose.yaml index fbf0e1b..cfe798c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,6 +12,12 @@ services: - 6969:6969 environment: - ISDOCKER=cat + standalone_lights: + image: standalone_lights + ports: + - 42069:42069 + environment: + - ISDOCKER=cat standalone_twitchscript: image: standalone_twitchscript environment: diff --git a/makedockerimages.bat b/makedockerimages.bat index f008b0e..fc288bc 100644 --- a/makedockerimages.bat +++ b/makedockerimages.bat @@ -1,5 +1,6 @@ docker build --file Dockerfile_standalone_command --tag standalone_command . docker build --file Dockerfile_standalone_channelRewards --tag standalone_channelrewards . +docker build --file Dockerfile_standalone_lights --tag standalone_lights . docker build --file Dockerfile_standalone_DiscordScript --tag standalone_discordscript . docker build --file Dockerfile_standalone_TwitchScript --tag standalone_twitchscript . docker build --file Dockerfile_standalone_Twitch_Pubsub --tag standalone_twitch_pubsub . \ No newline at end of file diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index d7f5632..2fa861a 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -22,9 +22,10 @@ def is_reward(reward_name, reward_type) -> bool: #global loadedRewards tempType = reward_type.replace('ChannelRewardsType.', '') realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] + #print(loadedRewards[realTempType]) for reward in loadedRewards[realTempType]: - print("found: ",reward,"type: ",type(reward)) + print("found: ", reward, "type: ", type(reward)) if reward_name == reward: print("Equal") return True @@ -38,13 +39,15 @@ def is_reward(reward_name, reward_type) -> bool: def handle_reward(source, username, reward_name, reward_type, rewardPrompt, userInput, bonusData): #reward:AbstractChannelRewards = loadedRewards[reward_name] - tempType = reward_type.replace('ChannelRewardsType.', '') - realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] - reward:AbstractChannelRewards = loadedRewards[realTempType][reward_name] - if reward is not None: - reward_response = reward.do_ChannelReward(source, username, reward_name, rewardPrompt, userInput, bonusData) - return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) - + try: + tempType = reward_type.replace('ChannelRewardsType.', '') + realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] + reward:AbstractChannelRewards = loadedRewards[realTempType][reward_name] + if reward is not None: + reward_response = reward.do_ChannelReward(source, username, reward_name, rewardPrompt, userInput, bonusData) + return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) + except: + return "None" #print("Doing a reward") diff --git a/standalone_lights.py b/standalone_lights.py index 09bb245..875a0d8 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -73,6 +73,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") print("-[Lights_Module] Setup Complete") def setLight(): @@ -87,6 +88,11 @@ class Lights_Module(): def setGroups(): pass + def hydration(self): + self.bridge_.run_scene("Downstairs", "hydration") + #sleep(20) + #self.bridge_.run_scene("Downstairs", "Stream") + def raveMode(self): for rave in range(30): rgb_r = random.random() @@ -202,61 +208,63 @@ def init(): RGB_Lights.main() def do_light_command(user="", lightGroup="all", command = "", rest = ""): - returnString = "" + returnString = "None" + print("about to do something ......") - tempBool = True - if tempBool == True: - #bot.return_message("\nRGB Command Detected!") - tempFix = command + " " + rest + #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 = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) + tempParsedMessage = tempFix.split(" ") + sceneCommand = False + if (len(tempParsedMessage)) > 2: + print("RGB Command!") + rgb_r = float(tempParsedMessage[1]) + rgb_g = float(tempParsedMessage[2]) + rgb_b = float(tempParsedMessage[3]) + xy_result = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) + print("got XY") + RGB_Lights.bridge_.set_group(16, "xy", xy_result) + #bot.return_message("sent color to [Lights_Module]") + else: + if "stream" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "Stream") + elif "normal" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "Bright") + elif "haxor" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.run_scene("Downstairs", "hacker vibes") + elif "off" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.set_group("Downstairs", "on", False) + elif "on" in tempParsedMessage: + sceneCommand = True + RGB_Lights.bridge_.set_group("Downstairs", "on", True) + elif "hydration" in tempParsedMessage: + sceneCommand = True + RGB_Lights.hydration() + elif "ravemode" in tempParsedMessage: + sceneCommand = True + RGB_Lights.raveMode() + else: + #bot.return_message("Color Command!") + xy_result = RGB_Lights.color_string_parser(tempParsedMessage) #bot.return_message("got XY") RGB_Lights.bridge_.set_group(16, "xy", xy_result) #bot.return_message("sent color to [Lights_Module]") - else: - if "stream" in tempParsedMessage: - sceneCommand = True - RGB_Lights.bridge_.run_scene("Downstairs", "Stream") - elif "normal" in tempParsedMessage: - sceneCommand = True - RGB_Lights.bridge_.run_scene("Downstairs", "Bright") - elif "haxor" in tempParsedMessage: - sceneCommand = True - RGB_Lights.bridge_.run_scene("Downstairs", "hacker vibes") - elif "off" in tempParsedMessage: - sceneCommand = True - RGB_Lights.bridge_.set_group("Downstairs", "on", False) - elif "on" in tempParsedMessage: - sceneCommand = True - RGB_Lights.bridge_.set_group("Downstairs", "on", True) - elif "ravemode" in tempParsedMessage: - sceneCommand = True - RGB_Lights.raveMode() - else: - #bot.return_message("Color Command!") - xy_result = RGB_Lights.color_string_parser(tempParsedMessage) - #bot.return_message("got XY") - RGB_Lights.bridge_.set_group(16, "xy", xy_result) - #bot.return_message("sent color to [Lights_Module]") - #if sceneCommand == True: - #bot.return_message("Scene Command!") + if sceneCommand == True: + print("Scene Command!") - returnString = user + " changed the light's color!" + returnString = user + " changed the light's color!" return returnString @api.route('/api/v1/exec_lights', methods=['GET']) -def exec_command(): +def exec_lights(): if 'user_name' not in request.args: user_name="User" else: @@ -266,9 +274,10 @@ def exec_command(): if 'command' not in request.args: return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) + print("about to do something ......") return do_light_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) if __name__ == "__main__": init() - + api.run(host='0.0.0.0', port=42069) #testModule.raveMode() \ No newline at end of file -- 2.45.2 From 87492e625a0016e75e8f17ec7b6238c45b6855ba Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 16:59:02 -0400 Subject: [PATCH 03/14] Working Version --- .../implemented/ChannelReward_Hydration.py | 8 +++++--- standalone_lights.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index d777da2..cb16a2c 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -18,13 +18,15 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): self.isChannelRewardEnabled = True def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None): - self.dothething(user, "16", "lights hydration") + #print("sending:",user, 16, "!lights hydration") + self.dothething(user, 16, "!lights hydration", "") return None - def dothething(self, username, light_group, command): + 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}) + 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: diff --git a/standalone_lights.py b/standalone_lights.py index 875a0d8..2907fc8 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -207,12 +207,16 @@ RGB_Lights = Lights_Module() def init(): RGB_Lights.main() -def do_light_command(user="", lightGroup="all", command = "", rest = ""): +def do_lights_command(user="", lightGroup="all", command = "", rest = ""): returnString = "None" print("about to do something ......") #bot.return_message("\nRGB Command Detected!") - tempFix = command + " " + rest + if rest is not "": + tempFix = command + " " + rest + else: + pass + tempFix = command tempParsedMessage = tempFix.split(" ") sceneCommand = False @@ -275,7 +279,8 @@ def exec_lights(): return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) print("about to do something ......") - return do_light_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) + RGB_Lights.main() + return do_lights_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) if __name__ == "__main__": init() -- 2.45.2 From b106eaa9dd3d40bf1b60b2d42f5967ac2259ba16 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 18:47:51 -0400 Subject: [PATCH 04/14] logging --- Command_Management_Module.py | 16 ++-- channel_rewards/channelRewards_loader.py | 16 ++-- .../implemented/ChannelReward_Hydration.py | 4 +- chyron_module.py | 10 ++- commands/implemented/Command_lights_v2.py | 74 ++++++------------- commands/implemented/Command_roll_v2.py | 4 +- commands/implemented/Command_test_v2.py | 2 +- commands/loader.py | 16 ++-- cooldowns.py | 36 +++++---- credentials.py | 30 ++++---- db.py | 4 +- help_module.py | 8 +- lights_module.py | 54 ++++++++------ logsStandAlone_Command.log | 16 ++++ main.py | 16 ++-- praxis_logging.py | 13 ++++ standalone_channelrewards.py | 20 +++-- standalone_command.py | 14 +++- standalone_discord_script.py | 28 ++++--- standalone_lights.py | 73 +++++++++--------- standalone_twitch_pubsub.py | 54 ++++++++------ standalone_twitch_script.py | 30 +++++--- standalone_webSource.py | 10 ++- tempText_Module.py | 9 ++- test_module.py | 8 +- tts.py | 11 ++- twitch_generate_credentials.py | 20 +++-- user_module.py | 14 +++- utilities_script.py | 21 ++++-- 29 files changed, 377 insertions(+), 254 deletions(-) create mode 100644 logsStandAlone_Command.log create mode 100644 praxis_logging.py diff --git a/Command_Management_Module.py b/Command_Management_Module.py index f8df757..1902e65 100644 --- a/Command_Management_Module.py +++ b/Command_Management_Module.py @@ -9,25 +9,31 @@ from commands.command_base import AbstractCommand import credentials +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 Command_Management_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential def main_test(self): - print("[TEST Module]> test") + praxis_logger_obj.log("[TEST Module]> test") tempModule = user_module.User_Module() #tempModule.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis) - print(self.getCommandsList(tempModule.commands)) + praxis_logger_obj.log(self.getCommandsList(tempModule.commands)) def getCommandsList(self, targetModuleCommands): - print(type(targetModuleCommands)) + praxis_logger_obj.log(type(targetModuleCommands)) commandsList = "\n" for cmd in targetModuleCommands: targetCommand = targetModuleCommands[cmd] - print(targetCommand.command) - print(targetCommand.isCommandEnabled) + praxis_logger_obj.log(targetCommand.command) + praxis_logger_obj.log(targetCommand.isCommandEnabled) return commandsList diff --git a/channel_rewards/channelRewards_loader.py b/channel_rewards/channelRewards_loader.py index 8a2db6e..fd80bb4 100644 --- a/channel_rewards/channelRewards_loader.py +++ b/channel_rewards/channelRewards_loader.py @@ -1,7 +1,13 @@ import importlib import importlib.util import inspect + 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__)) + import sys from typing import Dict @@ -10,7 +16,7 @@ from channel_rewards.channelRewards_base import AbstractChannelRewards #New def load_rewards(channelRewardsType: AbstractChannelRewards.ChannelRewardsType) -> Dict[str, AbstractChannelRewards]: - print(" -Loading ", channelRewardsType ," ChannelRewards...\n") + praxis_logger_obj.log(" -Loading ", channelRewardsType ," ChannelRewards...\n") ChannelRewards = compile_and_load(channelRewardsType) return ChannelRewards @@ -26,10 +32,10 @@ def compile_and_load_file(path: str, channelRewardsType: AbstractChannelRewards. if inspect.isclass(obj) and name.startswith("ChannelReward"): ChannelReward_inst = obj() if channelRewardsType == ChannelReward_inst.get_ChannelRewardType(): - print(" ---Successfully loaded %s: %s" % (channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) + praxis_logger_obj.log(" ---Successfully loaded %s: %s" % (channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) return ChannelReward_inst.get_ChannelRewardName(), ChannelReward_inst elif channelRewardsType != ChannelReward_inst.get_ChannelRewardType(): - print(" -%s ChannelRewardsType did not match: %s for: %s" % (ChannelReward_inst.get_ChannelRewardType(), channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) + praxis_logger_obj.log(" -%s ChannelRewardsType did not match: %s for: %s" % (ChannelReward_inst.get_ChannelRewardType(), channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) return "", None @@ -40,7 +46,7 @@ def compile_and_load(ChannelRewardType: AbstractChannelRewards.ChannelRewardsTyp for dirName, subdirList, fileList in os.walk(implementations): for file in fileList: name = os.path.join(dirName, file) - print("compiling: %s" % name) + praxis_logger_obj.log("compiling: %s" % name) name, reward = compile_and_load_file(name, ChannelRewardType) if reward is not None and reward.ChannelRewardType is ChannelRewardType: dic[name] = reward @@ -56,7 +62,7 @@ def get_base_dir() -> str: elif current == 'Praxis_Bot' or current == 'Praxis': return check_dir(os.path.join(cwd, "channel_rewards")) else: - print("could not find working directory for Praxis_Bot/channel_rewards") + praxis_logger_obj.log("could not find working directory for Praxis_Bot/channel_rewards") raise Exception diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index cb16a2c..4ca908d 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -18,8 +18,6 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): self.isChannelRewardEnabled = True def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None): - - #print("sending:",user, 16, "!lights hydration") self.dothething(user, 16, "!lights hydration", "") return None @@ -30,7 +28,7 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): 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) + praxis_logger_obj.log("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: diff --git a/chyron_module.py b/chyron_module.py index 1eed58a..44df435 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -1,6 +1,10 @@ import config import utilities_script as utilities 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 Chyron_Module(): def __init__(self): @@ -77,7 +81,7 @@ class Chyron_Module(): file = open(real_file_path, "rb") text = file.read() - #print(text) + #praxis_logger_obj.log(text) file.close return text @@ -94,7 +98,7 @@ class ChyronItem(): self.itemComputedString = "" def setupItem(self, name, title, content): - print("\nSetting up Item {", name,"}[", title, content, "]") + praxis_logger_obj.log("\nSetting up Item {", name,"}[", title, content, "]") self.itemName = name self.itemTitle = title self.itemContent = content @@ -114,6 +118,6 @@ if __name__ == "__main__": testModule.chyron_stringUpdater() test = testModule.chyron_computedString + "<<<|" - print(test) + praxis_logger_obj.log(test) testModule.updateChyronFile() \ No newline at end of file diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py index ccde22b..ed99c3d 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): """ @@ -18,58 +19,27 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): self.isCommandEnabled = True def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): - returnString = "" + returnString = self.dothething(user, 16, command, rest) + praxis_logger_obj.log(returnString) - tempBool = True - if tempBool == True: - LightModule = lights_module.Lights_Module() - LightModule.main() - #bot.return_message("\nRGB Command Detected!") - tempFix = command + " " + rest + return None - 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!" - - 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: + praxis_logger_obj.log("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/commands/implemented/Command_roll_v2.py b/commands/implemented/Command_roll_v2.py index a174567..7da6f48 100644 --- a/commands/implemented/Command_roll_v2.py +++ b/commands/implemented/Command_roll_v2.py @@ -47,7 +47,7 @@ class Command_roll_v2(AbstractCommand, metaclass=ABCMeta): loopBool = False if roll_type == 1: - print("-rolling...") + praxis_logger_obj.log("-rolling...") # If roll is in xdx+x format if loopBool == True: rolls: list = [] @@ -78,7 +78,7 @@ class Command_roll_v2(AbstractCommand, metaclass=ABCMeta): if roll_type == 2: - print("-fate Rolling....") + praxis_logger_obj.log("-fate Rolling....") # !roll 4df # If roll is in xdx+x format if loopBool == True: diff --git a/commands/implemented/Command_test_v2.py b/commands/implemented/Command_test_v2.py index 18995d3..512a265 100644 --- a/commands/implemented/Command_test_v2.py +++ b/commands/implemented/Command_test_v2.py @@ -18,7 +18,7 @@ class Command_test_v2(AbstractCommand, metaclass=ABCMeta): def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): returnString = user + " sent: [ " + command + " ] with: " + rest - #print(returnString) + #praxis_logger_obj.log(returnString) return returnString def get_help(self): diff --git a/commands/loader.py b/commands/loader.py index a92b544..5d4d215 100644 --- a/commands/loader.py +++ b/commands/loader.py @@ -1,7 +1,13 @@ import importlib import importlib.util import inspect + 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__)) + import sys from typing import Dict @@ -10,7 +16,7 @@ from commands.command_base import AbstractCommand #New def load_commands(commandType: AbstractCommand.CommandType) -> Dict[str, AbstractCommand]: - print(" -Loading ", commandType ," Commands...\n") + praxis_logger_obj.log(" -Loading ", commandType ," Commands...\n") commands = compile_and_load(commandType) return commands @@ -26,10 +32,10 @@ def compile_and_load_file(path: str, commandType: AbstractCommand.CommandType): if inspect.isclass(obj) and name.startswith("Command"): command_inst = obj() if commandType == command_inst.get_commandType(): - print(" ---Successfully loaded %s: %s" % (commandType, command_inst.get_command())) + praxis_logger_obj.log(" ---Successfully loaded %s: %s" % (commandType, command_inst.get_command())) return command_inst.get_command(), command_inst elif commandType != command_inst.get_commandType(): - print(" -%s CommandType did not match: %s for: %s" % (command_inst.get_commandType(), commandType, command_inst.get_command())) + praxis_logger_obj.log(" -%s CommandType did not match: %s for: %s" % (command_inst.get_commandType(), commandType, command_inst.get_command())) return "", None @@ -40,7 +46,7 @@ def compile_and_load(commandType: AbstractCommand.CommandType) -> Dict[str, Abst for dirName, subdirList, fileList in os.walk(implementations): for file in fileList: name = os.path.join(dirName, file) - print("compiling: %s" % name) + praxis_logger_obj.log("compiling: %s" % name) name, command = compile_and_load_file(name, commandType) if command is not None and command.command_type is commandType: dic[name] = command @@ -56,7 +62,7 @@ def get_base_dir() -> str: elif current == 'Praxis_Bot' or current == 'Praxis': return check_dir(os.path.join(cwd, "commands")) else: - print("could not find working directory for Praxis_Bot/commands") + praxis_logger_obj.log("could not find working directory for Praxis_Bot/commands") raise Exception diff --git a/cooldowns.py b/cooldowns.py index 68b1431..b419809 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -7,6 +7,12 @@ from datetime import timedelta import time from time import sleep +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 Cooldown_Action: def __init__(self): self.tag:str = "" @@ -81,41 +87,41 @@ if __name__ == "__main__": cdName = "test" testCD.setupCooldown(cdName, 20, 2) - print("CD Test 0: ") + praxis_logger_obj.log("CD Test 0: ") for x in range(20): testCD.actionTrigger("cdName") sleep(0) - print(testCD.isCooldownActive("cdName")) - print("//Test Done//") + praxis_logger_obj.log(testCD.isCooldownActive("cdName")) + praxis_logger_obj.log("//Test Done//") sleep(2) - print("CD Test 1: ") + praxis_logger_obj.log("CD Test 1: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0) - print(testCD.isCooldownActive("test")) - print("//Test Done//") + praxis_logger_obj.log(testCD.isCooldownActive("test")) + praxis_logger_obj.log("//Test Done//") sleep(2) - print("CD Test 2: ") + praxis_logger_obj.log("CD Test 2: ") for x in range(10): testCD.actionTrigger(cdName) sleep(0) - print(testCD.isCooldownActive(cdName)) - print("//Test Done//") + praxis_logger_obj.log(testCD.isCooldownActive(cdName)) + praxis_logger_obj.log("//Test Done//") sleep(2) - print("CD Test 3: ") + praxis_logger_obj.log("CD Test 3: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0.05) - print(testCD.isCooldownActive(cdName)) - print("//Test Done//") + praxis_logger_obj.log(testCD.isCooldownActive(cdName)) + praxis_logger_obj.log("//Test Done//") sleep(2) - print("CD Test 4: ") + praxis_logger_obj.log("CD Test 4: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0.6) - print(testCD.isCooldownActive(cdName)) - print("//Test Done//") \ No newline at end of file + praxis_logger_obj.log(testCD.isCooldownActive(cdName)) + praxis_logger_obj.log("//Test Done//") \ No newline at end of file diff --git a/credentials.py b/credentials.py index 50cad94..6f0af71 100644 --- a/credentials.py +++ b/credentials.py @@ -1,7 +1,11 @@ import json -import os from enum import Enum +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 Credential(Enum): Twitch_Credential = 1 @@ -59,7 +63,7 @@ class Credentials_Module(): self.DB_Credentials_List: list = [] def load_credentials(self): - print("Loading credentials...") + praxis_logger_obj.log("Loading credentials...") fileList = self.list_credential_files() for file in fileList: if file.lower().find("twitch") != -1: @@ -111,33 +115,33 @@ class Credentials_Module(): return tobj def find_Credential(self, credentialType, searchParam: str): - print("Searching for credential named: " + searchParam) + praxis_logger_obj.log("Searching for credential named: " + searchParam) if credentialType.__name__ == Twitch_Credential.__name__: - print(".\{Twitch Credential Detected}") + praxis_logger_obj.log(".\{Twitch Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.Twitch_Credential) output = credential_search_function(self, searchParam) return output elif credentialType.__name__ == Discord_Credential.__name__: - print(".\{Discord Credential Detected}") + praxis_logger_obj.log(".\{Discord Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.Twitch_Credential) output = credential_search_function(self, searchParam) return output elif credentialType.__name__ == DB_Credential.__name__: - print(".\{DB Credential Detected}") + praxis_logger_obj.log(".\{DB Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.DB_Credential) output = credential_search_function(self, searchParam) return output else: - print(".\{Something else Detected}") + praxis_logger_obj.log(".\{Something else Detected}") return None def find_Twitch_Credential(self, searchParam: str): - print("Searching for Twitch Credential named: " + searchParam) + praxis_logger_obj.log("Searching for Twitch Credential named: " + searchParam) foundSomething = False tempCert: Twitch_Credential = None for cert in self.Twitch_Credentials_List: if cert.username == searchParam: - print("Twitch Credential Found: {" + cert.username + "}") + praxis_logger_obj.log("Twitch Credential Found: {" + cert.username + "}") tempCert = cert foundSomething = True if foundSomething: @@ -146,12 +150,12 @@ class Credentials_Module(): return None def find_Discord_Credential(self, searchParam: str): - print("Searching for Discord Credential named: " + searchParam) + praxis_logger_obj.log("Searching for Discord Credential named: " + searchParam) foundSomething = False tempCert: Discord_Credential = None for cert in self.Discord_Credentials_List: if cert.nickname == searchParam: - print("Discord Credential Found: {" + cert.nickname + "}") + praxis_logger_obj.log("Discord Credential Found: {" + cert.nickname + "}") tempCert = cert foundSomething = True if foundSomething: @@ -160,12 +164,12 @@ class Credentials_Module(): return None def find_DB_Credential(self, searchParam: str): - print("Searching for DB Credential named: " + searchParam) + praxis_logger_obj.log("Searching for DB Credential named: " + searchParam) foundSomething = False tempCert: DB_Credential = None for cert in self.DB_Credentials_List: if cert.nickname == searchParam: - print("DB Credential Found: {" + cert.nickname + "}") + praxis_logger_obj.log("DB Credential Found: {" + cert.nickname + "}") tempCert = cert foundSomething = True if foundSomething: diff --git a/db.py b/db.py index f649999..dcd8dcb 100644 --- a/db.py +++ b/db.py @@ -24,7 +24,7 @@ class db_module(): if createEngine: self.engine = create_engine(credential.engine_url) self.currentWorkingDB = credential.databaseName - print("SQL Engine Created") + praxis_logger_obj.log("SQL Engine Created") def create_table(self, tableName: str = ""): pass @@ -45,7 +45,7 @@ class db_module(): # temp = df.query(stmt) # result = temp.get("response") # -# # print(result) +# # praxis_logger_obj.log(result) # i = len(temp.index.values) # # if i == 1: diff --git a/help_module.py b/help_module.py index b67a4bf..12b0270 100644 --- a/help_module.py +++ b/help_module.py @@ -7,13 +7,19 @@ import commands.loader as command_loader import credentials +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 Help_Module(): def __init__(self): super().__init__() #self.dbCredential: credentials.DB_Credential def main(self): - print("[Help Module]> help test") + praxis_logger_obj.log("[Help Module]> help test") self.isCommandEnabled = True def help_command_response(self, command:AbstractCommand, responseType): diff --git a/lights_module.py b/lights_module.py index a3f0308..0dc07b9 100644 --- a/lights_module.py +++ b/lights_module.py @@ -8,13 +8,19 @@ import utilities_script as utilities import credentials import config +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 Lights_Module(): def __init__(self): super().__init__() self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - print("\nStarting up [Lights_Module]...") + praxis_logger_obj.log("\nStarting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -24,26 +30,26 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - #print("\n -Listing Lights...") + #praxis_logger_obj.log("\n -Listing Lights...") for l in light_list: pass - #print(l.name) - #print("\n -Counting Groups...") + #praxis_logger_obj.log(l.name) + #praxis_logger_obj.log("\n -Counting Groups...") for g in groups: - #print(g) + #praxis_logger_obj.log(g) groupCount = int(g) for gc in range(groupCount): try: - #print("group n:" + str(gc)) + #praxis_logger_obj.log("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - #print(group) + #praxis_logger_obj.log(group) group_list.append(group) - #print(" --done adding") + #praxis_logger_obj.log(" --done adding") except: pass - #print(" --adding failed") + #praxis_logger_obj.log(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -60,12 +66,12 @@ class Lights_Module(): #sleep(0.1) #for stuffz in self.bridge_.scenes: - #print(stuffz) + #praxis_logger_obj.log(stuffz) # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - print("-[Lights_Module] Setup Complete") + praxis_logger_obj.log("-[Lights_Module] Setup Complete") def setLight(): pass @@ -118,22 +124,22 @@ class Lights_Module(): def color_string_parser(self, message): maxDigits = config.colorParse_maxDigits - print("Searching for color...") + praxis_logger_obj.log("Searching for color...") xy_color = [0, 0] for text in message: - #print("testing word") + #praxis_logger_obj.log("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - print("-found: red") + praxis_logger_obj.log("-found: red") if "blue" in text.lower(): - print("-found: blue") + praxis_logger_obj.log("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - print("-found: green") + praxis_logger_obj.log("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - print("-found: yellow") + praxis_logger_obj.log("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -141,23 +147,23 @@ class Lights_Module(): if "cyan" in text.lower(): - print("-found: cyan") + praxis_logger_obj.log("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - print("-found: aquamarine") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -165,21 +171,21 @@ class Lights_Module(): if "magenta" in text.lower(): - print("-found: magenta") + praxis_logger_obj.log("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - print("-found: purple") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: violet") xy_color = self.rgb_to_xy( round(utilities.rescale_value(237,0,254),maxDigits), round(utilities.rescale_value(129,0,254),maxDigits), diff --git a/logsStandAlone_Command.log b/logsStandAlone_Command.log new file mode 100644 index 0000000..3ea97dd --- /dev/null +++ b/logsStandAlone_Command.log @@ -0,0 +1,16 @@ +INFO:root:Application running! +INFO:root:testLog +INFO:werkzeug: * Restarting with stat +INFO:root:Application running! +INFO:root:testLog +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 760-498-562 +INFO:werkzeug: * Running on http://0.0.0.0:6009/ (Press CTRL+C to quit) +INFO:root:Application running! +INFO:root:testLog +INFO:werkzeug: * Restarting with stat +INFO:root:Application running! +INFO:root:testLog +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 760-498-562 +INFO:werkzeug: * Running on http://0.0.0.0:6009/ (Press CTRL+C to quit) diff --git a/main.py b/main.py index f0bb16e..5cf07d1 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,12 @@ import credentials import threading +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__)) + testModule_: test_module.Test_Module userModule_: user_module.User_Module @@ -25,18 +31,18 @@ def main(inputArg): def test_module_init(dbCert, Empty): - print("-init [TEST Module]") + praxis_logger_obj.log("-init [TEST Module]") #testModule_.dbCredential = dbCert testModule_.main() def user_module_init(dbCert, Empty): - print("-init [USER Module]") + praxis_logger_obj.log("-init [USER Module]") userModule_.dbCredential = dbCert userModule_.main() def thread_main(): if utility.isRunningInDocker() == True: - print("<[DOCKER Detected]>") + praxis_logger_obj.log("<[DOCKER Detected]>") if not config.skip_splashScreen: utility.splashScreen() global credentials_manager @@ -66,11 +72,11 @@ def thread_main(): threads.append(thread_) thread_.start() - print("---Post Thread Creation Test---\n") + praxis_logger_obj.log("---Post Thread Creation Test---\n") for t in threads: t.join() - print("---Point of no return---") + praxis_logger_obj.log("---Point of no return---") if utility.isRunningInDocker() == False: input() diff --git a/praxis_logging.py b/praxis_logging.py new file mode 100644 index 0000000..f1bbad4 --- /dev/null +++ b/praxis_logging.py @@ -0,0 +1,13 @@ +import logging +import utilities_script + +class praxis_logger(): + def init(self, name): + super().__init__() + self.logName = "logs/" + name + ".log" + utilities_script.get_dir("logs") + logging.basicConfig(filename=self.logName, level=logging.DEBUG) + logging.info('Application running!') + + def log(self, msg): + logging.info(msg) diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index 2fa861a..5f7ec1f 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -4,6 +4,12 @@ from flask import request import channel_rewards.channelRewards_loader as rewards_loader from channel_rewards.channelRewards_base import AbstractChannelRewards +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 @@ -12,7 +18,7 @@ loadedRewards = {} def init(): # todo load entire reward library and cache it here - print("init stuff") + praxis_logger_obj.log("init stuff") loadedRewards[AbstractChannelRewards.ChannelRewardsType.channelPoints] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.channelPoints) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_bits] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_bits) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_subs] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_subs) @@ -22,12 +28,12 @@ def is_reward(reward_name, reward_type) -> bool: #global loadedRewards tempType = reward_type.replace('ChannelRewardsType.', '') realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] - #print(loadedRewards[realTempType]) + #praxis_logger_obj.log(loadedRewards[realTempType]) for reward in loadedRewards[realTempType]: - print("found: ", reward, "type: ", type(reward)) + praxis_logger_obj.log("found: ", reward, "type: ", type(reward)) if reward_name == reward: - print("Equal") + praxis_logger_obj.log("Equal") return True @@ -48,15 +54,15 @@ def handle_reward(source, username, reward_name, reward_type, rewardPrompt, user return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) except: return "None" - #print("Doing a reward") + #praxis_logger_obj.log("Doing a reward") @api.route('/api/v1/reward', methods=['GET']) def reward_check(): if 'reward_name' in request.args and 'reward_type' in request.args: - print("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) + praxis_logger_obj.log("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) if is_reward(request.args['reward_name'], request.args['reward_type']): - print("about to send") + praxis_logger_obj.log("about to send") return flask.make_response('', 200) else: return flask.make_response('', 404) diff --git a/standalone_command.py b/standalone_command.py index def50cb..bb40055 100644 --- a/standalone_command.py +++ b/standalone_command.py @@ -4,6 +4,12 @@ from flask import request import commands.loader as command_loader from commands.command_base import AbstractCommand +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 @@ -21,9 +27,9 @@ def load_commands(): def is_command(command: str) -> bool: - #print(command) + #praxis_logger_obj.log(command) for cmd in loadedCommands: - #print(cmd) + #praxis_logger_obj.log(cmd) if command == cmd: return True @@ -35,7 +41,7 @@ def is_command(command: str) -> bool: def handle_command(source, username, command, rest, bonusData): if command == "!echo": message = "Got payload [%s]" % rest - #print(message) + #praxis_logger_obj.log(message) return flask.make_response("{\"message\":\"%s\"}" % message, 200, {"Content-Type": "application/json"}) cmd:AbstractCommand = loadedCommands[command] @@ -43,7 +49,7 @@ def handle_command(source, username, command, rest, bonusData): cmd_response = cmd.do_command(source, username, command, rest, bonusData) return flask.make_response("{\"message\":\"%s\"}" % cmd_response, 200, {"Content-Type": "application/json"}) - #print("Doing a command") + #praxis_logger_obj.log("Doing a command") @api.route('/api/v1/command', methods=['GET']) diff --git a/standalone_discord_script.py b/standalone_discord_script.py index 9f9c59c..7ac4381 100644 --- a/standalone_discord_script.py +++ b/standalone_discord_script.py @@ -25,6 +25,12 @@ import discord.abc 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 Discord_Module(discord.Client): def __init__(self): super().__init__() @@ -44,17 +50,17 @@ class Discord_Module(discord.Client): await self.start(self.discordCredential.token) def main(self): - print("starting loop") + praxis_logger_obj.log("starting loop") self.loop.create_task(self.startup()) self.loop.run_forever() async def on_ready(self): - print('Logged on as', self.user) + praxis_logger_obj.log('Logged on as', self.user) async def on_message(self, message: discord.Message): - print("{" + message.guild.name + "}[ " + str(message.channel) + " ](" + message.author.display_name + ")> ") - #print(message.author.mention) - print(message.content) + praxis_logger_obj.log("{" + message.guild.name + "}[ " + str(message.channel) + " ](" + message.author.display_name + ")> ") + #praxis_logger_obj.log(message.author.mention) + praxis_logger_obj.log(message.content) if not await self.isSenderBot(message): # This will check for the praxis_bot-tts channel and will TTS stuff from there. @@ -82,7 +88,7 @@ class Discord_Module(discord.Client): if self.cooldownModule.isCooldownActive("discordRateLimit") == False: await self.exec_command(message, command, rest) except: - print("something went wrong with a command") + praxis_logger_obj.log("something went wrong with a command") async def is_command(self, word: str) -> bool: # todo need to url-escape word @@ -97,7 +103,7 @@ class Discord_Module(discord.Client): url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: - print("Got the following message: %s" % resp.text) + praxis_logger_obj.log("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: @@ -121,15 +127,15 @@ class Discord_Module(discord.Client): for bot in config.botList: if message.author.display_name.lower() == bot.lower(): isBot = True - print("<{ bot detected! }> ") + praxis_logger_obj.log("<{ bot detected! }> ") return isBot async def isChannel_inConfigList(self, selectedChannel, selectedList): - #print(channel) - #print(selectedList) + #praxis_logger_obj.log(channel) + #praxis_logger_obj.log(selectedList) is_Self = False for discordChannel in selectedList: - #print("isSelf: " + str(discordChannel) + " vs " + str(selectedChannel)) + #praxis_logger_obj.log("isSelf: " + str(discordChannel) + " vs " + str(selectedChannel)) if discordChannel == selectedChannel: is_Self = True diff --git a/standalone_lights.py b/standalone_lights.py index 2907fc8..38bbaf8 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -11,6 +11,12 @@ 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 @@ -22,7 +28,7 @@ class Lights_Module(): self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - print("\nStarting up [Lights_Module]...") + praxis_logger_obj.log("\nStarting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -32,26 +38,26 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - #print("\n -Listing Lights...") + #praxis_logger_obj.log("\n -Listing Lights...") for l in light_list: pass - #print(l.name) - #print("\n -Counting Groups...") + #praxis_logger_obj.log(l.name) + #praxis_logger_obj.log("\n -Counting Groups...") for g in groups: - #print(g) + #praxis_logger_obj.log(g) groupCount = int(g) for gc in range(groupCount): try: - #print("group n:" + str(gc)) + #praxis_logger_obj.log("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - #print(group) + #praxis_logger_obj.log(group) group_list.append(group) - #print(" --done adding") + #praxis_logger_obj.log(" --done adding") except: pass - #print(" --adding failed") + #praxis_logger_obj.log(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -68,13 +74,13 @@ class Lights_Module(): #sleep(0.1) #for stuffz in self.bridge_.scenes: - #print(stuffz) + #praxis_logger_obj.log(stuffz) # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - self.bridge_.run_scene("Downstairs", "Stream") - print("-[Lights_Module] Setup Complete") + #self.bridge_.run_scene("Downstairs", "Stream") + praxis_logger_obj.log("-[Lights_Module] Setup Complete") def setLight(): pass @@ -132,22 +138,22 @@ class Lights_Module(): def color_string_parser(self, message): maxDigits = config.colorParse_maxDigits - print("Searching for color...") + praxis_logger_obj.log("Searching for color...") xy_color = [0, 0] for text in message: - #print("testing word") + #praxis_logger_obj.log("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - print("-found: red") + praxis_logger_obj.log("-found: red") if "blue" in text.lower(): - print("-found: blue") + praxis_logger_obj.log("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - print("-found: green") + praxis_logger_obj.log("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - print("-found: yellow") + praxis_logger_obj.log("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -155,23 +161,23 @@ class Lights_Module(): if "cyan" in text.lower(): - print("-found: cyan") + praxis_logger_obj.log("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - print("-found: aquamarine") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -179,21 +185,21 @@ class Lights_Module(): if "magenta" in text.lower(): - print("-found: magenta") + praxis_logger_obj.log("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - print("-found: purple") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: violet") xy_color = self.rgb_to_xy( round(utilities.rescale_value(237,0,254),maxDigits), round(utilities.rescale_value(129,0,254),maxDigits), @@ -208,8 +214,8 @@ def init(): RGB_Lights.main() def do_lights_command(user="", lightGroup="all", command = "", rest = ""): - returnString = "None" - print("about to do something ......") + returnString = "" + praxis_logger_obj.log("about to do something ......") #bot.return_message("\nRGB Command Detected!") if rest is not "": @@ -221,12 +227,12 @@ def do_lights_command(user="", lightGroup="all", command = "", rest = ""): tempParsedMessage = tempFix.split(" ") sceneCommand = False if (len(tempParsedMessage)) > 2: - print("RGB Command!") + praxis_logger_obj.log("RGB Command!") rgb_r = float(tempParsedMessage[1]) rgb_g = float(tempParsedMessage[2]) rgb_b = float(tempParsedMessage[3]) xy_result = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) - print("got XY") + praxis_logger_obj.log("got XY") RGB_Lights.bridge_.set_group(16, "xy", xy_result) #bot.return_message("sent color to [Lights_Module]") else: @@ -259,11 +265,12 @@ def do_lights_command(user="", lightGroup="all", command = "", rest = ""): #bot.return_message("sent color to [Lights_Module]") if sceneCommand == True: - print("Scene Command!") + praxis_logger_obj.log("Scene Command!") - returnString = user + " changed the light's color!" + returnString = user + " changed the lights color!" + praxis_logger_obj.log(returnString) - return returnString + return flask.make_response("{\"message\":\"%s\"}" % returnString, 200, {"Content-Type": "application/json"}) @@ -278,7 +285,7 @@ def exec_lights(): if 'command' not in request.args: return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) - print("about to do something ......") + praxis_logger_obj.log("about to do something ......") RGB_Lights.main() return do_lights_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index aec0c4c..378b6c6 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__() @@ -42,14 +48,14 @@ class Twitch_Pubsub(): def get_tokens(self): self.twitch.authenticate_app(self.target_scope) for scope_ in self.target_scope: - print(scope_) + praxis_logger_obj.log(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() - if token is not None: print("found token") - if refresh_token is not None: print("found refresh_token") - print(token) - print(refresh_token) + if token is not None: praxis_logger_obj.log("found token") + if refresh_token is not None: praxis_logger_obj.log("found refresh_token") + praxis_logger_obj.log(token) + praxis_logger_obj.log(refresh_token) self.twitch.set_user_authentication(token, self.target_scope, refresh_token) @@ -57,12 +63,12 @@ class Twitch_Pubsub(): self.pubsub = PubSub(self.twitch) #self.pubsub.ping_frequency = 30 self.pubsub.start() - print("started") + praxis_logger_obj.log("started") def next(self): user_id = self.twitch.get_users(logins=[config.autoJoin_TwitchChannel])['data'][0]['id'] - if user_id is not None: print("found user_id") - print(user_id) + if user_id is not None: praxis_logger_obj.log("found user_id") + praxis_logger_obj.log(user_id) self.uuid_1 = self.pubsub.listen_whispers(user_id, self.callback_whisper) self.uuid_2 = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints) #input('press ENTER to close...') @@ -73,22 +79,22 @@ class Twitch_Pubsub(): self.pubsub.stop() def callback_whisper(self, uuid: UUID, data: dict) -> None: - print('got callback for UUID ' + str(uuid)) + praxis_logger_obj.log('got callback for UUID ' + str(uuid)) pprint(data) def callback_channelPoints(self, uuid: UUID, data: dict) -> None: - print("Channel Point Redemption") - print('got callback for UUID ' + str(uuid)) + praxis_logger_obj.log("Channel Point Redemption") + praxis_logger_obj.log('got callback for UUID ' + str(uuid)) pprint(data) - #print("attempting to get data: ") - #print(data['data']['redemption']['user']['display_name']) - #print(data['data']['redemption']['reward']['title']) - #print(data['data']['redemption']['reward']['prompt']) + #praxis_logger_obj.log("attempting to get data: ") + #praxis_logger_obj.log(data['data']['redemption']['user']['display_name']) + #praxis_logger_obj.log(data['data']['redemption']['reward']['title']) + #praxis_logger_obj.log(data['data']['redemption']['reward']['prompt']) try: userinput = data['data']['redemption']['user_input'] except: userinput = "" - #print(userinput) + #praxis_logger_obj.log(userinput) self.callback_EXEC( data['data']['redemption']['user']['display_name'], data['data']['redemption']['reward']['title'], @@ -98,29 +104,29 @@ class Twitch_Pubsub(): data) def callback_bits(self, uuid: UUID, data: dict) -> None: - print("Bits Redemption") - print('got callback for UUID ' + str(uuid)) + praxis_logger_obj.log("Bits Redemption") + praxis_logger_obj.log('got callback for UUID ' + str(uuid)) pprint(data) def callback_subs(self, uuid: UUID, data: dict) -> None: - print("Subs Redemption") - print('got callback for UUID ' + str(uuid)) + praxis_logger_obj.log("Subs Redemption") + praxis_logger_obj.log('got callback for UUID ' + str(uuid)) pprint(data) def callback_EXEC(self, sender, rewardName:str, rewardType, rewardPrompt, userInput, raw_data): try: is_actionable = self.is_reward(rewardName, rewardType) if is_actionable: - print("Trying to do the thing") + praxis_logger_obj.log("Trying to do the thing") if self.cooldownModule.isCooldownActive("twitchChat") == False: self.exec_reward(sender, rewardName, rewardType, rewardPrompt, userInput, raw_data) except: - print("something went wrong with a reward") + praxis_logger_obj.log("something went wrong with a reward") def is_reward(self, rewardName, rewardType): # todo need to url-escape word clean_param = urlencode({'reward_name': rewardName, 'reward_type':rewardType}) - print(rewardName, rewardType) + praxis_logger_obj.log(rewardName, rewardType) #standalone_channelrewards url = "http://standalone_channelrewards:6969/api/v1/reward?%s" % clean_param resp = requests.get(url) @@ -140,7 +146,7 @@ class Twitch_Pubsub(): url = "http://standalone_channelrewards:6969/api/v1/exec_reward?%s" % params resp = requests.get(url) if resp.status_code == 200: - print("Got the following message: %s" % resp.text) + praxis_logger_obj.log("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: diff --git a/standalone_twitch_script.py b/standalone_twitch_script.py index bb0f82d..5313ac9 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__() @@ -33,7 +39,7 @@ class Twitch_Module(): def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str): channel_name = "#" + channel_name - print("Connecting to Channel: " + channel_name + "...") + praxis_logger_obj.log("Connecting to Channel: " + channel_name + "...") if credential is None: credential = self.twitchCredential @@ -47,23 +53,23 @@ class Twitch_Module(): ) self.chat.subscribe(self.twitch_chat) - print("Connected to Channel: ", channel_name) + praxis_logger_obj.log("Connected to Channel: ", channel_name) def leave_channel(self): - print("Leaving Channel", self.chat.channel) + praxis_logger_obj.log("Leaving Channel", self.chat.channel) self.chat.irc.leave_channel(self.chat.channel) self.chat.irc.socket.close() def send_message(self, message): isBlocked = self.isChannel_inConfigList(self.chat.channel, config.block_TwitchChannelsMessaging) - # print("isBlocked: " + str(isBlocked) + " for: " + self.chat.channel) + # praxis_logger_obj.log("isBlocked: " + str(isBlocked) + " for: " + self.chat.channel) #if self. if utility.contains_slur(message): isBlocked = True if self.cooldownModule.isCooldownActive( "twitchChat") == False and not isBlocked and not config.blockAll_TwitchChatChannelsMessaging: self.chat.send(message) - # print("Sent ChatMSG") + # praxis_logger_obj.log("Sent ChatMSG") self.cooldownModule.actionTrigger("twitchChat") def is_command(self, word: str) -> bool: @@ -79,7 +85,7 @@ class Twitch_Module(): url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: - print("Got the following message: %s" % resp.text) + praxis_logger_obj.log("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: @@ -93,7 +99,7 @@ class Twitch_Module(): # This reacts to messages def twitch_chat(self, message: twitch.chat.Message) -> None: - print("[#" + message.channel + "](" + message.sender + ")> " + message.text) + praxis_logger_obj.log("[#" + message.channel + "](" + message.sender + ")> " + message.text) command, rest = utility.parse_line(message.text) try: @@ -102,19 +108,19 @@ class Twitch_Module(): if self.cooldownModule.isCooldownActive("twitchChat") == False: self.exec_command(message ,command, rest) except: - print("something went wrong with a command") + praxis_logger_obj.log("something went wrong with a command") def isChannel_inConfigList(self, selectedChannel, selectedList): - # print(channel) - # print(selectedList) + # praxis_logger_obj.log(channel) + # praxis_logger_obj.log(selectedList) is_Self = False for twitchChannel in selectedList: if twitchChannel == selectedChannel: is_Self = True # if is_Self: - # print("Is Self") + # praxis_logger_obj.log("Is Self") # if not is_Self: - # print("Is Not Self") + # praxis_logger_obj.log("Is Not Self") return is_Self diff --git a/standalone_webSource.py b/standalone_webSource.py index 54a7dce..b8509c2 100644 --- a/standalone_webSource.py +++ b/standalone_webSource.py @@ -20,6 +20,12 @@ import utilities_script as utility import chyron_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 webSource_Module(): webSources:Flask = Flask('webSources') @@ -28,7 +34,7 @@ class webSource_Module(): self.dbCredential: credentials.DB_Credential def main(self, port_=5000): - print("starting up on port: ", port_) + praxis_logger_obj.log("starting up on port: ", port_) self.webSources.run(host="0.0.0.0", port= port_) @webSources.route('/') @@ -42,7 +48,7 @@ class webSource_Module(): @webSources.route('/temptext//') def textSource_tempText(filename): - print("trying file: ", filename) + praxis_logger_obj.log("trying file: ", filename) tempModule = tempText_Module.tempText_Module() return tempModule.getTempTextFile(filename) diff --git a/tempText_Module.py b/tempText_Module.py index 158e912..749dada 100644 --- a/tempText_Module.py +++ b/tempText_Module.py @@ -1,6 +1,11 @@ import config import utilities_script as utilities + 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 tempText_Module(): def __init__(self): @@ -57,7 +62,7 @@ class tempText_Module(): file = open(real_file_path, "rb") text = file.read() - #print(text) + #praxis_logger_obj.log(text) file.close return text @@ -74,7 +79,7 @@ class tempTextItem(): self.itemComputedString = "" def setupItem(self, name, title, content): - print("\nSetting up tempTextItem {", name,"}[", title, content, "]") + praxis_logger_obj.log("\nSetting up tempTextItem {", name,"}[", title, content, "]") self.itemName = name self.itemTitle = title self.itemContent = content diff --git a/test_module.py b/test_module.py index 9594d9b..76d77cf 100644 --- a/test_module.py +++ b/test_module.py @@ -3,13 +3,19 @@ import db import credentials +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 Test_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential def main(self): - print("[TEST Module]> test") + praxis_logger_obj.log("[TEST Module]> test") if __name__ == "__main__": diff --git a/tts.py b/tts.py index 6e026aa..0b133d6 100644 --- a/tts.py +++ b/tts.py @@ -1,6 +1,11 @@ import datetime import hashlib + 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__)) import requests from gtts import gTTS @@ -14,9 +19,9 @@ streamLabsUrl = "https://streamlabs.com/polly/speak" def tts(inputText: str, *args): outpath = create_speech_file(inputText) if utility.isRunningInDocker() == True: - print("Docker Detected, skipping playsound()") + praxis_logger_obj.log("Docker Detected, skipping playsound()") else: - print("Playing Sound...") + praxis_logger_obj.log("Playing Sound...") playsound(outpath) @@ -108,6 +113,6 @@ def get_tts_dir(): if __name__ == "__main__": - print("Enter Text: ") + praxis_logger_obj.log("Enter Text: ") textInput = str(input()) tts(textInput) diff --git a/twitch_generate_credentials.py b/twitch_generate_credentials.py index cfabaee..db97d80 100644 --- a/twitch_generate_credentials.py +++ b/twitch_generate_credentials.py @@ -10,6 +10,12 @@ from twitchAPI.oauth import UserAuthenticator from pprint import pprint from uuid import UUID +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_Credential_Maker(): def __init__(self): @@ -21,15 +27,15 @@ class Twitch_Credential_Maker(): def get_tokens(self): self.twitch.authenticate_app(self.target_scope) for scope_ in self.target_scope: - print(scope_) + praxis_logger_obj.log(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() - if token is not None: print("found token") - if refresh_token is not None: print("found refresh_token\n") - print("token: ", token) - print("refresh_token: ", refresh_token) - print("") + if token is not None: praxis_logger_obj.log("found token") + if refresh_token is not None: praxis_logger_obj.log("found refresh_token\n") + praxis_logger_obj.log("token: ", token) + praxis_logger_obj.log("refresh_token: ", refresh_token) + praxis_logger_obj.log("") return token, refresh_token @@ -45,5 +51,5 @@ if __name__ == "__main__": #pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) testModule.get_tokens() - print("Ready to close") + praxis_logger_obj.log("Ready to close") input() \ No newline at end of file diff --git a/user_module.py b/user_module.py index 023c042..bafd884 100644 --- a/user_module.py +++ b/user_module.py @@ -13,6 +13,12 @@ from cooldowns import Cooldown_Module 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 User_Module(): def __init__(self): super().__init__() @@ -27,10 +33,10 @@ class User_Module(): def main(self): time.sleep(.01) - print("\nWaiting on User input...\n\n") + praxis_logger_obj.log("\nWaiting on User input...\n\n") if utility.isRunningInDocker() == True: self.inputLoop = False - print("\nNo User's Input Allowed") + praxis_logger_obj.log("\nNo User's Input Allowed") while self.inputLoop: keyboardInput = input() @@ -77,7 +83,7 @@ class User_Module(): command.do_command(self, message) except Exception as e: # Undo the following for debug stuff - #print(e) + #praxis_logger_obj.log(e) pass # we don't care def eval_commands_SpecialActionCheck(self): @@ -88,7 +94,7 @@ class User_Module(): pass def return_message(self, returnedMessage): - print(returnedMessage) + praxis_logger_obj.log(returnedMessage) def tts(self, message): tts.tts(message) diff --git a/utilities_script.py b/utilities_script.py index 4cfb4d0..61e7911 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -1,5 +1,4 @@ from asyncio.tasks import sleep -import os import sys import re import psutil @@ -9,6 +8,12 @@ import time import config as config import art +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__)) + clearScreen = lambda: os.system('cls' if os.name == 'nt' else 'clear') urlMatcher = re.compile("(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))") @@ -22,7 +27,7 @@ def get_args(text: str) -> list: def does_contain_OnlyNumbers(text): isJustNumbers = False - print("checking numbers") + praxis_logger_obj.log("checking numbers") try: for x in range(10): if str(x) in str(text): @@ -35,9 +40,9 @@ def does_contain_OnlyNumbers(text): return isJustNumbers def rescale_value(value, min, max): - #print("trying Rescale") + #praxis_logger_obj.log("trying Rescale") returnValue = (value - min) / (max - min) - #print("got ", returnValue) + #praxis_logger_obj.log("got ", returnValue) return returnValue def get_dir(selected_dir): @@ -62,7 +67,7 @@ def contains_slur(input: str): break if containsSlur: - print("<{ slur detected! }> ") + praxis_logger_obj.log("<{ slur detected! }> ") return containsSlur def parse_line(message: str): @@ -131,9 +136,9 @@ def splashScreen(): art.tprint("----------",font="slant") art.tprint("Praxis Bot",font="graffiti") art.tprint("----------",font="slant") - print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") - print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) - print("\n\n\n") + praxis_logger_obj.log("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") + praxis_logger_obj.log("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) + praxis_logger_obj.log("\n\n\n") if not config.skip_splashScreenSleep: time.sleep(3) -- 2.45.2 From 0d6e26a2a52b35fe0f5f64785afd33d89859e6f3 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 18:55:23 -0400 Subject: [PATCH 05/14] Revert "logging" This reverts commit b106eaa9dd3d40bf1b60b2d42f5967ac2259ba16. --- Command_Management_Module.py | 16 ++-- channel_rewards/channelRewards_loader.py | 16 ++-- .../implemented/ChannelReward_Hydration.py | 4 +- chyron_module.py | 10 +-- commands/implemented/Command_lights_v2.py | 74 +++++++++++++------ commands/implemented/Command_roll_v2.py | 4 +- commands/implemented/Command_test_v2.py | 2 +- commands/loader.py | 16 ++-- cooldowns.py | 36 ++++----- credentials.py | 30 ++++---- db.py | 4 +- help_module.py | 8 +- lights_module.py | 54 ++++++-------- logsStandAlone_Command.log | 16 ---- main.py | 16 ++-- praxis_logging.py | 13 ---- standalone_channelrewards.py | 20 ++--- standalone_command.py | 14 +--- standalone_discord_script.py | 28 +++---- standalone_lights.py | 73 +++++++++--------- standalone_twitch_pubsub.py | 54 ++++++-------- standalone_twitch_script.py | 30 +++----- standalone_webSource.py | 10 +-- tempText_Module.py | 9 +-- test_module.py | 8 +- tts.py | 11 +-- twitch_generate_credentials.py | 20 ++--- user_module.py | 14 +--- utilities_script.py | 21 ++---- 29 files changed, 254 insertions(+), 377 deletions(-) delete mode 100644 logsStandAlone_Command.log delete mode 100644 praxis_logging.py diff --git a/Command_Management_Module.py b/Command_Management_Module.py index 1902e65..f8df757 100644 --- a/Command_Management_Module.py +++ b/Command_Management_Module.py @@ -9,31 +9,25 @@ from commands.command_base import AbstractCommand import credentials -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 Command_Management_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential def main_test(self): - praxis_logger_obj.log("[TEST Module]> test") + print("[TEST Module]> test") tempModule = user_module.User_Module() #tempModule.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis) - praxis_logger_obj.log(self.getCommandsList(tempModule.commands)) + print(self.getCommandsList(tempModule.commands)) def getCommandsList(self, targetModuleCommands): - praxis_logger_obj.log(type(targetModuleCommands)) + print(type(targetModuleCommands)) commandsList = "\n" for cmd in targetModuleCommands: targetCommand = targetModuleCommands[cmd] - praxis_logger_obj.log(targetCommand.command) - praxis_logger_obj.log(targetCommand.isCommandEnabled) + print(targetCommand.command) + print(targetCommand.isCommandEnabled) return commandsList diff --git a/channel_rewards/channelRewards_loader.py b/channel_rewards/channelRewards_loader.py index fd80bb4..8a2db6e 100644 --- a/channel_rewards/channelRewards_loader.py +++ b/channel_rewards/channelRewards_loader.py @@ -1,13 +1,7 @@ import importlib import importlib.util import inspect - 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__)) - import sys from typing import Dict @@ -16,7 +10,7 @@ from channel_rewards.channelRewards_base import AbstractChannelRewards #New def load_rewards(channelRewardsType: AbstractChannelRewards.ChannelRewardsType) -> Dict[str, AbstractChannelRewards]: - praxis_logger_obj.log(" -Loading ", channelRewardsType ," ChannelRewards...\n") + print(" -Loading ", channelRewardsType ," ChannelRewards...\n") ChannelRewards = compile_and_load(channelRewardsType) return ChannelRewards @@ -32,10 +26,10 @@ def compile_and_load_file(path: str, channelRewardsType: AbstractChannelRewards. if inspect.isclass(obj) and name.startswith("ChannelReward"): ChannelReward_inst = obj() if channelRewardsType == ChannelReward_inst.get_ChannelRewardType(): - praxis_logger_obj.log(" ---Successfully loaded %s: %s" % (channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) + print(" ---Successfully loaded %s: %s" % (channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) return ChannelReward_inst.get_ChannelRewardName(), ChannelReward_inst elif channelRewardsType != ChannelReward_inst.get_ChannelRewardType(): - praxis_logger_obj.log(" -%s ChannelRewardsType did not match: %s for: %s" % (ChannelReward_inst.get_ChannelRewardType(), channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) + print(" -%s ChannelRewardsType did not match: %s for: %s" % (ChannelReward_inst.get_ChannelRewardType(), channelRewardsType, ChannelReward_inst.get_ChannelRewardName())) return "", None @@ -46,7 +40,7 @@ def compile_and_load(ChannelRewardType: AbstractChannelRewards.ChannelRewardsTyp for dirName, subdirList, fileList in os.walk(implementations): for file in fileList: name = os.path.join(dirName, file) - praxis_logger_obj.log("compiling: %s" % name) + print("compiling: %s" % name) name, reward = compile_and_load_file(name, ChannelRewardType) if reward is not None and reward.ChannelRewardType is ChannelRewardType: dic[name] = reward @@ -62,7 +56,7 @@ def get_base_dir() -> str: elif current == 'Praxis_Bot' or current == 'Praxis': return check_dir(os.path.join(cwd, "channel_rewards")) else: - praxis_logger_obj.log("could not find working directory for Praxis_Bot/channel_rewards") + print("could not find working directory for Praxis_Bot/channel_rewards") raise Exception diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index 4ca908d..cb16a2c 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -18,6 +18,8 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): self.isChannelRewardEnabled = True def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None): + + #print("sending:",user, 16, "!lights hydration") self.dothething(user, 16, "!lights hydration", "") return None @@ -28,7 +30,7 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: - praxis_logger_obj.log("Got the following message: %s" % resp.text) + print("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: diff --git a/chyron_module.py b/chyron_module.py index 44df435..1eed58a 100644 --- a/chyron_module.py +++ b/chyron_module.py @@ -1,10 +1,6 @@ import config import utilities_script as utilities 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 Chyron_Module(): def __init__(self): @@ -81,7 +77,7 @@ class Chyron_Module(): file = open(real_file_path, "rb") text = file.read() - #praxis_logger_obj.log(text) + #print(text) file.close return text @@ -98,7 +94,7 @@ class ChyronItem(): self.itemComputedString = "" def setupItem(self, name, title, content): - praxis_logger_obj.log("\nSetting up Item {", name,"}[", title, content, "]") + print("\nSetting up Item {", name,"}[", title, content, "]") self.itemName = name self.itemTitle = title self.itemContent = content @@ -118,6 +114,6 @@ if __name__ == "__main__": testModule.chyron_stringUpdater() test = testModule.chyron_computedString + "<<<|" - praxis_logger_obj.log(test) + print(test) testModule.updateChyronFile() \ No newline at end of file diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py index ed99c3d..ccde22b 100644 --- a/commands/implemented/Command_lights_v2.py +++ b/commands/implemented/Command_lights_v2.py @@ -1,10 +1,9 @@ from abc import ABCMeta +import lights_module from commands.command_base import AbstractCommand -from json import loads -from urllib.parse import urlencode -import requests +import utilities_script as utility class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): """ @@ -19,27 +18,58 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): self.isCommandEnabled = True def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): - returnString = self.dothething(user, 16, command, rest) - praxis_logger_obj.log(returnString) + returnString = "" - return None + tempBool = True + if tempBool == True: + LightModule = lights_module.Lights_Module() + LightModule.main() + #bot.return_message("\nRGB Command Detected!") + tempFix = command + " " + rest - 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: - praxis_logger_obj.log("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 + 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!" + + return returnString def get_help(self): return self.help \ No newline at end of file diff --git a/commands/implemented/Command_roll_v2.py b/commands/implemented/Command_roll_v2.py index 7da6f48..a174567 100644 --- a/commands/implemented/Command_roll_v2.py +++ b/commands/implemented/Command_roll_v2.py @@ -47,7 +47,7 @@ class Command_roll_v2(AbstractCommand, metaclass=ABCMeta): loopBool = False if roll_type == 1: - praxis_logger_obj.log("-rolling...") + print("-rolling...") # If roll is in xdx+x format if loopBool == True: rolls: list = [] @@ -78,7 +78,7 @@ class Command_roll_v2(AbstractCommand, metaclass=ABCMeta): if roll_type == 2: - praxis_logger_obj.log("-fate Rolling....") + print("-fate Rolling....") # !roll 4df # If roll is in xdx+x format if loopBool == True: diff --git a/commands/implemented/Command_test_v2.py b/commands/implemented/Command_test_v2.py index 512a265..18995d3 100644 --- a/commands/implemented/Command_test_v2.py +++ b/commands/implemented/Command_test_v2.py @@ -18,7 +18,7 @@ class Command_test_v2(AbstractCommand, metaclass=ABCMeta): def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): returnString = user + " sent: [ " + command + " ] with: " + rest - #praxis_logger_obj.log(returnString) + #print(returnString) return returnString def get_help(self): diff --git a/commands/loader.py b/commands/loader.py index 5d4d215..a92b544 100644 --- a/commands/loader.py +++ b/commands/loader.py @@ -1,13 +1,7 @@ import importlib import importlib.util import inspect - 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__)) - import sys from typing import Dict @@ -16,7 +10,7 @@ from commands.command_base import AbstractCommand #New def load_commands(commandType: AbstractCommand.CommandType) -> Dict[str, AbstractCommand]: - praxis_logger_obj.log(" -Loading ", commandType ," Commands...\n") + print(" -Loading ", commandType ," Commands...\n") commands = compile_and_load(commandType) return commands @@ -32,10 +26,10 @@ def compile_and_load_file(path: str, commandType: AbstractCommand.CommandType): if inspect.isclass(obj) and name.startswith("Command"): command_inst = obj() if commandType == command_inst.get_commandType(): - praxis_logger_obj.log(" ---Successfully loaded %s: %s" % (commandType, command_inst.get_command())) + print(" ---Successfully loaded %s: %s" % (commandType, command_inst.get_command())) return command_inst.get_command(), command_inst elif commandType != command_inst.get_commandType(): - praxis_logger_obj.log(" -%s CommandType did not match: %s for: %s" % (command_inst.get_commandType(), commandType, command_inst.get_command())) + print(" -%s CommandType did not match: %s for: %s" % (command_inst.get_commandType(), commandType, command_inst.get_command())) return "", None @@ -46,7 +40,7 @@ def compile_and_load(commandType: AbstractCommand.CommandType) -> Dict[str, Abst for dirName, subdirList, fileList in os.walk(implementations): for file in fileList: name = os.path.join(dirName, file) - praxis_logger_obj.log("compiling: %s" % name) + print("compiling: %s" % name) name, command = compile_and_load_file(name, commandType) if command is not None and command.command_type is commandType: dic[name] = command @@ -62,7 +56,7 @@ def get_base_dir() -> str: elif current == 'Praxis_Bot' or current == 'Praxis': return check_dir(os.path.join(cwd, "commands")) else: - praxis_logger_obj.log("could not find working directory for Praxis_Bot/commands") + print("could not find working directory for Praxis_Bot/commands") raise Exception diff --git a/cooldowns.py b/cooldowns.py index b419809..68b1431 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -7,12 +7,6 @@ from datetime import timedelta import time from time import sleep -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 Cooldown_Action: def __init__(self): self.tag:str = "" @@ -87,41 +81,41 @@ if __name__ == "__main__": cdName = "test" testCD.setupCooldown(cdName, 20, 2) - praxis_logger_obj.log("CD Test 0: ") + print("CD Test 0: ") for x in range(20): testCD.actionTrigger("cdName") sleep(0) - praxis_logger_obj.log(testCD.isCooldownActive("cdName")) - praxis_logger_obj.log("//Test Done//") + print(testCD.isCooldownActive("cdName")) + print("//Test Done//") sleep(2) - praxis_logger_obj.log("CD Test 1: ") + print("CD Test 1: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0) - praxis_logger_obj.log(testCD.isCooldownActive("test")) - praxis_logger_obj.log("//Test Done//") + print(testCD.isCooldownActive("test")) + print("//Test Done//") sleep(2) - praxis_logger_obj.log("CD Test 2: ") + print("CD Test 2: ") for x in range(10): testCD.actionTrigger(cdName) sleep(0) - praxis_logger_obj.log(testCD.isCooldownActive(cdName)) - praxis_logger_obj.log("//Test Done//") + print(testCD.isCooldownActive(cdName)) + print("//Test Done//") sleep(2) - praxis_logger_obj.log("CD Test 3: ") + print("CD Test 3: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0.05) - praxis_logger_obj.log(testCD.isCooldownActive(cdName)) - praxis_logger_obj.log("//Test Done//") + print(testCD.isCooldownActive(cdName)) + print("//Test Done//") sleep(2) - praxis_logger_obj.log("CD Test 4: ") + print("CD Test 4: ") for x in range(20): testCD.actionTrigger(cdName) sleep(0.6) - praxis_logger_obj.log(testCD.isCooldownActive(cdName)) - praxis_logger_obj.log("//Test Done//") \ No newline at end of file + print(testCD.isCooldownActive(cdName)) + print("//Test Done//") \ No newline at end of file diff --git a/credentials.py b/credentials.py index 6f0af71..50cad94 100644 --- a/credentials.py +++ b/credentials.py @@ -1,11 +1,7 @@ import json +import os from enum import Enum -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 Credential(Enum): Twitch_Credential = 1 @@ -63,7 +59,7 @@ class Credentials_Module(): self.DB_Credentials_List: list = [] def load_credentials(self): - praxis_logger_obj.log("Loading credentials...") + print("Loading credentials...") fileList = self.list_credential_files() for file in fileList: if file.lower().find("twitch") != -1: @@ -115,33 +111,33 @@ class Credentials_Module(): return tobj def find_Credential(self, credentialType, searchParam: str): - praxis_logger_obj.log("Searching for credential named: " + searchParam) + print("Searching for credential named: " + searchParam) if credentialType.__name__ == Twitch_Credential.__name__: - praxis_logger_obj.log(".\{Twitch Credential Detected}") + print(".\{Twitch Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.Twitch_Credential) output = credential_search_function(self, searchParam) return output elif credentialType.__name__ == Discord_Credential.__name__: - praxis_logger_obj.log(".\{Discord Credential Detected}") + print(".\{Discord Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.Twitch_Credential) output = credential_search_function(self, searchParam) return output elif credentialType.__name__ == DB_Credential.__name__: - praxis_logger_obj.log(".\{DB Credential Detected}") + print(".\{DB Credential Detected}") credential_search_function = self.credentialSearchFunctions.get(Credential.DB_Credential) output = credential_search_function(self, searchParam) return output else: - praxis_logger_obj.log(".\{Something else Detected}") + print(".\{Something else Detected}") return None def find_Twitch_Credential(self, searchParam: str): - praxis_logger_obj.log("Searching for Twitch Credential named: " + searchParam) + print("Searching for Twitch Credential named: " + searchParam) foundSomething = False tempCert: Twitch_Credential = None for cert in self.Twitch_Credentials_List: if cert.username == searchParam: - praxis_logger_obj.log("Twitch Credential Found: {" + cert.username + "}") + print("Twitch Credential Found: {" + cert.username + "}") tempCert = cert foundSomething = True if foundSomething: @@ -150,12 +146,12 @@ class Credentials_Module(): return None def find_Discord_Credential(self, searchParam: str): - praxis_logger_obj.log("Searching for Discord Credential named: " + searchParam) + print("Searching for Discord Credential named: " + searchParam) foundSomething = False tempCert: Discord_Credential = None for cert in self.Discord_Credentials_List: if cert.nickname == searchParam: - praxis_logger_obj.log("Discord Credential Found: {" + cert.nickname + "}") + print("Discord Credential Found: {" + cert.nickname + "}") tempCert = cert foundSomething = True if foundSomething: @@ -164,12 +160,12 @@ class Credentials_Module(): return None def find_DB_Credential(self, searchParam: str): - praxis_logger_obj.log("Searching for DB Credential named: " + searchParam) + print("Searching for DB Credential named: " + searchParam) foundSomething = False tempCert: DB_Credential = None for cert in self.DB_Credentials_List: if cert.nickname == searchParam: - praxis_logger_obj.log("DB Credential Found: {" + cert.nickname + "}") + print("DB Credential Found: {" + cert.nickname + "}") tempCert = cert foundSomething = True if foundSomething: diff --git a/db.py b/db.py index dcd8dcb..f649999 100644 --- a/db.py +++ b/db.py @@ -24,7 +24,7 @@ class db_module(): if createEngine: self.engine = create_engine(credential.engine_url) self.currentWorkingDB = credential.databaseName - praxis_logger_obj.log("SQL Engine Created") + print("SQL Engine Created") def create_table(self, tableName: str = ""): pass @@ -45,7 +45,7 @@ class db_module(): # temp = df.query(stmt) # result = temp.get("response") # -# # praxis_logger_obj.log(result) +# # print(result) # i = len(temp.index.values) # # if i == 1: diff --git a/help_module.py b/help_module.py index 12b0270..b67a4bf 100644 --- a/help_module.py +++ b/help_module.py @@ -7,19 +7,13 @@ import commands.loader as command_loader import credentials -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 Help_Module(): def __init__(self): super().__init__() #self.dbCredential: credentials.DB_Credential def main(self): - praxis_logger_obj.log("[Help Module]> help test") + print("[Help Module]> help test") self.isCommandEnabled = True def help_command_response(self, command:AbstractCommand, responseType): diff --git a/lights_module.py b/lights_module.py index 0dc07b9..a3f0308 100644 --- a/lights_module.py +++ b/lights_module.py @@ -8,19 +8,13 @@ import utilities_script as utilities import credentials import config -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 Lights_Module(): def __init__(self): super().__init__() self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - praxis_logger_obj.log("\nStarting up [Lights_Module]...") + print("\nStarting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -30,26 +24,26 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - #praxis_logger_obj.log("\n -Listing Lights...") + #print("\n -Listing Lights...") for l in light_list: pass - #praxis_logger_obj.log(l.name) - #praxis_logger_obj.log("\n -Counting Groups...") + #print(l.name) + #print("\n -Counting Groups...") for g in groups: - #praxis_logger_obj.log(g) + #print(g) groupCount = int(g) for gc in range(groupCount): try: - #praxis_logger_obj.log("group n:" + str(gc)) + #print("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - #praxis_logger_obj.log(group) + #print(group) group_list.append(group) - #praxis_logger_obj.log(" --done adding") + #print(" --done adding") except: pass - #praxis_logger_obj.log(" --adding failed") + #print(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -66,12 +60,12 @@ class Lights_Module(): #sleep(0.1) #for stuffz in self.bridge_.scenes: - #praxis_logger_obj.log(stuffz) + #print(stuffz) # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - praxis_logger_obj.log("-[Lights_Module] Setup Complete") + print("-[Lights_Module] Setup Complete") def setLight(): pass @@ -124,22 +118,22 @@ class Lights_Module(): def color_string_parser(self, message): maxDigits = config.colorParse_maxDigits - praxis_logger_obj.log("Searching for color...") + print("Searching for color...") xy_color = [0, 0] for text in message: - #praxis_logger_obj.log("testing word") + #print("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - praxis_logger_obj.log("-found: red") + print("-found: red") if "blue" in text.lower(): - praxis_logger_obj.log("-found: blue") + print("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - praxis_logger_obj.log("-found: green") + print("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - praxis_logger_obj.log("-found: yellow") + print("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -147,23 +141,23 @@ class Lights_Module(): if "cyan" in text.lower(): - praxis_logger_obj.log("-found: cyan") + print("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-found: orange") + print("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -171,21 +165,21 @@ class Lights_Module(): if "magenta" in text.lower(): - praxis_logger_obj.log("-found: magenta") + print("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-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), diff --git a/logsStandAlone_Command.log b/logsStandAlone_Command.log deleted file mode 100644 index 3ea97dd..0000000 --- a/logsStandAlone_Command.log +++ /dev/null @@ -1,16 +0,0 @@ -INFO:root:Application running! -INFO:root:testLog -INFO:werkzeug: * Restarting with stat -INFO:root:Application running! -INFO:root:testLog -WARNING:werkzeug: * Debugger is active! -INFO:werkzeug: * Debugger PIN: 760-498-562 -INFO:werkzeug: * Running on http://0.0.0.0:6009/ (Press CTRL+C to quit) -INFO:root:Application running! -INFO:root:testLog -INFO:werkzeug: * Restarting with stat -INFO:root:Application running! -INFO:root:testLog -WARNING:werkzeug: * Debugger is active! -INFO:werkzeug: * Debugger PIN: 760-498-562 -INFO:werkzeug: * Running on http://0.0.0.0:6009/ (Press CTRL+C to quit) diff --git a/main.py b/main.py index 5cf07d1..f0bb16e 100644 --- a/main.py +++ b/main.py @@ -15,12 +15,6 @@ import credentials import threading -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__)) - testModule_: test_module.Test_Module userModule_: user_module.User_Module @@ -31,18 +25,18 @@ def main(inputArg): def test_module_init(dbCert, Empty): - praxis_logger_obj.log("-init [TEST Module]") + print("-init [TEST Module]") #testModule_.dbCredential = dbCert testModule_.main() def user_module_init(dbCert, Empty): - praxis_logger_obj.log("-init [USER Module]") + print("-init [USER Module]") userModule_.dbCredential = dbCert userModule_.main() def thread_main(): if utility.isRunningInDocker() == True: - praxis_logger_obj.log("<[DOCKER Detected]>") + print("<[DOCKER Detected]>") if not config.skip_splashScreen: utility.splashScreen() global credentials_manager @@ -72,11 +66,11 @@ def thread_main(): threads.append(thread_) thread_.start() - praxis_logger_obj.log("---Post Thread Creation Test---\n") + print("---Post Thread Creation Test---\n") for t in threads: t.join() - praxis_logger_obj.log("---Point of no return---") + print("---Point of no return---") if utility.isRunningInDocker() == False: input() diff --git a/praxis_logging.py b/praxis_logging.py deleted file mode 100644 index f1bbad4..0000000 --- a/praxis_logging.py +++ /dev/null @@ -1,13 +0,0 @@ -import logging -import utilities_script - -class praxis_logger(): - def init(self, name): - super().__init__() - self.logName = "logs/" + name + ".log" - utilities_script.get_dir("logs") - logging.basicConfig(filename=self.logName, level=logging.DEBUG) - logging.info('Application running!') - - def log(self, msg): - logging.info(msg) diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index 5f7ec1f..2fa861a 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -4,12 +4,6 @@ from flask import request import channel_rewards.channelRewards_loader as rewards_loader from channel_rewards.channelRewards_base import AbstractChannelRewards -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 @@ -18,7 +12,7 @@ loadedRewards = {} def init(): # todo load entire reward library and cache it here - praxis_logger_obj.log("init stuff") + print("init stuff") loadedRewards[AbstractChannelRewards.ChannelRewardsType.channelPoints] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.channelPoints) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_bits] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_bits) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_subs] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_subs) @@ -28,12 +22,12 @@ def is_reward(reward_name, reward_type) -> bool: #global loadedRewards tempType = reward_type.replace('ChannelRewardsType.', '') realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] - #praxis_logger_obj.log(loadedRewards[realTempType]) + #print(loadedRewards[realTempType]) for reward in loadedRewards[realTempType]: - praxis_logger_obj.log("found: ", reward, "type: ", type(reward)) + print("found: ", reward, "type: ", type(reward)) if reward_name == reward: - praxis_logger_obj.log("Equal") + print("Equal") return True @@ -54,15 +48,15 @@ def handle_reward(source, username, reward_name, reward_type, rewardPrompt, user return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) except: return "None" - #praxis_logger_obj.log("Doing a reward") + #print("Doing a reward") @api.route('/api/v1/reward', methods=['GET']) def reward_check(): if 'reward_name' in request.args and 'reward_type' in request.args: - praxis_logger_obj.log("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) + print("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) if is_reward(request.args['reward_name'], request.args['reward_type']): - praxis_logger_obj.log("about to send") + print("about to send") return flask.make_response('', 200) else: return flask.make_response('', 404) diff --git a/standalone_command.py b/standalone_command.py index bb40055..def50cb 100644 --- a/standalone_command.py +++ b/standalone_command.py @@ -4,12 +4,6 @@ from flask import request import commands.loader as command_loader from commands.command_base import AbstractCommand -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 @@ -27,9 +21,9 @@ def load_commands(): def is_command(command: str) -> bool: - #praxis_logger_obj.log(command) + #print(command) for cmd in loadedCommands: - #praxis_logger_obj.log(cmd) + #print(cmd) if command == cmd: return True @@ -41,7 +35,7 @@ def is_command(command: str) -> bool: def handle_command(source, username, command, rest, bonusData): if command == "!echo": message = "Got payload [%s]" % rest - #praxis_logger_obj.log(message) + #print(message) return flask.make_response("{\"message\":\"%s\"}" % message, 200, {"Content-Type": "application/json"}) cmd:AbstractCommand = loadedCommands[command] @@ -49,7 +43,7 @@ def handle_command(source, username, command, rest, bonusData): cmd_response = cmd.do_command(source, username, command, rest, bonusData) return flask.make_response("{\"message\":\"%s\"}" % cmd_response, 200, {"Content-Type": "application/json"}) - #praxis_logger_obj.log("Doing a command") + #print("Doing a command") @api.route('/api/v1/command', methods=['GET']) diff --git a/standalone_discord_script.py b/standalone_discord_script.py index 7ac4381..9f9c59c 100644 --- a/standalone_discord_script.py +++ b/standalone_discord_script.py @@ -25,12 +25,6 @@ import discord.abc 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 Discord_Module(discord.Client): def __init__(self): super().__init__() @@ -50,17 +44,17 @@ class Discord_Module(discord.Client): await self.start(self.discordCredential.token) def main(self): - praxis_logger_obj.log("starting loop") + print("starting loop") self.loop.create_task(self.startup()) self.loop.run_forever() async def on_ready(self): - praxis_logger_obj.log('Logged on as', self.user) + print('Logged on as', self.user) async def on_message(self, message: discord.Message): - praxis_logger_obj.log("{" + message.guild.name + "}[ " + str(message.channel) + " ](" + message.author.display_name + ")> ") - #praxis_logger_obj.log(message.author.mention) - praxis_logger_obj.log(message.content) + print("{" + message.guild.name + "}[ " + str(message.channel) + " ](" + message.author.display_name + ")> ") + #print(message.author.mention) + print(message.content) if not await self.isSenderBot(message): # This will check for the praxis_bot-tts channel and will TTS stuff from there. @@ -88,7 +82,7 @@ class Discord_Module(discord.Client): if self.cooldownModule.isCooldownActive("discordRateLimit") == False: await self.exec_command(message, command, rest) except: - praxis_logger_obj.log("something went wrong with a command") + print("something went wrong with a command") async def is_command(self, word: str) -> bool: # todo need to url-escape word @@ -103,7 +97,7 @@ class Discord_Module(discord.Client): url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: - praxis_logger_obj.log("Got the following message: %s" % resp.text) + print("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: @@ -127,15 +121,15 @@ class Discord_Module(discord.Client): for bot in config.botList: if message.author.display_name.lower() == bot.lower(): isBot = True - praxis_logger_obj.log("<{ bot detected! }> ") + print("<{ bot detected! }> ") return isBot async def isChannel_inConfigList(self, selectedChannel, selectedList): - #praxis_logger_obj.log(channel) - #praxis_logger_obj.log(selectedList) + #print(channel) + #print(selectedList) is_Self = False for discordChannel in selectedList: - #praxis_logger_obj.log("isSelf: " + str(discordChannel) + " vs " + str(selectedChannel)) + #print("isSelf: " + str(discordChannel) + " vs " + str(selectedChannel)) if discordChannel == selectedChannel: is_Self = True diff --git a/standalone_lights.py b/standalone_lights.py index 38bbaf8..2907fc8 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -11,12 +11,6 @@ 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 @@ -28,7 +22,7 @@ class Lights_Module(): self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - praxis_logger_obj.log("\nStarting up [Lights_Module]...") + print("\nStarting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -38,26 +32,26 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - #praxis_logger_obj.log("\n -Listing Lights...") + #print("\n -Listing Lights...") for l in light_list: pass - #praxis_logger_obj.log(l.name) - #praxis_logger_obj.log("\n -Counting Groups...") + #print(l.name) + #print("\n -Counting Groups...") for g in groups: - #praxis_logger_obj.log(g) + #print(g) groupCount = int(g) for gc in range(groupCount): try: - #praxis_logger_obj.log("group n:" + str(gc)) + #print("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - #praxis_logger_obj.log(group) + #print(group) group_list.append(group) - #praxis_logger_obj.log(" --done adding") + #print(" --done adding") except: pass - #praxis_logger_obj.log(" --adding failed") + #print(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -74,13 +68,13 @@ class Lights_Module(): #sleep(0.1) #for stuffz in self.bridge_.scenes: - #praxis_logger_obj.log(stuffz) + #print(stuffz) # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") - #self.bridge_.run_scene("Downstairs", "Stream") - praxis_logger_obj.log("-[Lights_Module] Setup Complete") + self.bridge_.run_scene("Downstairs", "Stream") + print("-[Lights_Module] Setup Complete") def setLight(): pass @@ -138,22 +132,22 @@ class Lights_Module(): def color_string_parser(self, message): maxDigits = config.colorParse_maxDigits - praxis_logger_obj.log("Searching for color...") + print("Searching for color...") xy_color = [0, 0] for text in message: - #praxis_logger_obj.log("testing word") + #print("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - praxis_logger_obj.log("-found: red") + print("-found: red") if "blue" in text.lower(): - praxis_logger_obj.log("-found: blue") + print("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - praxis_logger_obj.log("-found: green") + print("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - praxis_logger_obj.log("-found: yellow") + print("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -161,23 +155,23 @@ class Lights_Module(): if "cyan" in text.lower(): - praxis_logger_obj.log("-found: cyan") + print("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-found: orange") + print("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -185,21 +179,21 @@ class Lights_Module(): if "magenta" in text.lower(): - praxis_logger_obj.log("-found: magenta") + print("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - praxis_logger_obj.log("-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(): - praxis_logger_obj.log("-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), @@ -214,8 +208,8 @@ def init(): RGB_Lights.main() def do_lights_command(user="", lightGroup="all", command = "", rest = ""): - returnString = "" - praxis_logger_obj.log("about to do something ......") + returnString = "None" + print("about to do something ......") #bot.return_message("\nRGB Command Detected!") if rest is not "": @@ -227,12 +221,12 @@ def do_lights_command(user="", lightGroup="all", command = "", rest = ""): tempParsedMessage = tempFix.split(" ") sceneCommand = False if (len(tempParsedMessage)) > 2: - praxis_logger_obj.log("RGB Command!") + print("RGB Command!") rgb_r = float(tempParsedMessage[1]) rgb_g = float(tempParsedMessage[2]) rgb_b = float(tempParsedMessage[3]) xy_result = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) - praxis_logger_obj.log("got XY") + print("got XY") RGB_Lights.bridge_.set_group(16, "xy", xy_result) #bot.return_message("sent color to [Lights_Module]") else: @@ -265,12 +259,11 @@ def do_lights_command(user="", lightGroup="all", command = "", rest = ""): #bot.return_message("sent color to [Lights_Module]") if sceneCommand == True: - praxis_logger_obj.log("Scene Command!") + print("Scene Command!") - returnString = user + " changed the lights color!" - praxis_logger_obj.log(returnString) + returnString = user + " changed the light's color!" - return flask.make_response("{\"message\":\"%s\"}" % returnString, 200, {"Content-Type": "application/json"}) + return returnString @@ -285,7 +278,7 @@ def exec_lights(): if 'command' not in request.args: return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) - praxis_logger_obj.log("about to do something ......") + print("about to do something ......") RGB_Lights.main() return do_lights_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index 378b6c6..aec0c4c 100644 --- a/standalone_twitch_pubsub.py +++ b/standalone_twitch_pubsub.py @@ -20,12 +20,6 @@ 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__() @@ -48,14 +42,14 @@ class Twitch_Pubsub(): def get_tokens(self): self.twitch.authenticate_app(self.target_scope) for scope_ in self.target_scope: - praxis_logger_obj.log(scope_) + print(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() - if token is not None: praxis_logger_obj.log("found token") - if refresh_token is not None: praxis_logger_obj.log("found refresh_token") - praxis_logger_obj.log(token) - praxis_logger_obj.log(refresh_token) + if token is not None: print("found token") + if refresh_token is not None: print("found refresh_token") + print(token) + print(refresh_token) self.twitch.set_user_authentication(token, self.target_scope, refresh_token) @@ -63,12 +57,12 @@ class Twitch_Pubsub(): self.pubsub = PubSub(self.twitch) #self.pubsub.ping_frequency = 30 self.pubsub.start() - praxis_logger_obj.log("started") + print("started") def next(self): user_id = self.twitch.get_users(logins=[config.autoJoin_TwitchChannel])['data'][0]['id'] - if user_id is not None: praxis_logger_obj.log("found user_id") - praxis_logger_obj.log(user_id) + if user_id is not None: print("found user_id") + print(user_id) self.uuid_1 = self.pubsub.listen_whispers(user_id, self.callback_whisper) self.uuid_2 = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints) #input('press ENTER to close...') @@ -79,22 +73,22 @@ class Twitch_Pubsub(): self.pubsub.stop() def callback_whisper(self, uuid: UUID, data: dict) -> None: - praxis_logger_obj.log('got callback for UUID ' + str(uuid)) + print('got callback for UUID ' + str(uuid)) pprint(data) def callback_channelPoints(self, uuid: UUID, data: dict) -> None: - praxis_logger_obj.log("Channel Point Redemption") - praxis_logger_obj.log('got callback for UUID ' + str(uuid)) + print("Channel Point Redemption") + print('got callback for UUID ' + str(uuid)) pprint(data) - #praxis_logger_obj.log("attempting to get data: ") - #praxis_logger_obj.log(data['data']['redemption']['user']['display_name']) - #praxis_logger_obj.log(data['data']['redemption']['reward']['title']) - #praxis_logger_obj.log(data['data']['redemption']['reward']['prompt']) + #print("attempting to get data: ") + #print(data['data']['redemption']['user']['display_name']) + #print(data['data']['redemption']['reward']['title']) + #print(data['data']['redemption']['reward']['prompt']) try: userinput = data['data']['redemption']['user_input'] except: userinput = "" - #praxis_logger_obj.log(userinput) + #print(userinput) self.callback_EXEC( data['data']['redemption']['user']['display_name'], data['data']['redemption']['reward']['title'], @@ -104,29 +98,29 @@ class Twitch_Pubsub(): data) def callback_bits(self, uuid: UUID, data: dict) -> None: - praxis_logger_obj.log("Bits Redemption") - praxis_logger_obj.log('got callback for UUID ' + str(uuid)) + print("Bits Redemption") + print('got callback for UUID ' + str(uuid)) pprint(data) def callback_subs(self, uuid: UUID, data: dict) -> None: - praxis_logger_obj.log("Subs Redemption") - praxis_logger_obj.log('got callback for UUID ' + str(uuid)) + print("Subs Redemption") + print('got callback for UUID ' + str(uuid)) pprint(data) def callback_EXEC(self, sender, rewardName:str, rewardType, rewardPrompt, userInput, raw_data): try: is_actionable = self.is_reward(rewardName, rewardType) if is_actionable: - praxis_logger_obj.log("Trying to do the thing") + print("Trying to do the thing") if self.cooldownModule.isCooldownActive("twitchChat") == False: self.exec_reward(sender, rewardName, rewardType, rewardPrompt, userInput, raw_data) except: - praxis_logger_obj.log("something went wrong with a reward") + print("something went wrong with a reward") def is_reward(self, rewardName, rewardType): # todo need to url-escape word clean_param = urlencode({'reward_name': rewardName, 'reward_type':rewardType}) - praxis_logger_obj.log(rewardName, rewardType) + print(rewardName, rewardType) #standalone_channelrewards url = "http://standalone_channelrewards:6969/api/v1/reward?%s" % clean_param resp = requests.get(url) @@ -146,7 +140,7 @@ class Twitch_Pubsub(): url = "http://standalone_channelrewards:6969/api/v1/exec_reward?%s" % params resp = requests.get(url) if resp.status_code == 200: - praxis_logger_obj.log("Got the following message: %s" % resp.text) + print("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: diff --git a/standalone_twitch_script.py b/standalone_twitch_script.py index 5313ac9..bb0f82d 100644 --- a/standalone_twitch_script.py +++ b/standalone_twitch_script.py @@ -12,12 +12,6 @@ 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__() @@ -39,7 +33,7 @@ class Twitch_Module(): def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str): channel_name = "#" + channel_name - praxis_logger_obj.log("Connecting to Channel: " + channel_name + "...") + print("Connecting to Channel: " + channel_name + "...") if credential is None: credential = self.twitchCredential @@ -53,23 +47,23 @@ class Twitch_Module(): ) self.chat.subscribe(self.twitch_chat) - praxis_logger_obj.log("Connected to Channel: ", channel_name) + print("Connected to Channel: ", channel_name) def leave_channel(self): - praxis_logger_obj.log("Leaving Channel", self.chat.channel) + print("Leaving Channel", self.chat.channel) self.chat.irc.leave_channel(self.chat.channel) self.chat.irc.socket.close() def send_message(self, message): isBlocked = self.isChannel_inConfigList(self.chat.channel, config.block_TwitchChannelsMessaging) - # praxis_logger_obj.log("isBlocked: " + str(isBlocked) + " for: " + self.chat.channel) + # print("isBlocked: " + str(isBlocked) + " for: " + self.chat.channel) #if self. if utility.contains_slur(message): isBlocked = True if self.cooldownModule.isCooldownActive( "twitchChat") == False and not isBlocked and not config.blockAll_TwitchChatChannelsMessaging: self.chat.send(message) - # praxis_logger_obj.log("Sent ChatMSG") + # print("Sent ChatMSG") self.cooldownModule.actionTrigger("twitchChat") def is_command(self, word: str) -> bool: @@ -85,7 +79,7 @@ class Twitch_Module(): url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: - praxis_logger_obj.log("Got the following message: %s" % resp.text) + print("Got the following message: %s" % resp.text) data = loads(resp.text) msg = data['message'] if msg is not None: @@ -99,7 +93,7 @@ class Twitch_Module(): # This reacts to messages def twitch_chat(self, message: twitch.chat.Message) -> None: - praxis_logger_obj.log("[#" + message.channel + "](" + message.sender + ")> " + message.text) + print("[#" + message.channel + "](" + message.sender + ")> " + message.text) command, rest = utility.parse_line(message.text) try: @@ -108,19 +102,19 @@ class Twitch_Module(): if self.cooldownModule.isCooldownActive("twitchChat") == False: self.exec_command(message ,command, rest) except: - praxis_logger_obj.log("something went wrong with a command") + print("something went wrong with a command") def isChannel_inConfigList(self, selectedChannel, selectedList): - # praxis_logger_obj.log(channel) - # praxis_logger_obj.log(selectedList) + # print(channel) + # print(selectedList) is_Self = False for twitchChannel in selectedList: if twitchChannel == selectedChannel: is_Self = True # if is_Self: - # praxis_logger_obj.log("Is Self") + # print("Is Self") # if not is_Self: - # praxis_logger_obj.log("Is Not Self") + # print("Is Not Self") return is_Self diff --git a/standalone_webSource.py b/standalone_webSource.py index b8509c2..54a7dce 100644 --- a/standalone_webSource.py +++ b/standalone_webSource.py @@ -20,12 +20,6 @@ import utilities_script as utility import chyron_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 webSource_Module(): webSources:Flask = Flask('webSources') @@ -34,7 +28,7 @@ class webSource_Module(): self.dbCredential: credentials.DB_Credential def main(self, port_=5000): - praxis_logger_obj.log("starting up on port: ", port_) + print("starting up on port: ", port_) self.webSources.run(host="0.0.0.0", port= port_) @webSources.route('/') @@ -48,7 +42,7 @@ class webSource_Module(): @webSources.route('/temptext//') def textSource_tempText(filename): - praxis_logger_obj.log("trying file: ", filename) + print("trying file: ", filename) tempModule = tempText_Module.tempText_Module() return tempModule.getTempTextFile(filename) diff --git a/tempText_Module.py b/tempText_Module.py index 749dada..158e912 100644 --- a/tempText_Module.py +++ b/tempText_Module.py @@ -1,11 +1,6 @@ import config import utilities_script as utilities - 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 tempText_Module(): def __init__(self): @@ -62,7 +57,7 @@ class tempText_Module(): file = open(real_file_path, "rb") text = file.read() - #praxis_logger_obj.log(text) + #print(text) file.close return text @@ -79,7 +74,7 @@ class tempTextItem(): self.itemComputedString = "" def setupItem(self, name, title, content): - praxis_logger_obj.log("\nSetting up tempTextItem {", name,"}[", title, content, "]") + print("\nSetting up tempTextItem {", name,"}[", title, content, "]") self.itemName = name self.itemTitle = title self.itemContent = content diff --git a/test_module.py b/test_module.py index 76d77cf..9594d9b 100644 --- a/test_module.py +++ b/test_module.py @@ -3,19 +3,13 @@ import db import credentials -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 Test_Module(): def __init__(self): super().__init__() self.dbCredential: credentials.DB_Credential def main(self): - praxis_logger_obj.log("[TEST Module]> test") + print("[TEST Module]> test") if __name__ == "__main__": diff --git a/tts.py b/tts.py index 0b133d6..6e026aa 100644 --- a/tts.py +++ b/tts.py @@ -1,11 +1,6 @@ import datetime import hashlib - 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__)) import requests from gtts import gTTS @@ -19,9 +14,9 @@ streamLabsUrl = "https://streamlabs.com/polly/speak" def tts(inputText: str, *args): outpath = create_speech_file(inputText) if utility.isRunningInDocker() == True: - praxis_logger_obj.log("Docker Detected, skipping playsound()") + print("Docker Detected, skipping playsound()") else: - praxis_logger_obj.log("Playing Sound...") + print("Playing Sound...") playsound(outpath) @@ -113,6 +108,6 @@ def get_tts_dir(): if __name__ == "__main__": - praxis_logger_obj.log("Enter Text: ") + print("Enter Text: ") textInput = str(input()) tts(textInput) diff --git a/twitch_generate_credentials.py b/twitch_generate_credentials.py index db97d80..cfabaee 100644 --- a/twitch_generate_credentials.py +++ b/twitch_generate_credentials.py @@ -10,12 +10,6 @@ from twitchAPI.oauth import UserAuthenticator from pprint import pprint from uuid import UUID -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_Credential_Maker(): def __init__(self): @@ -27,15 +21,15 @@ class Twitch_Credential_Maker(): def get_tokens(self): self.twitch.authenticate_app(self.target_scope) for scope_ in self.target_scope: - praxis_logger_obj.log(scope_) + print(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() - if token is not None: praxis_logger_obj.log("found token") - if refresh_token is not None: praxis_logger_obj.log("found refresh_token\n") - praxis_logger_obj.log("token: ", token) - praxis_logger_obj.log("refresh_token: ", refresh_token) - praxis_logger_obj.log("") + if token is not None: print("found token") + if refresh_token is not None: print("found refresh_token\n") + print("token: ", token) + print("refresh_token: ", refresh_token) + print("") return token, refresh_token @@ -51,5 +45,5 @@ if __name__ == "__main__": #pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) testModule.get_tokens() - praxis_logger_obj.log("Ready to close") + print("Ready to close") input() \ No newline at end of file diff --git a/user_module.py b/user_module.py index bafd884..023c042 100644 --- a/user_module.py +++ b/user_module.py @@ -13,12 +13,6 @@ from cooldowns import Cooldown_Module 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 User_Module(): def __init__(self): super().__init__() @@ -33,10 +27,10 @@ class User_Module(): def main(self): time.sleep(.01) - praxis_logger_obj.log("\nWaiting on User input...\n\n") + print("\nWaiting on User input...\n\n") if utility.isRunningInDocker() == True: self.inputLoop = False - praxis_logger_obj.log("\nNo User's Input Allowed") + print("\nNo User's Input Allowed") while self.inputLoop: keyboardInput = input() @@ -83,7 +77,7 @@ class User_Module(): command.do_command(self, message) except Exception as e: # Undo the following for debug stuff - #praxis_logger_obj.log(e) + #print(e) pass # we don't care def eval_commands_SpecialActionCheck(self): @@ -94,7 +88,7 @@ class User_Module(): pass def return_message(self, returnedMessage): - praxis_logger_obj.log(returnedMessage) + print(returnedMessage) def tts(self, message): tts.tts(message) diff --git a/utilities_script.py b/utilities_script.py index 61e7911..4cfb4d0 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -1,4 +1,5 @@ from asyncio.tasks import sleep +import os import sys import re import psutil @@ -8,12 +9,6 @@ import time import config as config import art -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__)) - clearScreen = lambda: os.system('cls' if os.name == 'nt' else 'clear') urlMatcher = re.compile("(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))") @@ -27,7 +22,7 @@ def get_args(text: str) -> list: def does_contain_OnlyNumbers(text): isJustNumbers = False - praxis_logger_obj.log("checking numbers") + print("checking numbers") try: for x in range(10): if str(x) in str(text): @@ -40,9 +35,9 @@ def does_contain_OnlyNumbers(text): return isJustNumbers def rescale_value(value, min, max): - #praxis_logger_obj.log("trying Rescale") + #print("trying Rescale") returnValue = (value - min) / (max - min) - #praxis_logger_obj.log("got ", returnValue) + #print("got ", returnValue) return returnValue def get_dir(selected_dir): @@ -67,7 +62,7 @@ def contains_slur(input: str): break if containsSlur: - praxis_logger_obj.log("<{ slur detected! }> ") + print("<{ slur detected! }> ") return containsSlur def parse_line(message: str): @@ -136,9 +131,9 @@ def splashScreen(): art.tprint("----------",font="slant") art.tprint("Praxis Bot",font="graffiti") art.tprint("----------",font="slant") - praxis_logger_obj.log("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") - praxis_logger_obj.log("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) - praxis_logger_obj.log("\n\n\n") + print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd") + print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega) + print("\n\n\n") if not config.skip_splashScreenSleep: time.sleep(3) -- 2.45.2 From f34e53fe1f95297c2644303c39e8414d2de97bc4 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 19:06:58 -0400 Subject: [PATCH 06/14] working without docker --- docker-compose.yaml | 12 ++++++++++++ logs/standalone_channelrewards.py.log | 12 ++++++++++++ praxis_logging.py | 14 ++++++++++++++ standalone_channelrewards.py | 20 +++++++++++++------- 4 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 logs/standalone_channelrewards.py.log create mode 100644 praxis_logging.py diff --git a/docker-compose.yaml b/docker-compose.yaml index cfe798c..7f9643d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,31 +2,43 @@ version: '3.7' services: standalone_command: image: standalone_command + volumes: + - c:/praxis/logs ports: - 6009:6009 environment: - ISDOCKER=cat standalone_channelrewards: image: standalone_channelrewards + volumes: + - c:/praxis/logs ports: - 6969:6969 environment: - ISDOCKER=cat standalone_lights: image: standalone_lights + volumes: + - c:/praxis/logs ports: - 42069:42069 environment: - ISDOCKER=cat standalone_twitchscript: image: standalone_twitchscript + volumes: + - c:/praxis/logs environment: - ISDOCKER=cat standalone_twitch_pubsub: image: standalone_twitch_pubsub + volumes: + - c:/praxis/logs environment: - ISDOCKER=cat standalone_discordscript: image: standalone_discordscript + volumes: + - c:/praxis/logs environment: - ISDOCKER=cat \ No newline at end of file diff --git a/logs/standalone_channelrewards.py.log b/logs/standalone_channelrewards.py.log new file mode 100644 index 0000000..bf8cf84 --- /dev/null +++ b/logs/standalone_channelrewards.py.log @@ -0,0 +1,12 @@ +INFO:root:Application running! +INFO:root: + -Starting Logs: standalone_channelrewards.py +INFO:root:init stuff +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: 760-498-562 +INFO:werkzeug: * Running on http://0.0.0.0:6969/ (Press CTRL+C to quit) diff --git a/praxis_logging.py b/praxis_logging.py new file mode 100644 index 0000000..57c344b --- /dev/null +++ b/praxis_logging.py @@ -0,0 +1,14 @@ +import logging +import utilities_script + +class praxis_logger(): + def init(self, name): + super().__init__() + self.logName = "logs/" + name + ".log" + utilities_script.get_dir("logs") + logging.basicConfig(filename=self.logName, level=logging.DEBUG) + logging.info('Application running!') + + def log(self, msg): + print(self.logName, msg) + logging.info(msg) \ No newline at end of file diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index 2fa861a..5f7ec1f 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -4,6 +4,12 @@ from flask import request import channel_rewards.channelRewards_loader as rewards_loader from channel_rewards.channelRewards_base import AbstractChannelRewards +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 @@ -12,7 +18,7 @@ loadedRewards = {} def init(): # todo load entire reward library and cache it here - print("init stuff") + praxis_logger_obj.log("init stuff") loadedRewards[AbstractChannelRewards.ChannelRewardsType.channelPoints] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.channelPoints) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_bits] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_bits) loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_subs] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_subs) @@ -22,12 +28,12 @@ def is_reward(reward_name, reward_type) -> bool: #global loadedRewards tempType = reward_type.replace('ChannelRewardsType.', '') realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] - #print(loadedRewards[realTempType]) + #praxis_logger_obj.log(loadedRewards[realTempType]) for reward in loadedRewards[realTempType]: - print("found: ", reward, "type: ", type(reward)) + praxis_logger_obj.log("found: ", reward, "type: ", type(reward)) if reward_name == reward: - print("Equal") + praxis_logger_obj.log("Equal") return True @@ -48,15 +54,15 @@ def handle_reward(source, username, reward_name, reward_type, rewardPrompt, user return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) except: return "None" - #print("Doing a reward") + #praxis_logger_obj.log("Doing a reward") @api.route('/api/v1/reward', methods=['GET']) def reward_check(): if 'reward_name' in request.args and 'reward_type' in request.args: - print("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) + praxis_logger_obj.log("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) if is_reward(request.args['reward_name'], request.args['reward_type']): - print("about to send") + praxis_logger_obj.log("about to send") return flask.make_response('', 200) else: return flask.make_response('', 404) -- 2.45.2 From 8dd069f7b9ae22187ba400e962e754de313d6d7c Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 27 Apr 2021 23:31:43 -0400 Subject: [PATCH 07/14] Working Docker Logging --- .gitignore | 1 + docker-compose.yaml | 12 ++++++------ standalone_command.py | 6 ++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d05686a..06e3763 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ credentials/ .idea/ stream_sources/chyron.txt stream_sources/brb.txt +*.log \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 7f9643d..73c3fe5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,7 +3,7 @@ services: standalone_command: image: standalone_command volumes: - - c:/praxis/logs + - "./:/Praxis/" ports: - 6009:6009 environment: @@ -11,7 +11,7 @@ services: standalone_channelrewards: image: standalone_channelrewards volumes: - - c:/praxis/logs + - "./:/Praxis/" ports: - 6969:6969 environment: @@ -19,7 +19,7 @@ services: standalone_lights: image: standalone_lights volumes: - - c:/praxis/logs + - "./:/Praxis/" ports: - 42069:42069 environment: @@ -27,18 +27,18 @@ services: standalone_twitchscript: image: standalone_twitchscript volumes: - - c:/praxis/logs + - "./:/Praxis/" environment: - ISDOCKER=cat standalone_twitch_pubsub: image: standalone_twitch_pubsub volumes: - - c:/praxis/logs + - "./:/Praxis/" environment: - ISDOCKER=cat standalone_discordscript: image: standalone_discordscript volumes: - - c:/praxis/logs + - "./:/Praxis/" environment: - ISDOCKER=cat \ No newline at end of file diff --git a/standalone_command.py b/standalone_command.py index def50cb..527cfb8 100644 --- a/standalone_command.py +++ b/standalone_command.py @@ -4,6 +4,12 @@ from flask import request import commands.loader as command_loader from commands.command_base import AbstractCommand +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 -- 2.45.2 From 6905e211c7c7149d8f55d2d67aa8a8a3b8471a02 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 01:25:40 -0400 Subject: [PATCH 08/14] logging --- .gitignore | 3 +- commands/implemented/Command_lights_v2.py | 71 +++++++---------------- logs/standalone_channelrewards.py.log | 26 +++++++++ standalone_lights.py | 9 ++- standalone_twitch_pubsub.py | 6 ++ standalone_twitch_script.py | 6 ++ 6 files changed, 68 insertions(+), 53 deletions(-) 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__() -- 2.45.2 From 1d07fb449d7afb946b3ea4aa4a0aaf5bc3299d60 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 01:25:53 -0400 Subject: [PATCH 09/14] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 96f3a00..ac870d4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ credentials/ stream_sources/chyron.txt stream_sources/brb.txt *.log -*.log -- 2.45.2 From 2c6fd90a0ebf3cda0be02587c751b13ca4a557f1 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 03:01:40 -0400 Subject: [PATCH 10/14] Fully Working AFAIK --- .../implemented/ChannelReward_Hydration.py | 2 +- commands/implemented/Command_lights_v2.py | 6 +- logs/standalone_channelrewards.py.log | 136 +++++++++++++++--- standalone_channelrewards.py | 16 ++- standalone_lights.py | 65 +++++---- standalone_twitch_pubsub.py | 10 +- 6 files changed, 177 insertions(+), 58 deletions(-) diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index cb16a2c..974a0e4 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -34,7 +34,7 @@ class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta): data = loads(resp.text) msg = data['message'] if msg is not None: - pass + return msg # todo send to logger and other relevent services else: # todo handle failed requests diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py index ef78d03..d5173f4 100644 --- a/commands/implemented/Command_lights_v2.py +++ b/commands/implemented/Command_lights_v2.py @@ -6,6 +6,7 @@ from json import loads from urllib.parse import urlencode import requests + class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): """ this is the test command. @@ -20,8 +21,9 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): def do_command(self, source = AbstractCommand.CommandSource.default, user = "User", command = "", rest = "", bonusData = None): returnString = "" + print("\n Command>: " + command + rest) - returnString = self.dothething(user, 16, "!lights hydration", "") + returnString = self.dothething(user, 16, command, rest) return returnString @@ -40,7 +42,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): # todo send to logger and other relevent services else: # todo handle failed requests - pass + return None 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 34a165d..4ac5be9 100644 --- a/logs/standalone_channelrewards.py.log +++ b/logs/standalone_channelrewards.py.log @@ -2,18 +2,6 @@ INFO:root:Application running! INFO:root: -Starting Logs: standalone_channelrewards.py INFO:root:init stuff -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: 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! @@ -21,7 +9,26 @@ INFO:root: -Starting Logs: standalone_channelrewards.py INFO:root:init stuff WARNING:werkzeug: * Debugger is active! -INFO:werkzeug: * Debugger PIN: 758-762-350 +INFO:werkzeug: * Debugger PIN: 697-151-642 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:49:47] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug: * Detected change in '/Praxis/channel_rewards/implemented/ChannelReward_Hydration.py', reloading +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: 697-151-642 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:50:59] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug: * Detected change in '/Praxis/channel_rewards/implemented/ChannelReward_Hydration.py', reloading +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: 697-151-642 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:51:19] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - INFO:root:Application running! INFO:root: -Starting Logs: standalone_channelrewards.py @@ -33,6 +40,103 @@ 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 - +INFO:werkzeug: * Debugger PIN: 697-151-642 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:52:54] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading +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: 697-151-642 +INFO:root:reward_name: Hydratereward_type: ChannelRewardsType.channelPoints +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:54:10] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +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: 697-151-642 +INFO:root:reward_name: Hydratereward_type: ChannelRewardsType.channelPoints +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:54:21] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading +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: 697-151-642 +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: 697-151-642 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:55:05] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:57:43] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - +INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading +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: 697-151-642 +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: 697-151-642 +INFO:root:Equal +INFO:root:about to send +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:59:26] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 200 - +INFO:root: + About to try a reward +INFO:root:ChannelRewardsSource.Twitch +INFO:root:Hydrate +INFO:root:ChannelRewardsType.channelPoints +INFO:root:Make me take a sip of water +INFO:root: +INFO:root:{'type': 'reward-redeemed', 'data': {'timestamp': '2021-04-28T06:59:27.946826068Z', 'redemption': {'id': '72f37b3d-f01d-44e0-9f63-91d17243cbe7', 'user': {'id': '50897047', 'login': 'thecuriousnerd', 'display_name': 'TheCuriousNerd'}, 'channel_id': '50897047', 'redeemed_at': '2021-04-28T06:59:27.946826068Z', 'reward': {'id': '92c89d8c-cf01-45f6-89f4-5f07ad576882', 'channel_id': '50897047', 'title': 'Hydrate', 'prompt': 'Make me take a sip of water', 'cost': 50, 'is_user_input_required': False, 'is_sub_only': False, 'image': None, 'default_image': {'url_1x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-1.png', 'url_2x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-2.png', 'url_4x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-4.png'}, 'background_color': '#1C4592', 'is_enabled': True, 'is_paused': False, 'is_in_stock': True, 'max_per_stream': {'is_enabled': False, 'max_per_stream': 1}, 'should_redemptions_skip_request_queue': False, 'template_id': 'template:41d5eae8-4deb-4541-b681-ebdcb3125c0f', 'updated_for_indicator_at': '2020-07-02T23:46:33.40915846Z', 'max_per_user_per_stream': {'is_enabled': False, 'max_per_user_per_stream': 0}, 'global_cooldown': {'is_enabled': False, 'global_cooldown_seconds': 0}, 'redemptions_redeemed_current_stream': None, 'cooldown_expires_at': None}, 'status': 'UNFULFILLED'}}} +INFO:root: + trying to handle reward: Hydrate +DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): standalone_lights:42069 +DEBUG:urllib3.connectionpool:http://standalone_lights:42069 "GET /api/v1/exec_lights?user_name=TheCuriousNerd&light_group=16&command=%21lights+hydration&rest= HTTP/1.1" 200 55 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:59:28] "GET /api/v1/exec_reward?reward_source=ChannelRewardsSource.Twitch&user_name=TheCuriousNerd&reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints&reward_prompt=Make+me+take+a+sip+of+water&user_input=&bonus_data=%7B%27type%27%3A+%27reward-redeemed%27%2C+%27data%27%3A+%7B%27timestamp%27%3A+%272021-04-28T06%3A59%3A27.946826068Z%27%2C+%27redemption%27%3A+%7B%27id%27%3A+%2772f37b3d-f01d-44e0-9f63-91d17243cbe7%27%2C+%27user%27%3A+%7B%27id%27%3A+%2750897047%27%2C+%27login%27%3A+%27thecuriousnerd%27%2C+%27display_name%27%3A+%27TheCuriousNerd%27%7D%2C+%27channel_id%27%3A+%2750897047%27%2C+%27redeemed_at%27%3A+%272021-04-28T06%3A59%3A27.946826068Z%27%2C+%27reward%27%3A+%7B%27id%27%3A+%2792c89d8c-cf01-45f6-89f4-5f07ad576882%27%2C+%27channel_id%27%3A+%2750897047%27%2C+%27title%27%3A+%27Hydrate%27%2C+%27prompt%27%3A+%27Make+me+take+a+sip+of+water%27%2C+%27cost%27%3A+50%2C+%27is_user_input_required%27%3A+False%2C+%27is_sub_only%27%3A+False%2C+%27image%27%3A+None%2C+%27default_image%27%3A+%7B%27url_1x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-1.png%27%2C+%27url_2x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-2.png%27%2C+%27url_4x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-4.png%27%7D%2C+%27background_color%27%3A+%27%231C4592%27%2C+%27is_enabled%27%3A+True%2C+%27is_paused%27%3A+False%2C+%27is_in_stock%27%3A+True%2C+%27max_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_stream%27%3A+1%7D%2C+%27should_redemptions_skip_request_queue%27%3A+False%2C+%27template_id%27%3A+%27template%3A41d5eae8-4deb-4541-b681-ebdcb3125c0f%27%2C+%27updated_for_indicator_at%27%3A+%272020-07-02T23%3A46%3A33.40915846Z%27%2C+%27max_per_user_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_user_per_stream%27%3A+0%7D%2C+%27global_cooldown%27%3A+%7B%27is_enabled%27%3A+False%2C+%27global_cooldown_seconds%27%3A+0%7D%2C+%27redemptions_redeemed_current_stream%27%3A+None%2C+%27cooldown_expires_at%27%3A+None%7D%2C+%27status%27%3A+%27UNFULFILLED%27%7D%7D%7D HTTP/1.1" 200 - +INFO:root:Equal +INFO:root:about to send +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 07:01:18] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 200 - +INFO:root: + About to try a reward +INFO:root:ChannelRewardsSource.Twitch +INFO:root:Hydrate +INFO:root:ChannelRewardsType.channelPoints +INFO:root:Make me take a sip of water +INFO:root: +INFO:root:{'type': 'reward-redeemed', 'data': {'timestamp': '2021-04-28T07:01:19.498040456Z', 'redemption': {'id': 'a7a4ba13-c702-46b6-a2c3-60851a746eaa', 'user': {'id': '50897047', 'login': 'thecuriousnerd', 'display_name': 'TheCuriousNerd'}, 'channel_id': '50897047', 'redeemed_at': '2021-04-28T07:01:19.498040456Z', 'reward': {'id': '92c89d8c-cf01-45f6-89f4-5f07ad576882', 'channel_id': '50897047', 'title': 'Hydrate', 'prompt': 'Make me take a sip of water', 'cost': 50, 'is_user_input_required': False, 'is_sub_only': False, 'image': None, 'default_image': {'url_1x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-1.png', 'url_2x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-2.png', 'url_4x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-4.png'}, 'background_color': '#1C4592', 'is_enabled': True, 'is_paused': False, 'is_in_stock': True, 'max_per_stream': {'is_enabled': False, 'max_per_stream': 1}, 'should_redemptions_skip_request_queue': False, 'template_id': 'template:41d5eae8-4deb-4541-b681-ebdcb3125c0f', 'updated_for_indicator_at': '2020-07-02T23:46:33.40915846Z', 'max_per_user_per_stream': {'is_enabled': False, 'max_per_user_per_stream': 0}, 'global_cooldown': {'is_enabled': False, 'global_cooldown_seconds': 0}, 'redemptions_redeemed_current_stream': None, 'cooldown_expires_at': None}, 'status': 'UNFULFILLED'}}} +INFO:root: + trying to handle reward: Hydrate +DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): standalone_lights:42069 +DEBUG:urllib3.connectionpool:http://standalone_lights:42069 "GET /api/v1/exec_lights?user_name=TheCuriousNerd&light_group=16&command=%21lights+hydration&rest= HTTP/1.1" 200 55 +INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 07:01:19] "GET /api/v1/exec_reward?reward_source=ChannelRewardsSource.Twitch&user_name=TheCuriousNerd&reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints&reward_prompt=Make+me+take+a+sip+of+water&user_input=&bonus_data=%7B%27type%27%3A+%27reward-redeemed%27%2C+%27data%27%3A+%7B%27timestamp%27%3A+%272021-04-28T07%3A01%3A19.498040456Z%27%2C+%27redemption%27%3A+%7B%27id%27%3A+%27a7a4ba13-c702-46b6-a2c3-60851a746eaa%27%2C+%27user%27%3A+%7B%27id%27%3A+%2750897047%27%2C+%27login%27%3A+%27thecuriousnerd%27%2C+%27display_name%27%3A+%27TheCuriousNerd%27%7D%2C+%27channel_id%27%3A+%2750897047%27%2C+%27redeemed_at%27%3A+%272021-04-28T07%3A01%3A19.498040456Z%27%2C+%27reward%27%3A+%7B%27id%27%3A+%2792c89d8c-cf01-45f6-89f4-5f07ad576882%27%2C+%27channel_id%27%3A+%2750897047%27%2C+%27title%27%3A+%27Hydrate%27%2C+%27prompt%27%3A+%27Make+me+take+a+sip+of+water%27%2C+%27cost%27%3A+50%2C+%27is_user_input_required%27%3A+False%2C+%27is_sub_only%27%3A+False%2C+%27image%27%3A+None%2C+%27default_image%27%3A+%7B%27url_1x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-1.png%27%2C+%27url_2x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-2.png%27%2C+%27url_4x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-4.png%27%7D%2C+%27background_color%27%3A+%27%231C4592%27%2C+%27is_enabled%27%3A+True%2C+%27is_paused%27%3A+False%2C+%27is_in_stock%27%3A+True%2C+%27max_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_stream%27%3A+1%7D%2C+%27should_redemptions_skip_request_queue%27%3A+False%2C+%27template_id%27%3A+%27template%3A41d5eae8-4deb-4541-b681-ebdcb3125c0f%27%2C+%27updated_for_indicator_at%27%3A+%272020-07-02T23%3A46%3A33.40915846Z%27%2C+%27max_per_user_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_user_per_stream%27%3A+0%7D%2C+%27global_cooldown%27%3A+%7B%27is_enabled%27%3A+False%2C+%27global_cooldown_seconds%27%3A+0%7D%2C+%27redemptions_redeemed_current_stream%27%3A+None%2C+%27cooldown_expires_at%27%3A+None%7D%2C+%27status%27%3A+%27UNFULFILLED%27%7D%7D%7D HTTP/1.1" 200 - diff --git a/standalone_channelrewards.py b/standalone_channelrewards.py index 5f7ec1f..34db99a 100644 --- a/standalone_channelrewards.py +++ b/standalone_channelrewards.py @@ -31,7 +31,7 @@ def is_reward(reward_name, reward_type) -> bool: #praxis_logger_obj.log(loadedRewards[realTempType]) for reward in loadedRewards[realTempType]: - praxis_logger_obj.log("found: ", reward, "type: ", type(reward)) + #praxis_logger_obj.log("found: ", reward, "type: ", type(reward)) if reward_name == reward: praxis_logger_obj.log("Equal") return True @@ -45,6 +45,7 @@ def is_reward(reward_name, reward_type) -> bool: def handle_reward(source, username, reward_name, reward_type, rewardPrompt, userInput, bonusData): #reward:AbstractChannelRewards = loadedRewards[reward_name] + praxis_logger_obj.log("\n trying to handle reward: " + reward_name) try: tempType = reward_type.replace('ChannelRewardsType.', '') realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType] @@ -53,14 +54,14 @@ def handle_reward(source, username, reward_name, reward_type, rewardPrompt, user reward_response = reward.do_ChannelReward(source, username, reward_name, rewardPrompt, userInput, bonusData) return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"}) except: - return "None" + return flask.make_response("This is a magic test", 500) #praxis_logger_obj.log("Doing a reward") @api.route('/api/v1/reward', methods=['GET']) def reward_check(): if 'reward_name' in request.args and 'reward_type' in request.args: - praxis_logger_obj.log("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type']) + #praxis_logger_obj.log("reward_name: "+ request.args['reward_name']+"reward_type: "+ request.args['reward_type']) if is_reward(request.args['reward_name'], request.args['reward_type']): praxis_logger_obj.log("about to send") return flask.make_response('', 200) @@ -73,7 +74,7 @@ def exec_reward(): if 'reward_name' not in request.args: return flask.make_response('{\"text\":"Argument \'reward_name\' not in request"}', 400) if 'reward_type' not in request.args: - return flask.make_response('{\"text\":"Argument \'reward_name\' not in request"}', 400) + return flask.make_response('{\"text\":"Argument \'reward_type\' not in request"}', 400) if 'reward_prompt' not in request.args: return flask.make_response('{\"text\":"Argument \'reward_prompt\' not in request"}', 400) if 'user_input' not in request.args: @@ -87,7 +88,14 @@ def exec_reward(): username = "User" else: username = request.args['user_name'] + praxis_logger_obj.log("\n About to try a reward") + praxis_logger_obj.log(request.args['reward_source']) + praxis_logger_obj.log(request.args['reward_name']) + praxis_logger_obj.log(request.args['reward_type']) + praxis_logger_obj.log(request.args['reward_prompt']) + praxis_logger_obj.log(request.args['user_input']) + praxis_logger_obj.log(request.args['bonus_data']) return handle_reward( request.args['reward_source'], username, diff --git a/standalone_lights.py b/standalone_lights.py index 1d2f850..409796d 100644 --- a/standalone_lights.py +++ b/standalone_lights.py @@ -27,7 +27,7 @@ class Lights_Module(): self.bridge_:Bridge = Bridge('192.168.191.146') def main(self): - print("\nStarting up [Lights_Module]...") + praxis_logger_obj.log("\nStarting up [Lights_Module]...") self.bridge_.connect() self.bridge_.get_api() @@ -37,26 +37,26 @@ class Lights_Module(): groups = self.bridge_.get_group() groupCount = 0 - #print("\n -Listing Lights...") + #praxis_logger_obj.log("\n -Listing Lights...") for l in light_list: pass - #print(l.name) - #print("\n -Counting Groups...") + #praxis_logger_obj.log(l.name) + #praxis_logger_obj.log("\n -Counting Groups...") for g in groups: - #print(g) + #praxis_logger_obj.log(g) groupCount = int(g) for gc in range(groupCount): try: - #print("group n:" + str(gc)) + #praxis_logger_obj.log("group n:" + str(gc)) group = self.bridge_.get_group(gc ,'name') - #print(group) + #praxis_logger_obj.log(group) group_list.append(group) - #print(" --done adding") + #praxis_logger_obj.log(" --done adding") except: pass - #print(" --adding failed") + #praxis_logger_obj.log(" --adding failed") #self.bridge_.set_group(18, "bri", 254) #This is max Brightness #self.bridge_.set_group(18, "on", True) #This is will turn ON @@ -73,13 +73,13 @@ class Lights_Module(): #sleep(0.1) #for stuffz in self.bridge_.scenes: - #print(stuffz) + #praxis_logger_obj.log(stuffz) # This will set the group Downstairs to the Stream scene #self.bridge_.run_scene("Downstairs", "Stream") #self.bridge_.run_scene("Downstairs", "Stream") - print("-[Lights_Module] Setup Complete") + praxis_logger_obj.log("-[Lights_Module] Setup Complete") def setLight(): pass @@ -137,22 +137,22 @@ class Lights_Module(): def color_string_parser(self, message): maxDigits = config.colorParse_maxDigits - print("Searching for color...") + praxis_logger_obj.log("Searching for color...") xy_color = [0, 0] for text in message: - #print("testing word") + #praxis_logger_obj.log("testing word") if "red" in text.lower(): xy_color = self.rgb_to_xy(1,0,0) - print("-found: red") + praxis_logger_obj.log("-found: red") if "blue" in text.lower(): - print("-found: blue") + praxis_logger_obj.log("-found: blue") xy_color = self.rgb_to_xy(0,0,1) if "green" in text.lower(): - print("-found: green") + praxis_logger_obj.log("-found: green") xy_color = self.rgb_to_xy(0,1,0) if "yellow" in text.lower(): - print("-found: yellow") + praxis_logger_obj.log("-found: yellow") xy_color = self.rgb_to_xy( 0.7, 0.64, @@ -160,23 +160,23 @@ class Lights_Module(): if "cyan" in text.lower(): - print("-found: cyan") + praxis_logger_obj.log("-found: cyan") xy_color = self.rgb_to_xy(0,1,1) if "aquamarine" in text.lower(): - print("-found: aquamarine") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: orange") xy_color = self.rgb_to_xy( 1, round(utilities.rescale_value(126,0,254),maxDigits), @@ -184,21 +184,21 @@ class Lights_Module(): if "magenta" in text.lower(): - print("-found: magenta") + praxis_logger_obj.log("-found: magenta") xy_color = self.rgb_to_xy( 1, 0, 1) if "purple" in text.lower(): - print("-found: purple") + praxis_logger_obj.log("-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") + praxis_logger_obj.log("-found: violet") xy_color = self.rgb_to_xy( round(utilities.rescale_value(237,0,254),maxDigits), round(utilities.rescale_value(129,0,254),maxDigits), @@ -214,24 +214,23 @@ def init(): def do_lights_command(user="", lightGroup="all", command = "", rest = ""): returnString = "None" - print("about to do something ......") - + praxis_logger_obj.log("about to do something ......") + praxis_logger_obj.log("about to do something with: " + command + " " + rest) #bot.return_message("\nRGB Command Detected!") if rest is not "": tempFix = command + " " + rest else: - pass - tempFix = command + tempFix = command tempParsedMessage = tempFix.split(" ") sceneCommand = False if (len(tempParsedMessage)) > 2: - print("RGB Command!") + praxis_logger_obj.log("RGB Command!") rgb_r = float(tempParsedMessage[1]) rgb_g = float(tempParsedMessage[2]) rgb_b = float(tempParsedMessage[3]) xy_result = RGB_Lights.rgb_to_xy(rgb_r, rgb_g, rgb_b) - print("got XY") + praxis_logger_obj.log("got XY") RGB_Lights.bridge_.set_group(16, "xy", xy_result) #bot.return_message("sent color to [Lights_Module]") else: @@ -264,11 +263,11 @@ def do_lights_command(user="", lightGroup="all", command = "", rest = ""): #bot.return_message("sent color to [Lights_Module]") if sceneCommand == True: - print("Scene Command!") + praxis_logger_obj.log("Scene Command!") returnString = user + " changed the light's color!" - return returnString + return flask.make_response("{\"message\":\"%s\"}" % returnString, 200, {"Content-Type": "application/json"}) @@ -283,7 +282,7 @@ def exec_lights(): if 'command' not in request.args: return flask.make_response('{\"text\":"Argument \'scene_name\' not in request"}', 400) - print("about to do something ......") + praxis_logger_obj.log("about to do something ......") RGB_Lights.main() return do_lights_command(user_name, request.args['light_group'], request.args['command'], request.args['rest']) diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index 5ffb7fd..e50e2d1 100644 --- a/standalone_twitch_pubsub.py +++ b/standalone_twitch_pubsub.py @@ -94,7 +94,13 @@ class Twitch_Pubsub(): userinput = data['data']['redemption']['user_input'] except: userinput = "" - #print(userinput) + praxis_logger_obj.log("\n\n") + praxis_logger_obj.log(data['data']['redemption']['user']['display_name']) + praxis_logger_obj.log(data['data']['redemption']['reward']['title']) + praxis_logger_obj.log(AbstractChannelRewards.ChannelRewardsType.channelPoints) + praxis_logger_obj.log(data['data']['redemption']['reward']['prompt']) + praxis_logger_obj.log(userinput) + praxis_logger_obj.log(data) self.callback_EXEC( data['data']['redemption']['user']['display_name'], data['data']['redemption']['reward']['title'], @@ -117,7 +123,7 @@ class Twitch_Pubsub(): try: is_actionable = self.is_reward(rewardName, rewardType) if is_actionable: - print("Trying to do the thing") + praxis_logger_obj.log("Trying to do the thing") if self.cooldownModule.isCooldownActive("twitchChat") == False: self.exec_reward(sender, rewardName, rewardType, rewardPrompt, userInput, raw_data) except: -- 2.45.2 From acac919f818959eb2f7d0fe20f58c7f754a0ef0e Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 03:20:15 -0400 Subject: [PATCH 11/14] more logging --- standalone_discord_script.py | 9 +++++++++ standalone_twitch_script.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/standalone_discord_script.py b/standalone_discord_script.py index 9f9c59c..df06fbc 100644 --- a/standalone_discord_script.py +++ b/standalone_discord_script.py @@ -25,6 +25,12 @@ import discord.abc 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 Discord_Module(discord.Client): def __init__(self): super().__init__() @@ -56,6 +62,9 @@ class Discord_Module(discord.Client): #print(message.author.mention) print(message.content) + debugLogString= "\n\n{" + message.guild.name + "}[ " + str(message.channel) + " ](" + message.author.display_name +")> " + message.content + "\n" + praxis_logger_obj.log(debugLogString) + if not await self.isSenderBot(message): # This will check for the praxis_bot-tts channel and will TTS stuff from there. #await self.eval_triggeredEvents(message) diff --git a/standalone_twitch_script.py b/standalone_twitch_script.py index fa3d0c9..56c5dd4 100644 --- a/standalone_twitch_script.py +++ b/standalone_twitch_script.py @@ -102,6 +102,8 @@ class Twitch_Module(): print("[#" + message.channel + "](" + message.sender + ")> " + message.text) command, rest = utility.parse_line(message.text) + praxis_logger_obj.log("\n[#" + message.channel + "](" + message.sender + ")> " + message.text) + try: is_actionable = self.is_command(command) if is_actionable: -- 2.45.2 From 53c20a200756dfc49abe8e88fda4576411c955b8 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 03:21:08 -0400 Subject: [PATCH 12/14] Delete standalone_channelrewards.py.log --- logs/standalone_channelrewards.py.log | 142 -------------------------- 1 file changed, 142 deletions(-) delete mode 100644 logs/standalone_channelrewards.py.log diff --git a/logs/standalone_channelrewards.py.log b/logs/standalone_channelrewards.py.log deleted file mode 100644 index 4ac5be9..0000000 --- a/logs/standalone_channelrewards.py.log +++ /dev/null @@ -1,142 +0,0 @@ -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: 697-151-642 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:49:47] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug: * Detected change in '/Praxis/channel_rewards/implemented/ChannelReward_Hydration.py', reloading -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: 697-151-642 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:50:59] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug: * Detected change in '/Praxis/channel_rewards/implemented/ChannelReward_Hydration.py', reloading -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: 697-151-642 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:51:19] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -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: 697-151-642 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:52:54] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading -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: 697-151-642 -INFO:root:reward_name: Hydratereward_type: ChannelRewardsType.channelPoints -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:54:10] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -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: 697-151-642 -INFO:root:reward_name: Hydratereward_type: ChannelRewardsType.channelPoints -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:54:21] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading -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: 697-151-642 -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: 697-151-642 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:55:05] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:57:43] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 500 - -INFO:werkzeug: * Detected change in '/Praxis/standalone_channelrewards.py', reloading -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: 697-151-642 -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: 697-151-642 -INFO:root:Equal -INFO:root:about to send -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:59:26] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 200 - -INFO:root: - About to try a reward -INFO:root:ChannelRewardsSource.Twitch -INFO:root:Hydrate -INFO:root:ChannelRewardsType.channelPoints -INFO:root:Make me take a sip of water -INFO:root: -INFO:root:{'type': 'reward-redeemed', 'data': {'timestamp': '2021-04-28T06:59:27.946826068Z', 'redemption': {'id': '72f37b3d-f01d-44e0-9f63-91d17243cbe7', 'user': {'id': '50897047', 'login': 'thecuriousnerd', 'display_name': 'TheCuriousNerd'}, 'channel_id': '50897047', 'redeemed_at': '2021-04-28T06:59:27.946826068Z', 'reward': {'id': '92c89d8c-cf01-45f6-89f4-5f07ad576882', 'channel_id': '50897047', 'title': 'Hydrate', 'prompt': 'Make me take a sip of water', 'cost': 50, 'is_user_input_required': False, 'is_sub_only': False, 'image': None, 'default_image': {'url_1x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-1.png', 'url_2x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-2.png', 'url_4x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-4.png'}, 'background_color': '#1C4592', 'is_enabled': True, 'is_paused': False, 'is_in_stock': True, 'max_per_stream': {'is_enabled': False, 'max_per_stream': 1}, 'should_redemptions_skip_request_queue': False, 'template_id': 'template:41d5eae8-4deb-4541-b681-ebdcb3125c0f', 'updated_for_indicator_at': '2020-07-02T23:46:33.40915846Z', 'max_per_user_per_stream': {'is_enabled': False, 'max_per_user_per_stream': 0}, 'global_cooldown': {'is_enabled': False, 'global_cooldown_seconds': 0}, 'redemptions_redeemed_current_stream': None, 'cooldown_expires_at': None}, 'status': 'UNFULFILLED'}}} -INFO:root: - trying to handle reward: Hydrate -DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): standalone_lights:42069 -DEBUG:urllib3.connectionpool:http://standalone_lights:42069 "GET /api/v1/exec_lights?user_name=TheCuriousNerd&light_group=16&command=%21lights+hydration&rest= HTTP/1.1" 200 55 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 06:59:28] "GET /api/v1/exec_reward?reward_source=ChannelRewardsSource.Twitch&user_name=TheCuriousNerd&reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints&reward_prompt=Make+me+take+a+sip+of+water&user_input=&bonus_data=%7B%27type%27%3A+%27reward-redeemed%27%2C+%27data%27%3A+%7B%27timestamp%27%3A+%272021-04-28T06%3A59%3A27.946826068Z%27%2C+%27redemption%27%3A+%7B%27id%27%3A+%2772f37b3d-f01d-44e0-9f63-91d17243cbe7%27%2C+%27user%27%3A+%7B%27id%27%3A+%2750897047%27%2C+%27login%27%3A+%27thecuriousnerd%27%2C+%27display_name%27%3A+%27TheCuriousNerd%27%7D%2C+%27channel_id%27%3A+%2750897047%27%2C+%27redeemed_at%27%3A+%272021-04-28T06%3A59%3A27.946826068Z%27%2C+%27reward%27%3A+%7B%27id%27%3A+%2792c89d8c-cf01-45f6-89f4-5f07ad576882%27%2C+%27channel_id%27%3A+%2750897047%27%2C+%27title%27%3A+%27Hydrate%27%2C+%27prompt%27%3A+%27Make+me+take+a+sip+of+water%27%2C+%27cost%27%3A+50%2C+%27is_user_input_required%27%3A+False%2C+%27is_sub_only%27%3A+False%2C+%27image%27%3A+None%2C+%27default_image%27%3A+%7B%27url_1x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-1.png%27%2C+%27url_2x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-2.png%27%2C+%27url_4x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-4.png%27%7D%2C+%27background_color%27%3A+%27%231C4592%27%2C+%27is_enabled%27%3A+True%2C+%27is_paused%27%3A+False%2C+%27is_in_stock%27%3A+True%2C+%27max_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_stream%27%3A+1%7D%2C+%27should_redemptions_skip_request_queue%27%3A+False%2C+%27template_id%27%3A+%27template%3A41d5eae8-4deb-4541-b681-ebdcb3125c0f%27%2C+%27updated_for_indicator_at%27%3A+%272020-07-02T23%3A46%3A33.40915846Z%27%2C+%27max_per_user_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_user_per_stream%27%3A+0%7D%2C+%27global_cooldown%27%3A+%7B%27is_enabled%27%3A+False%2C+%27global_cooldown_seconds%27%3A+0%7D%2C+%27redemptions_redeemed_current_stream%27%3A+None%2C+%27cooldown_expires_at%27%3A+None%7D%2C+%27status%27%3A+%27UNFULFILLED%27%7D%7D%7D HTTP/1.1" 200 - -INFO:root:Equal -INFO:root:about to send -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 07:01:18] "GET /api/v1/reward?reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints HTTP/1.1" 200 - -INFO:root: - About to try a reward -INFO:root:ChannelRewardsSource.Twitch -INFO:root:Hydrate -INFO:root:ChannelRewardsType.channelPoints -INFO:root:Make me take a sip of water -INFO:root: -INFO:root:{'type': 'reward-redeemed', 'data': {'timestamp': '2021-04-28T07:01:19.498040456Z', 'redemption': {'id': 'a7a4ba13-c702-46b6-a2c3-60851a746eaa', 'user': {'id': '50897047', 'login': 'thecuriousnerd', 'display_name': 'TheCuriousNerd'}, 'channel_id': '50897047', 'redeemed_at': '2021-04-28T07:01:19.498040456Z', 'reward': {'id': '92c89d8c-cf01-45f6-89f4-5f07ad576882', 'channel_id': '50897047', 'title': 'Hydrate', 'prompt': 'Make me take a sip of water', 'cost': 50, 'is_user_input_required': False, 'is_sub_only': False, 'image': None, 'default_image': {'url_1x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-1.png', 'url_2x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-2.png', 'url_4x': 'https://static-cdn.jtvnw.net/custom-reward-images/tree-4.png'}, 'background_color': '#1C4592', 'is_enabled': True, 'is_paused': False, 'is_in_stock': True, 'max_per_stream': {'is_enabled': False, 'max_per_stream': 1}, 'should_redemptions_skip_request_queue': False, 'template_id': 'template:41d5eae8-4deb-4541-b681-ebdcb3125c0f', 'updated_for_indicator_at': '2020-07-02T23:46:33.40915846Z', 'max_per_user_per_stream': {'is_enabled': False, 'max_per_user_per_stream': 0}, 'global_cooldown': {'is_enabled': False, 'global_cooldown_seconds': 0}, 'redemptions_redeemed_current_stream': None, 'cooldown_expires_at': None}, 'status': 'UNFULFILLED'}}} -INFO:root: - trying to handle reward: Hydrate -DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): standalone_lights:42069 -DEBUG:urllib3.connectionpool:http://standalone_lights:42069 "GET /api/v1/exec_lights?user_name=TheCuriousNerd&light_group=16&command=%21lights+hydration&rest= HTTP/1.1" 200 55 -INFO:werkzeug:192.168.96.2 - - [28/Apr/2021 07:01:19] "GET /api/v1/exec_reward?reward_source=ChannelRewardsSource.Twitch&user_name=TheCuriousNerd&reward_name=Hydrate&reward_type=ChannelRewardsType.channelPoints&reward_prompt=Make+me+take+a+sip+of+water&user_input=&bonus_data=%7B%27type%27%3A+%27reward-redeemed%27%2C+%27data%27%3A+%7B%27timestamp%27%3A+%272021-04-28T07%3A01%3A19.498040456Z%27%2C+%27redemption%27%3A+%7B%27id%27%3A+%27a7a4ba13-c702-46b6-a2c3-60851a746eaa%27%2C+%27user%27%3A+%7B%27id%27%3A+%2750897047%27%2C+%27login%27%3A+%27thecuriousnerd%27%2C+%27display_name%27%3A+%27TheCuriousNerd%27%7D%2C+%27channel_id%27%3A+%2750897047%27%2C+%27redeemed_at%27%3A+%272021-04-28T07%3A01%3A19.498040456Z%27%2C+%27reward%27%3A+%7B%27id%27%3A+%2792c89d8c-cf01-45f6-89f4-5f07ad576882%27%2C+%27channel_id%27%3A+%2750897047%27%2C+%27title%27%3A+%27Hydrate%27%2C+%27prompt%27%3A+%27Make+me+take+a+sip+of+water%27%2C+%27cost%27%3A+50%2C+%27is_user_input_required%27%3A+False%2C+%27is_sub_only%27%3A+False%2C+%27image%27%3A+None%2C+%27default_image%27%3A+%7B%27url_1x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-1.png%27%2C+%27url_2x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-2.png%27%2C+%27url_4x%27%3A+%27https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fcustom-reward-images%2Ftree-4.png%27%7D%2C+%27background_color%27%3A+%27%231C4592%27%2C+%27is_enabled%27%3A+True%2C+%27is_paused%27%3A+False%2C+%27is_in_stock%27%3A+True%2C+%27max_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_stream%27%3A+1%7D%2C+%27should_redemptions_skip_request_queue%27%3A+False%2C+%27template_id%27%3A+%27template%3A41d5eae8-4deb-4541-b681-ebdcb3125c0f%27%2C+%27updated_for_indicator_at%27%3A+%272020-07-02T23%3A46%3A33.40915846Z%27%2C+%27max_per_user_per_stream%27%3A+%7B%27is_enabled%27%3A+False%2C+%27max_per_user_per_stream%27%3A+0%7D%2C+%27global_cooldown%27%3A+%7B%27is_enabled%27%3A+False%2C+%27global_cooldown_seconds%27%3A+0%7D%2C+%27redemptions_redeemed_current_stream%27%3A+None%2C+%27cooldown_expires_at%27%3A+None%7D%2C+%27status%27%3A+%27UNFULFILLED%27%7D%7D%7D HTTP/1.1" 200 - -- 2.45.2 From 114d70f661c8a3ae5e24e602d5d0f827e3d76bcc Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 03:30:41 -0400 Subject: [PATCH 13/14] Update config.py --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 20beb45..89758ce 100644 --- a/config.py +++ b/config.py @@ -10,7 +10,7 @@ user_module: bool = True autoJoin_TwitchChannel = "thecuriousnerd" autoJoin_TwitchChannels = ["thecuriousnerd"] -whitelisted_TwitchPowerUsers = ["thecuriousnerd"] +allowedCommandList_TwitchPowerUsers = ["thecuriousnerd"] #Twitch Module Configs block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels -- 2.45.2 From 3fbc517e59bddf09d17549966fdc01c1be0c3ea0 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Wed, 28 Apr 2021 03:31:23 -0400 Subject: [PATCH 14/14] typo --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 89758ce..ac98bb8 100644 --- a/config.py +++ b/config.py @@ -10,7 +10,7 @@ user_module: bool = True autoJoin_TwitchChannel = "thecuriousnerd" autoJoin_TwitchChannels = ["thecuriousnerd"] -allowedCommandList_TwitchPowerUsers = ["thecuriousnerd"] +allowedCommandsList_TwitchPowerUsers = ["thecuriousnerd"] #Twitch Module Configs block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels -- 2.45.2