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"
|
credentialsNickname = "praxis_bot"
|
||||||
|
|
||||||
twitch_module: bool = True
|
twitch_module: bool = False
|
||||||
discord_module: bool = True
|
discord_module: bool = False
|
||||||
|
|
||||||
autojoinTwitchChannels = ("thecuriousnerd")
|
test_module: bool = True
|
||||||
|
|
||||||
selected_discordTTSChannels = ("431129571308339210")
|
autojoinTwitchChannels = ["thecuriousnerd"]
|
||||||
|
|
||||||
|
selected_discordTTSChannels = ["431129571308339210"]
|
||||||
|
|
||||||
|
|
||||||
class Speaker(Enum):
|
class Speaker(Enum):
|
||||||
|
|||||||
3
db.py
3
db.py
@ -73,5 +73,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
credentials_manager = credentials.Credentials_Module()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
|
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||||
|
|
||||||
testModule.setup_engine()
|
testModule.setup_engine()
|
||||||
@ -170,9 +170,10 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
credentials_manager = credentials.Credentials_Module()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
|
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||||
testModule.discordCredential = credentials_manager.find_Discord_Credential("praxis_bot")
|
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()
|
testModule.main()
|
||||||
|
|
||||||
|
|||||||
61
main.py
61
main.py
@ -7,6 +7,8 @@ import time
|
|||||||
import twitch_script
|
import twitch_script
|
||||||
import discord_script
|
import discord_script
|
||||||
|
|
||||||
|
import test_module
|
||||||
|
|
||||||
import utilities_script as utility
|
import utilities_script as utility
|
||||||
import config as config
|
import config as config
|
||||||
|
|
||||||
@ -14,57 +16,72 @@ import credentials
|
|||||||
|
|
||||||
import threading
|
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
|
credentials_manager: credentials.Credentials_Module
|
||||||
discord_connection: discord_script.Discord_Module
|
|
||||||
|
|
||||||
def main(inputArg):
|
def main(inputArg):
|
||||||
args = utility.get_args(inputArg)
|
args = utility.get_args(inputArg)
|
||||||
|
|
||||||
|
|
||||||
def twitch_module_init(dbCert, twitchCert):
|
def twitch_module_init(dbCert, twitchCert):
|
||||||
twitch_chat.db_manager.setup_engine(dbCert)
|
print("-init [TWITCH Module]")
|
||||||
twitch_chat.twitchCredential = twitchCert
|
twitchModule_.db_manager.setup_engine(dbCert)
|
||||||
|
twitchModule_.twitchCredential = twitchCert
|
||||||
for twitchChannel in config.autojoinTwitchChannels.split():
|
|
||||||
twitch_chat.join_channel(None, twitchChannel)
|
|
||||||
|
|
||||||
|
for twitchChannel in config.autojoinTwitchChannels:
|
||||||
|
twitchModule_.join_channel(None, twitchChannel)
|
||||||
|
|
||||||
def discord_module_init(dbCert, discordCert):
|
def discord_module_init(dbCert, discordCert):
|
||||||
discord_connection.dbCredential = dbCert
|
print("-init [DISCORD Module]")
|
||||||
discord_connection.discordCredential = discordCert
|
discordModule_.dbCredential = dbCert
|
||||||
|
discordModule_.discordCredential = discordCert
|
||||||
|
|
||||||
for ttsChannel in config.selected_discordTTSChannels.split():
|
for ttsChannel in config.selected_discordTTSChannels:
|
||||||
discord_connection.selected_ttsChannels.append(int(ttsChannel))
|
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():
|
def thread_main():
|
||||||
global twitch_chat
|
|
||||||
global discord_connection
|
|
||||||
global credentials_manager
|
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()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
|
|
||||||
|
twitchModule_ = twitch_script.Twitch_Module()
|
||||||
|
discordModule_ = discord_script.Discord_Module()
|
||||||
|
testModule_ = test_module.Test_Module()
|
||||||
|
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, config.credentialsNickname)
|
dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, config.credentialsNickname)
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
if config.twitch_module == True:
|
if config.twitch_module == True:
|
||||||
twitchCert: credentials.Twitch_Credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
twitchCert: credentials.Twitch_Credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||||
twitch = threading.Thread(target=twitch_module_init, args=(dbCert, twitchCert))
|
thread_ = threading.Thread(target=twitch_module_init, args=(dbCert, twitchCert))
|
||||||
threads.append(twitch)
|
threads.append(thread_)
|
||||||
twitch.start()
|
thread_.start()
|
||||||
|
|
||||||
if config.discord_module == True:
|
if config.discord_module == True:
|
||||||
discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
||||||
discord = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
thread_ = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
||||||
threads.append(discord)
|
threads.append(thread_)
|
||||||
discord.start()
|
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---")
|
print("---Post Thread Creation Test---")
|
||||||
for t in threads:
|
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__()
|
super().__init__()
|
||||||
self.twitchCredential: credentials.Twitch_Credential
|
self.twitchCredential: credentials.Twitch_Credential
|
||||||
self.dbCredential: credentials.DB_Credential
|
self.dbCredential: credentials.DB_Credential
|
||||||
|
|
||||||
self.db_manager: db.db_module = db.db_module()
|
self.db_manager: db.db_module = db.db_module()
|
||||||
|
|
||||||
self.chat: twitch.Chat
|
self.chat: twitch.Chat
|
||||||
self.commands = command_loader.load_commands_new(AbstractCommand.CommandType.TWITCH)
|
self.commands = command_loader.load_commands_new(AbstractCommand.CommandType.TWITCH)
|
||||||
self.tts_enabled: bool = False
|
self.tts_enabled: bool = False
|
||||||
@ -168,6 +168,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
credentials_manager = credentials.Credentials_Module()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
testModule.twitchCredential = credentials_manager.find_Twitch_Credential("praxis_bot")
|
testModule.twitchCredential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||||
testModule.dbCredential = credentials_manager.find_DB_Credential("praxis_bot")
|
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||||
testModule.join_channel(None ,"thecuriousnerd")
|
|
||||||
|
for twitchChannel in config.autojoinTwitchChannels:
|
||||||
|
testModule.join_channel(None, twitchChannel)
|
||||||
Loading…
Reference in New Issue
Block a user