Added Test Module & Updated Name == Main
Added a test module to make it faster to include new additions. I also updated the name == main section in each module to use the values in config instead of itself.
This commit is contained in:
parent
1abfc12fa0
commit
4ef983c7cc
10
config.py
10
config.py
@ -2,12 +2,14 @@ from enum import Enum
|
||||
|
||||
credentialsNickname = "praxis_bot"
|
||||
|
||||
twitch_module: bool = True
|
||||
discord_module: bool = True
|
||||
twitch_module: bool = False
|
||||
discord_module: bool = False
|
||||
|
||||
autojoinTwitchChannels = ("thecuriousnerd")
|
||||
test_module: bool = True
|
||||
|
||||
selected_discordTTSChannels = ("431129571308339210")
|
||||
autojoinTwitchChannels = ["thecuriousnerd"]
|
||||
|
||||
selected_discordTTSChannels = ["431129571308339210"]
|
||||
|
||||
|
||||
class Speaker(Enum):
|
||||
|
||||
5
db.py
5
db.py
@ -73,5 +73,6 @@ if __name__ == "__main__":
|
||||
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
credentials_manager.load_credentials()
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
|
||||
testModule.setup_engine()
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
|
||||
testModule.setup_engine()
|
||||
@ -170,9 +170,10 @@ if __name__ == "__main__":
|
||||
|
||||
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()
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
testModule.discordCredential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
||||
|
||||
testModule.main()
|
||||
for ttsChannel in config.selected_discordTTSChannels:
|
||||
testModule.selected_ttsChannels.append(int(ttsChannel))
|
||||
|
||||
testModule.main()
|
||||
61
main.py
61
main.py
@ -7,6 +7,8 @@ import time
|
||||
import twitch_script
|
||||
import discord_script
|
||||
|
||||
import test_module
|
||||
|
||||
import utilities_script as utility
|
||||
import config as config
|
||||
|
||||
@ -14,57 +16,72 @@ import credentials
|
||||
|
||||
import threading
|
||||
|
||||
twitch_chat: twitch_script.Twitch_Module
|
||||
twitchModule_: twitch_script.Twitch_Module
|
||||
discordModule_: discord_script.Discord_Module
|
||||
testModule_: test_module.Test_Module
|
||||
|
||||
credentials_manager: credentials.Credentials_Module
|
||||
discord_connection: discord_script.Discord_Module
|
||||
|
||||
def main(inputArg):
|
||||
args = utility.get_args(inputArg)
|
||||
|
||||
|
||||
def twitch_module_init(dbCert, twitchCert):
|
||||
twitch_chat.db_manager.setup_engine(dbCert)
|
||||
twitch_chat.twitchCredential = twitchCert
|
||||
|
||||
for twitchChannel in config.autojoinTwitchChannels.split():
|
||||
twitch_chat.join_channel(None, twitchChannel)
|
||||
print("-init [TWITCH Module]")
|
||||
twitchModule_.db_manager.setup_engine(dbCert)
|
||||
twitchModule_.twitchCredential = twitchCert
|
||||
|
||||
for twitchChannel in config.autojoinTwitchChannels:
|
||||
twitchModule_.join_channel(None, twitchChannel)
|
||||
|
||||
def discord_module_init(dbCert, discordCert):
|
||||
discord_connection.dbCredential = dbCert
|
||||
discord_connection.discordCredential = discordCert
|
||||
print("-init [DISCORD Module]")
|
||||
discordModule_.dbCredential = dbCert
|
||||
discordModule_.discordCredential = discordCert
|
||||
|
||||
for ttsChannel in config.selected_discordTTSChannels.split():
|
||||
discord_connection.selected_ttsChannels.append(int(ttsChannel))
|
||||
for ttsChannel in config.selected_discordTTSChannels:
|
||||
discordModule_.selected_ttsChannels.append(int(ttsChannel))
|
||||
|
||||
discord_connection.main()
|
||||
discordModule_.main()
|
||||
|
||||
def test_module_init(dbCert, Empty):
|
||||
print("-init [TEST Module]")
|
||||
#testModule_.dbCredential = dbCert
|
||||
testModule_.main()
|
||||
|
||||
|
||||
def thread_main():
|
||||
global twitch_chat
|
||||
global discord_connection
|
||||
global credentials_manager
|
||||
global twitchModule_
|
||||
global discordModule_
|
||||
global testModule_
|
||||
|
||||
twitch_chat = twitch_script.Twitch_Module()
|
||||
discord_connection = discord_script.Discord_Module()
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
|
||||
twitchModule_ = twitch_script.Twitch_Module()
|
||||
discordModule_ = discord_script.Discord_Module()
|
||||
testModule_ = test_module.Test_Module()
|
||||
|
||||
credentials_manager.load_credentials()
|
||||
dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, config.credentialsNickname)
|
||||
|
||||
threads = []
|
||||
if config.twitch_module == True:
|
||||
twitchCert: credentials.Twitch_Credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||
twitch = threading.Thread(target=twitch_module_init, args=(dbCert, twitchCert))
|
||||
threads.append(twitch)
|
||||
twitch.start()
|
||||
thread_ = threading.Thread(target=twitch_module_init, args=(dbCert, twitchCert))
|
||||
threads.append(thread_)
|
||||
thread_.start()
|
||||
|
||||
if config.discord_module == True:
|
||||
discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
||||
discord = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
||||
threads.append(discord)
|
||||
discord.start()
|
||||
thread_ = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
||||
threads.append(thread_)
|
||||
thread_.start()
|
||||
|
||||
if config.test_module == True:
|
||||
thread_ = threading.Thread(target=test_module_init, args=(dbCert, None))
|
||||
threads.append(thread_)
|
||||
thread_.start()
|
||||
|
||||
print("---Post Thread Creation Test---")
|
||||
for t in threads:
|
||||
|
||||
21
test_module.py
Normal file
21
test_module.py
Normal file
@ -0,0 +1,21 @@
|
||||
import config as config
|
||||
import db
|
||||
|
||||
import credentials
|
||||
|
||||
class Test_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.dbCredential: credentials.DB_Credential
|
||||
|
||||
def main(self):
|
||||
print("[TEST Module]> test")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testModule = Test_Module()
|
||||
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
credentials_manager.load_credentials()
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
testModule.main()
|
||||
@ -21,8 +21,8 @@ class Twitch_Module():
|
||||
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.commands = command_loader.load_commands_new(AbstractCommand.CommandType.TWITCH)
|
||||
self.tts_enabled: bool = False
|
||||
@ -168,6 +168,8 @@ if __name__ == "__main__":
|
||||
|
||||
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")
|
||||
testModule.twitchCredential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
|
||||
for twitchChannel in config.autojoinTwitchChannels:
|
||||
testModule.join_channel(None, twitchChannel)
|
||||
Loading…
Reference in New Issue
Block a user