Compare commits

..

No commits in common. "ccaee336dd73f242b0e8d9d5a0a7730b1db38fe3" and "ff4c21a74715177615c0ff078868804bd8767f8b" have entirely different histories.

5 changed files with 9 additions and 40 deletions

View File

@ -1,5 +1,4 @@
{
"nickname": "AnythingYouWant",
"username": "",
"password": "",
"ipAddress": "",

View File

@ -34,9 +34,8 @@ class Discord_Credential():
class DB_Credential():
# engine = "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
def __init__(self, nickname, username, password, ipAddress, port, databaseName, engine_url):
def __init__(self, username, password, ipAddress, port, databaseName, engine_url):
#super().__init__()
self.nickname = nickname
self.username = username
self.password = password
self.ipAddress = ipAddress
@ -47,7 +46,6 @@ 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():
@ -108,9 +106,6 @@ 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,

18
db.py
View File

@ -1,6 +1,4 @@
import credentials
import config as config
import db_cred as db_credentials
import pandas as pd
from sqlalchemy import create_engine
@ -9,21 +7,11 @@ 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, 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
def setup_engine(self):
self.engine = create_engine(db_credentials.engine_url)
print("Engine Created")
def create_table(self, tableName: str = ""):

15
main.py
View File

@ -22,27 +22,18 @@ 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 + "}")
twitchCert = cert
mainCert = cert
twitch_chat.db_manager.setup_engine(dbCert)
print("Loading Credential: {" + cert.username + "} into Twitch_Module")
twitch_chat.twitchCredential = twitchCert
twitch_chat.twitchCredential = mainCert
print("Connecting to Channel: " + "thecuriousnerd")
twitch_chat.join_channel(None, "thecuriousnerd")
# twitch_chat.send_message("activated")
#twitch_chat.send_message("activated")
if __name__ == "__main__":

View File

@ -5,7 +5,7 @@ import twitch
import twitch.chat
import config as config
import db
#import db
import tts
import credentials
@ -14,11 +14,7 @@ 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