Compare commits
2 Commits
ff4c21a747
...
ccaee336dd
| Author | SHA1 | Date | |
|---|---|---|---|
| ccaee336dd | |||
|
|
ada9d2ecb8 |
@ -1,4 +1,5 @@
|
||||
{
|
||||
"nickname": "AnythingYouWant",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"ipAddress": "",
|
||||
|
||||
@ -34,8 +34,9 @@ class Discord_Credential():
|
||||
|
||||
class DB_Credential():
|
||||
# engine = "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
|
||||
def __init__(self, username, password, ipAddress, port, databaseName, engine_url):
|
||||
def __init__(self, nickname, username, password, ipAddress, port, databaseName, engine_url):
|
||||
#super().__init__()
|
||||
self.nickname = nickname
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.ipAddress = ipAddress
|
||||
@ -46,6 +47,7 @@ class DB_Credential():
|
||||
def create_engine_url(self):
|
||||
new_engine_url = "mysql+mysqlconnector://" + self.username + ":" + self.password + "@" + self.ipAddress + ":" + self.port + "/" + self.databaseName
|
||||
self.engine_url = new_engine_url
|
||||
return new_engine_url
|
||||
|
||||
|
||||
class Credentials_Module():
|
||||
@ -106,6 +108,9 @@ class Credentials_Module():
|
||||
tobj = DB_Credential(**raw_json)
|
||||
return tobj
|
||||
|
||||
def find_Credential(self):
|
||||
pass
|
||||
|
||||
credentialLoadingFunctions = { # this is a mapping of the Credential enum to function pointers
|
||||
Credential.Twitch_Credential: load_Twitch_Credential,
|
||||
Credential.Discord_Credential: load_Discord_Credential,
|
||||
|
||||
20
db.py
20
db.py
@ -1,4 +1,6 @@
|
||||
import db_cred as db_credentials
|
||||
import credentials
|
||||
|
||||
import config as config
|
||||
|
||||
import pandas as pd
|
||||
from sqlalchemy import create_engine
|
||||
@ -7,12 +9,22 @@ from sqlalchemy import create_engine
|
||||
class db_module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.dbCredential: credentials.DB_Credential
|
||||
self.currentWorkingDB: str
|
||||
self.engine = None
|
||||
|
||||
def setup_engine(self):
|
||||
self.engine = create_engine(db_credentials.engine_url)
|
||||
print("Engine Created")
|
||||
def setup_engine(self, credential: credentials.DB_Credential):
|
||||
createEngine = True
|
||||
if credential is None:
|
||||
if self.dbCredential is None:
|
||||
createEngine = False
|
||||
else:
|
||||
credential = self.dbCredential
|
||||
|
||||
if createEngine:
|
||||
self.engine = create_engine(credential.engine_url)
|
||||
self.currentWorkingDB = credential.databaseName
|
||||
print("Engine Created")
|
||||
|
||||
def create_table(self, tableName: str = ""):
|
||||
pass
|
||||
|
||||
15
main.py
15
main.py
@ -22,18 +22,27 @@ def main():
|
||||
|
||||
twitch_chat = twitch_script.Twitch_Module()
|
||||
|
||||
dbCert: credentials.DB_Credential
|
||||
if credentials_manager.DB_Credentials_List is not None:
|
||||
for cert in credentials_manager.DB_Credentials_List:
|
||||
if cert.nickname == "praxis_bot":
|
||||
print("DB Certificate Found: {" + cert.nickname + "}")
|
||||
dbCert = cert
|
||||
|
||||
twitchCert: credentials.Twitch_Credential
|
||||
if credentials_manager.Twitch_Credentials_List is not None:
|
||||
for cert in credentials_manager.Twitch_Credentials_List:
|
||||
if cert.username == "praxis_bot":
|
||||
print("Twitch Certificate Found: {" + cert.username + "}")
|
||||
mainCert = cert
|
||||
twitchCert = cert
|
||||
|
||||
twitch_chat.db_manager.setup_engine(dbCert)
|
||||
print("Loading Credential: {" + cert.username + "} into Twitch_Module")
|
||||
twitch_chat.twitchCredential = mainCert
|
||||
twitch_chat.twitchCredential = twitchCert
|
||||
print("Connecting to Channel: " + "thecuriousnerd")
|
||||
twitch_chat.join_channel(None, "thecuriousnerd")
|
||||
|
||||
#twitch_chat.send_message("activated")
|
||||
# twitch_chat.send_message("activated")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -5,7 +5,7 @@ import twitch
|
||||
import twitch.chat
|
||||
|
||||
import config as config
|
||||
#import db
|
||||
import db
|
||||
import tts
|
||||
|
||||
import credentials
|
||||
@ -14,7 +14,11 @@ class Twitch_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.twitchCredential: credentials.Twitch_Credential
|
||||
self.dbCredential: credentials.DB_Credential
|
||||
|
||||
self.db_manager: db.db_module = db.db_module()
|
||||
self.chat: twitch.Chat
|
||||
|
||||
self.tts_enabled: bool = False
|
||||
self.tts_whitelist_enabled: bool = False
|
||||
self.links_allowed: bool = True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user