Discord Module & Minor Fixes

Started working on the discord script.

Adjusted the if __name__ == "__main__": lines on a few modules.
This commit is contained in:
Alex Orid 2020-10-01 04:33:59 -04:00
parent a95684053a
commit f0468e0630
5 changed files with 53 additions and 16 deletions

View File

@ -1,6 +1,4 @@
{
"username": "discord",
"helix": "secret discord",
"oauth": "token discord",
"v5_client": "I have no idea here"
"username": "AnythingYouWant",
"token": ""
}

View File

@ -24,13 +24,11 @@ class Twitch_Credential():
class Discord_Credential():
# Discord Credentials explanations here.
def __init__(self, username, helix, oauth, v5_client):
def __init__(self, nickname, token):
# super().__init__()
# all of this is completely made up, i just wanted to make sure your file name switch worked right
self.username = username
self.helix = helix
self.oauth = oauth
self.v5_client = v5_client
self.nickname = nickname
self.token = token
class DB_Credential():
# engine = "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
@ -149,8 +147,8 @@ class Credentials_Module():
foundSomething = False
tempCert: Discord_Credential
for cert in self.Discord_Credentials_List:
if cert.username == searchParam:
print("Discord Credential Found: {" + cert.username + "}")
if cert.nickname == searchParam:
print("Discord Credential Found: {" + cert.nickname + "}")
tempCert = cert
foundSomething = True
if foundSomething:

10
db.py
View File

@ -13,7 +13,7 @@ class db_module():
self.currentWorkingDB: str
self.engine = None
def setup_engine(self, credential: credentials.DB_Credential):
def setup_engine(self, credential: credentials.DB_Credential = None):
createEngine = True
if credential is None:
if self.dbCredential is None:
@ -69,5 +69,9 @@ class db_module():
if __name__ == "__main__":
db_connection = db_module()
db_connection.setup_engine()
testModule = db_module()
credentials_manager = credentials.Credentials_Module()
credentials_manager.load_credentials()
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
testModule.setup_engine()

32
discord_script.py Normal file
View File

@ -0,0 +1,32 @@
import random
import re
import config as config
import db
import tts
import credentials
import discord
class Discord_Module(discord.Client):
def __init__(self):
super().__init__()
self.dbCredential: credentials.DB_Credential
self.discordCredential: credentials.Discord_Credential
self.tts_enabled: bool = False
def main(self):
self.run(self.discordCredential.token)
if __name__ == "__main__":
testModule = Discord_Module()
credentials_manager = credentials.Credentials_Module()
credentials_manager.load_credentials()
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
testModule.discordCredential = credentials_manager.find_Discord_Credential("praxis_bot")
testModule.main()

View File

@ -197,5 +197,10 @@ def main_chat_commands_check(channel, sender, text):
if __name__ == "__main__":
testChat = Twitch_Module()
testChat.join_channel("thecuriousnerd")
testModule = Twitch_Module()
credentials_manager = credentials.Credentials_Module()
credentials_manager.load_credentials()
testModule.twitchCredential = credentials_manager.find_Twitch_Credential("praxis_bot")
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
testModule.join_channel(None ,"thecuriousnerd")