From 7d0520b0b0de37e5d1d7d902bdbfe6ff350fbf52 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 22 Sep 2020 18:20:56 -0400 Subject: [PATCH] Added the DB Credential Template --- README.md | 12 ++++++++---- credential_templates/credential_template_db.json | 3 +++ credential_templates/credential_template_twitch.json | 4 ++-- credentials.py | 6 +++++- 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 credential_templates/credential_template_db.json diff --git a/README.md b/README.md index cd51c6b..e45dfc0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ A chatbot to help with live stream production/effects. +___ + # Credentials Setup: -## For Twitch Credentials in twitch_cred.py +Create a json based on the templates and put them into the credentials folder. + +## For Twitch Credentials Username = `TwitchUsername` -Helix ID = `https://dev.twitch.tv/console/apps` +Helix Client ID = `https://dev.twitch.tv/console/apps` Oauth = `https://twitchapps.com/tmi/` V5 Client ID = `https://twitchtokengenerator.com/` -## For Database Credentials in db_cred.py -engine = `"mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"` +## For Database Credentials +Engine = `"mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"` diff --git a/credential_templates/credential_template_db.json b/credential_templates/credential_template_db.json new file mode 100644 index 0000000..f94408c --- /dev/null +++ b/credential_templates/credential_template_db.json @@ -0,0 +1,3 @@ +{ + "engine": "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName" +} \ No newline at end of file diff --git a/credential_templates/credential_template_twitch.json b/credential_templates/credential_template_twitch.json index 5f5b4a1..c889bf2 100644 --- a/credential_templates/credential_template_twitch.json +++ b/credential_templates/credential_template_twitch.json @@ -1,6 +1,6 @@ { "username": "something", - "helix": "secret", + "helix": "Helix Client ID", "oauth": "token", - "v5_client": "I have no idea here" + "v5_client": "Client ID" } \ No newline at end of file diff --git a/credentials.py b/credentials.py index 612994a..566a6a7 100644 --- a/credentials.py +++ b/credentials.py @@ -97,7 +97,11 @@ class Credentials_Module(): return tobj def load_DB_Credential(self, fileName: str): - return None + file_path = os.path.join(self.get_credentials_dir(), fileName) + f = open(file_path) + raw_json = json.loads(f.read()) + tobj = DB_Credential(**raw_json) + return tobj credentialLoadingFunctions = { # this is a mapping of the Credential enum to function pointers Credential.Twitch_Credential: load_Twitch_Credential,