diff --git a/Command_Management_Module.py b/Command_Management_Module.py deleted file mode 100644 index f8df757..0000000 --- a/Command_Management_Module.py +++ /dev/null @@ -1,46 +0,0 @@ -from main import user_module_init -import config as config -import db - -import user_module - -import commands.loader as command_loader -from commands.command_base import AbstractCommand - -import credentials - -class Command_Management_Module(): - def __init__(self): - super().__init__() - self.dbCredential: credentials.DB_Credential - - def main_test(self): - print("[TEST Module]> test") - - tempModule = user_module.User_Module() - #tempModule.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis) - print(self.getCommandsList(tempModule.commands)) - - def getCommandsList(self, targetModuleCommands): - print(type(targetModuleCommands)) - commandsList = "\n" - for cmd in targetModuleCommands: - targetCommand = targetModuleCommands[cmd] - print(targetCommand.command) - print(targetCommand.isCommandEnabled) - - - return commandsList - - - def getUserPermission(): - pass - - -if __name__ == "__main__": - testModule = Command_Management_Module() - - credentials_manager = credentials.Credentials_Module() - credentials_manager.load_credentials() - testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname) - testModule.main_test() \ No newline at end of file diff --git a/cooldowns.py b/cooldowns.py index 68b1431..e2fe563 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -77,7 +77,7 @@ class Cooldown_Module: targetCD.actionList.append(newAction) if __name__ == "__main__": - testCD = Cooldowns_Module() + testCD = Cooldown_Module() cdName = "test" testCD.setupCooldown(cdName, 20, 2) diff --git a/twitch_generate_credentials.py b/twitch_generate_credentials.py index 0173910..2c07362 100644 --- a/twitch_generate_credentials.py +++ b/twitch_generate_credentials.py @@ -10,6 +10,9 @@ from twitchAPI.oauth import UserAuthenticator from pprint import pprint from uuid import UUID +import json +import utilities_script as utility +import os class Twitch_Credential_Maker(): def __init__(self): @@ -32,6 +35,21 @@ class Twitch_Credential_Maker(): print("") return token, refresh_token + def updateCredentialsFile(self, token, refreshToken): + dir = utility.get_dir("credentials") + script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in + relative_path = "credentials/twitch.json" + real_file_path = os.path.join(script_dir, relative_path) + + with open(real_file_path, 'r') as cred_r: + data = json.load(cred_r) + data['pubsub_AccessToken'] = token + data['pubsub_RefreshToken'] = refreshToken + + os.remove(real_file_path) + with open(real_file_path, 'w') as cred_w: + json.dump(data, cred_w, indent=2) + @@ -44,6 +62,10 @@ if __name__ == "__main__": testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret) #pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) - testModule.get_tokens() + token, refreshToken = testModule.get_tokens() + print("Update credentials file? (y/n)") + response = input() + if "y" in response.lower(): + testModule.updateCredentialsFile(token, refreshToken) print("Ready to close") input() \ No newline at end of file