Compare commits
4 Commits
d773d8b8da
...
99b303958a
| Author | SHA1 | Date | |
|---|---|---|---|
| 99b303958a | |||
|
|
dd4b42803b | ||
|
|
928ec6e935 | ||
|
|
85909ecad9 |
@ -1,3 +1,8 @@
|
||||
{
|
||||
"username": "",
|
||||
"password": "",
|
||||
"ipAddress": "",
|
||||
"port": "",
|
||||
"databaseName": "",
|
||||
"engine": "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
|
||||
}
|
||||
@ -34,14 +34,14 @@ class Discord_Credential():
|
||||
|
||||
class DB_Credential():
|
||||
# engine = "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.username = ""
|
||||
self.password = ""
|
||||
self.ipAddress = ""
|
||||
self.port = ""
|
||||
self.databaseName = ""
|
||||
self.engine_url = ""
|
||||
def __init__(self, username, password, ipAddress, port, databaseName, engine_url):
|
||||
#super().__init__()
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.ipAddress = ipAddress
|
||||
self.port = port
|
||||
self.databaseName = databaseName
|
||||
self.engine_url = engine_url
|
||||
|
||||
def create_engine_url(self):
|
||||
new_engine_url = "mysql+mysqlconnector://" + self.username + ":" + self.password + "@" + self.ipAddress + ":" + self.port + "/" + self.databaseName
|
||||
@ -51,9 +51,9 @@ class DB_Credential():
|
||||
class Credentials_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.Twitch_Credentials_List: list
|
||||
self.Discord_Credentials_List: list
|
||||
self.DB_Credentials_List: list
|
||||
self.Twitch_Credentials_List: list = []
|
||||
self.Discord_Credentials_List: list = []
|
||||
self.DB_Credentials_List: list = []
|
||||
|
||||
def load_credentials(self):
|
||||
fileList = self.list_credential_files()
|
||||
@ -61,17 +61,14 @@ class Credentials_Module():
|
||||
if file.lower().find("twitch") != -1:
|
||||
credential_loading_function = self.credentialLoadingFunctions.get(Credential.Twitch_Credential)
|
||||
output = credential_loading_function(self, file)
|
||||
if output is not None:
|
||||
self.Twitch_Credentials_List.append(output)
|
||||
if file.lower().find("discord") != -1:
|
||||
credential_loading_function = self.credentialLoadingFunctions.get(Credential.Discord_Credential)
|
||||
output = credential_loading_function(self, file)
|
||||
if output is not None:
|
||||
self.Discord_Credentials_List.append(output)
|
||||
if file.lower().find("db") != -1:
|
||||
credential_loading_function = self.credentialLoadingFunctions.get(Credential.DB_Credential)
|
||||
output = credential_loading_function(self, file)
|
||||
if output is not None:
|
||||
self.DB_Credentials_List.append(output)
|
||||
|
||||
def list_credential_files(self):
|
||||
|
||||
@ -1 +0,0 @@
|
||||
engine_url = "mysql+mysqlconnector://"
|
||||
29
main.py
29
main.py
@ -4,21 +4,36 @@
|
||||
import sys
|
||||
import time
|
||||
|
||||
import twitch_script_class
|
||||
import twitch_script
|
||||
|
||||
import utilities_script as utility
|
||||
|
||||
twitch_chat: twitch_script_class.Twitch_Module
|
||||
import credentials
|
||||
|
||||
twitch_chat: twitch_script.Twitch_Module
|
||||
credentials_manager: credentials.Credentials_Module
|
||||
|
||||
def main():
|
||||
print("Connecting to Channels...")
|
||||
|
||||
global twitch_chat
|
||||
twitch_chat = twitch_script_class.Twitch_Module()
|
||||
global credentials_manager
|
||||
print("Loading credentials...")
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
credentials_manager.load_credentials()
|
||||
|
||||
twitch_chat.join_channel("thecuriousnerd")
|
||||
# twitch_chat.send_message("activated")
|
||||
twitch_chat = twitch_script.Twitch_Module()
|
||||
|
||||
if credentials_manager.Twitch_Credentials_List is not None:
|
||||
for cert in credentials_manager.Twitch_Credentials_List:
|
||||
if cert.username == "praxis_bot":
|
||||
print("Twitch Certificate Found: {" + cert.username + "}")
|
||||
mainCert = cert
|
||||
|
||||
print("Loading Credential: {" + cert.username + "} into Twitch_Module")
|
||||
twitch_chat.twitchCredential = mainCert
|
||||
print("Connecting to Channel: " + "thecuriousnerd")
|
||||
twitch_chat.join_channel(None, "thecuriousnerd")
|
||||
|
||||
#twitch_chat.send_message("activated")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
# So I'm a little conflicted here. My nit-picky self says that this should be a class you have to instantiate rather
|
||||
# than static variables... I'll leave this alone for now, but you may wish to refactor this in future
|
||||
|
||||
username = ""
|
||||
helix = ""
|
||||
oauth = "oauth:"
|
||||
v5_Client = ""
|
||||
|
||||
#Username = Twitch Username
|
||||
#Helix ID https://dev.twitch.tv/console/apps
|
||||
#Oauth https://twitchapps.com/tmi/
|
||||
#V5 Client ID https://twitchtokengenerator.com/
|
||||
@ -5,14 +5,15 @@ import twitch
|
||||
import twitch.chat
|
||||
|
||||
import config as config
|
||||
import db
|
||||
#import db
|
||||
import tts
|
||||
import twitch_cred as twitch_credentials
|
||||
|
||||
import credentials
|
||||
|
||||
class Twitch_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.twitchCredential: credentials.Twitch_Credential
|
||||
self.chat: twitch.Chat
|
||||
self.tts_enabled: bool = False
|
||||
self.tts_whitelist_enabled: bool = False
|
||||
@ -22,14 +23,16 @@ class Twitch_Module():
|
||||
self._urlMatcher = re.compile(
|
||||
"(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))")
|
||||
|
||||
def join_channel(self, channel_name):
|
||||
def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):
|
||||
channel_name = "#" + channel_name
|
||||
if credential is None:
|
||||
credential = self.twitchCredential
|
||||
|
||||
self.chat = twitch.Chat(
|
||||
channel=channel_name,
|
||||
nickname=twitch_credentials.username,
|
||||
oauth=twitch_credentials.oauth,
|
||||
helix=twitch.Helix(twitch_credentials.helix, use_cache=True)
|
||||
channel = channel_name,
|
||||
nickname = credential.username,
|
||||
oauth = credential.oauth,
|
||||
helix = twitch.Helix(credential.helix, use_cache=True)
|
||||
)
|
||||
self.chat.subscribe(self.twitch_chat)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user