credential helper function + cleaning/typo fixes
This commit is contained in:
parent
bb002c7b0c
commit
bc6a8c8bf7
@ -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()
|
|
||||||
@ -77,7 +77,7 @@ class Cooldown_Module:
|
|||||||
targetCD.actionList.append(newAction)
|
targetCD.actionList.append(newAction)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
testCD = Cooldowns_Module()
|
testCD = Cooldown_Module()
|
||||||
cdName = "test"
|
cdName = "test"
|
||||||
testCD.setupCooldown(cdName, 20, 2)
|
testCD.setupCooldown(cdName, 20, 2)
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,9 @@ from twitchAPI.oauth import UserAuthenticator
|
|||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
import json
|
||||||
|
import utilities_script as utility
|
||||||
|
import os
|
||||||
|
|
||||||
class Twitch_Credential_Maker():
|
class Twitch_Credential_Maker():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -32,6 +35,21 @@ class Twitch_Credential_Maker():
|
|||||||
print("")
|
print("")
|
||||||
return token, refresh_token
|
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)
|
testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret)
|
||||||
#pprint(testModule.twitch.get_users(logins=['thecuriousnerd']))
|
#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")
|
print("Ready to close")
|
||||||
input()
|
input()
|
||||||
Loading…
Reference in New Issue
Block a user