From 4be0adf7378e6d3821e0847ad51f241b70c604ec Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 18 Jan 2021 09:44:39 -0500 Subject: [PATCH 1/5] Moved things to Config --- config.py | 9 +++++++++ main.py | 29 +++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/config.py b/config.py index 4316725..ec02abd 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,14 @@ from enum import Enum +credentialsNickname = "praxis_bot" + +twitch_module: bool = True +discord_module: bool = True + +autojoinTwitchChannels = ("thecuriousnerd") + +selected_discordTTSChannels = (431129571308339210) + class Speaker(Enum): GOOGLE_TEXT_TO_SPEECH = 1 diff --git a/main.py b/main.py index c0ea930..31d6cbe 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ import twitch_script import discord_script import utilities_script as utility +import config as config import credentials @@ -25,14 +26,17 @@ def twitch_module_init(dbCert, twitchCert): twitch_chat.db_manager.setup_engine(dbCert) twitch_chat.twitchCredential = twitchCert - twitch_chat.join_channel(None, "thecuriousnerd") + for twitchChannel in config.autojoinTwitchChannels: + twitch_chat.join_channel(None, twitchChannel) def discord_module_init(dbCert, discordCert): discord_connection.dbCredential = dbCert discord_connection.discordCredential = discordCert - discord_connection.selected_ttsChannels.append(431129571308339210) + for ttsChannel in config.selected_discordTTSChannels: + discord_connection.selected_ttsChannels.append(ttsChannel) + discord_connection.main() @@ -48,19 +52,20 @@ def thread_main(): credentials_manager = credentials.Credentials_Module() credentials_manager.load_credentials() - dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, "praxis_bot") - twitchCert: credentials.Twitch_Credential = credentials_manager.find_Twitch_Credential("praxis_bot") - discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential("praxis_bot") + 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() - twitch = threading.Thread(target=twitch_module_init, args=(dbCert, twitchCert)) - threads.append(twitch) - twitch.start() - - discord = threading.Thread(target=discord_module_init, args=(dbCert, discordCert)) - threads.append(discord) - discord.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() print("---Post Thread Creation Test---") for t in threads: From f7d3203c2844d58671d44cb375de5898532f920d Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 18 Jan 2021 10:01:28 -0500 Subject: [PATCH 2/5] Fixed Startup --- config.py | 2 +- main.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index ec02abd..9b4b9ba 100644 --- a/config.py +++ b/config.py @@ -7,7 +7,7 @@ discord_module: bool = True autojoinTwitchChannels = ("thecuriousnerd") -selected_discordTTSChannels = (431129571308339210) +selected_discordTTSChannels = ("431129571308339210") class Speaker(Enum): diff --git a/main.py b/main.py index 31d6cbe..e9ac91a 100644 --- a/main.py +++ b/main.py @@ -26,17 +26,16 @@ def twitch_module_init(dbCert, twitchCert): twitch_chat.db_manager.setup_engine(dbCert) twitch_chat.twitchCredential = twitchCert - for twitchChannel in config.autojoinTwitchChannels: - twitch_chat.join_channel(None, twitchChannel) + for twitchChannel in config.autojoinTwitchChannels.split(): + twitch_chat.join_channel(None, "thecuriousnerd") def discord_module_init(dbCert, discordCert): discord_connection.dbCredential = dbCert discord_connection.discordCredential = discordCert - for ttsChannel in config.selected_discordTTSChannels: - discord_connection.selected_ttsChannels.append(ttsChannel) - + for ttsChannel in config.selected_discordTTSChannels.split(): + discord_connection.selected_ttsChannels.append(int(ttsChannel)) discord_connection.main() @@ -72,7 +71,7 @@ def thread_main(): t.join() print("---Point of no return---") - + input() From 538f46718c088bb6ca15092b2d8d5fd9c8947952 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 18 Jan 2021 10:01:57 -0500 Subject: [PATCH 3/5] fixed typo --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index e9ac91a..56a59bb 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ def twitch_module_init(dbCert, twitchCert): twitch_chat.twitchCredential = twitchCert for twitchChannel in config.autojoinTwitchChannels.split(): - twitch_chat.join_channel(None, "thecuriousnerd") + twitch_chat.join_channel(None, twitchChannel) def discord_module_init(dbCert, discordCert): From 3ef6df23f1426f085252fe214c06749eeb02488a Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Mon, 18 Jan 2021 10:03:26 -0500 Subject: [PATCH 4/5] deleted space --- twitch_script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twitch_script.py b/twitch_script.py index ee39c98..3f75df5 100644 --- a/twitch_script.py +++ b/twitch_script.py @@ -86,7 +86,7 @@ class Twitch_Module(): try: #first_space_idx = message.text.index(' ') - # This fixes a error where if you send a command without arguments it fails because + # This fixes a error where if you send a command without arguments it fails because # it cant find the substring. if message.text.find(" ") != -1: first_space_idx = message.text.index(' ') From e81e4d1b22f1236f6bb11c415288b8986517e401 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Tue, 19 Jan 2021 23:47:34 -0500 Subject: [PATCH 5/5] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ebc005f..17afa01 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Create a json based on the templates and put them into the `/credentials/` folde Refer to the `/credential_templates/` folder for examples. ### For Twitch Credentials -Username = `TwitchUsername` +Username = `TwitchUsername` *(Must match ***credentialsNickname*** in config)* Helix Client ID = `https://dev.twitch.tv/console/apps` @@ -19,12 +19,12 @@ Oauth = `https://twitchapps.com/tmi/` V5 Client ID = `https://twitchtokengenerator.com/` ### For Database Credentials -Nickname = `Anything You Want` +Nickname = `Anything You Want` *(Must match ***credentialsNickname*** in config)* Engine = `"mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"` ### For Discord Credentials -Nickname = `Anything You Want` +Nickname = `Anything You Want` *(Must match ***credentialsNickname*** in config)* Token = `https://discord.com/developers/`