Merge pull request 'startup and config changes' (#12) from startup-changes into master
Reviewed-on: #12
This commit is contained in:
commit
1abfc12fa0
@ -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.
|
Refer to the `/credential_templates/` folder for examples.
|
||||||
|
|
||||||
### For Twitch Credentials
|
### For Twitch Credentials
|
||||||
Username = `TwitchUsername`
|
Username = `TwitchUsername` *(Must match ***credentialsNickname*** in config)*
|
||||||
|
|
||||||
Helix Client ID = `https://dev.twitch.tv/console/apps`
|
Helix Client ID = `https://dev.twitch.tv/console/apps`
|
||||||
|
|
||||||
@ -19,12 +19,12 @@ Oauth = `https://twitchapps.com/tmi/`
|
|||||||
V5 Client ID = `https://twitchtokengenerator.com/`
|
V5 Client ID = `https://twitchtokengenerator.com/`
|
||||||
|
|
||||||
### For Database Credentials
|
### For Database Credentials
|
||||||
Nickname = `Anything You Want`
|
Nickname = `Anything You Want` *(Must match ***credentialsNickname*** in config)*
|
||||||
|
|
||||||
Engine = `"mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"`
|
Engine = `"mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"`
|
||||||
|
|
||||||
### For Discord Credentials
|
### For Discord Credentials
|
||||||
Nickname = `Anything You Want`
|
Nickname = `Anything You Want` *(Must match ***credentialsNickname*** in config)*
|
||||||
|
|
||||||
Token = `https://discord.com/developers/`
|
Token = `https://discord.com/developers/`
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
credentialsNickname = "praxis_bot"
|
||||||
|
|
||||||
|
twitch_module: bool = True
|
||||||
|
discord_module: bool = True
|
||||||
|
|
||||||
|
autojoinTwitchChannels = ("thecuriousnerd")
|
||||||
|
|
||||||
|
selected_discordTTSChannels = ("431129571308339210")
|
||||||
|
|
||||||
|
|
||||||
class Speaker(Enum):
|
class Speaker(Enum):
|
||||||
GOOGLE_TEXT_TO_SPEECH = 1
|
GOOGLE_TEXT_TO_SPEECH = 1
|
||||||
|
|||||||
30
main.py
30
main.py
@ -8,6 +8,7 @@ import twitch_script
|
|||||||
import discord_script
|
import discord_script
|
||||||
|
|
||||||
import utilities_script as utility
|
import utilities_script as utility
|
||||||
|
import config as config
|
||||||
|
|
||||||
import credentials
|
import credentials
|
||||||
|
|
||||||
@ -25,14 +26,16 @@ def twitch_module_init(dbCert, twitchCert):
|
|||||||
twitch_chat.db_manager.setup_engine(dbCert)
|
twitch_chat.db_manager.setup_engine(dbCert)
|
||||||
twitch_chat.twitchCredential = twitchCert
|
twitch_chat.twitchCredential = twitchCert
|
||||||
|
|
||||||
twitch_chat.join_channel(None, "thecuriousnerd")
|
for twitchChannel in config.autojoinTwitchChannels.split():
|
||||||
|
twitch_chat.join_channel(None, twitchChannel)
|
||||||
|
|
||||||
|
|
||||||
def discord_module_init(dbCert, discordCert):
|
def discord_module_init(dbCert, discordCert):
|
||||||
discord_connection.dbCredential = dbCert
|
discord_connection.dbCredential = dbCert
|
||||||
discord_connection.discordCredential = discordCert
|
discord_connection.discordCredential = discordCert
|
||||||
|
|
||||||
discord_connection.selected_ttsChannels.append(431129571308339210)
|
for ttsChannel in config.selected_discordTTSChannels.split():
|
||||||
|
discord_connection.selected_ttsChannels.append(int(ttsChannel))
|
||||||
|
|
||||||
discord_connection.main()
|
discord_connection.main()
|
||||||
|
|
||||||
@ -48,26 +51,27 @@ def thread_main():
|
|||||||
credentials_manager = credentials.Credentials_Module()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
|
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, "praxis_bot")
|
dbCert: credentials.DB_Credential = credentials_manager.find_Credential(credentials.DB_Credential, config.credentialsNickname)
|
||||||
twitchCert: credentials.Twitch_Credential = credentials_manager.find_Twitch_Credential("praxis_bot")
|
|
||||||
discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential("praxis_bot")
|
|
||||||
|
|
||||||
threads = []
|
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))
|
if config.discord_module == True:
|
||||||
threads.append(twitch)
|
discordCert: credentials.Discord_Credential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
||||||
twitch.start()
|
discord = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
||||||
|
threads.append(discord)
|
||||||
discord = threading.Thread(target=discord_module_init, args=(dbCert, discordCert))
|
discord.start()
|
||||||
threads.append(discord)
|
|
||||||
discord.start()
|
|
||||||
|
|
||||||
print("---Post Thread Creation Test---")
|
print("---Post Thread Creation Test---")
|
||||||
for t in threads:
|
for t in threads:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
print("---Point of no return---")
|
print("---Point of no return---")
|
||||||
|
input()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ class Twitch_Module():
|
|||||||
try:
|
try:
|
||||||
#first_space_idx = message.text.index(' ')
|
#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.
|
# it cant find the substring.
|
||||||
if message.text.find(" ") != -1:
|
if message.text.find(" ") != -1:
|
||||||
first_space_idx = message.text.index(' ')
|
first_space_idx = message.text.index(' ')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user