mirror of https://gitlab.com/gpvkt/twitchtts.git
Minor changes
This commit is contained in:
parent
fb1d9531cf
commit
57e55f0946
|
@ -32,7 +32,7 @@ By using Javascript for the actual TTS part it's not only very easy to access th
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Adapt `config.yml` to your needs. Example:
|
Adapt `config.yml` to your needs. Please use `UTF-8` as encoding. Example:
|
||||||
|
|
||||||
``` lang=yaml
|
``` lang=yaml
|
||||||
irc:
|
irc:
|
||||||
|
|
File diff suppressed because one or more lines are too long
19
tts.py
19
tts.py
|
@ -821,17 +821,18 @@ def get_url(path=False):
|
||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def check_oauth_token(conf):
|
def check_oauth_token():
|
||||||
""" Check for valid authentication via Twitch API """
|
""" Check for valid authentication via Twitch API """
|
||||||
|
global conf # pylint: disable=global-statement,invalid-name
|
||||||
logging.debug('Checking OAuth Token')
|
logging.debug('Checking OAuth Token')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = 'https://id.twitch.tv/oauth2/validate'
|
url = 'https://id.twitch.tv/oauth2/validate'
|
||||||
oauth = "OAuth %s" % conf['IRC_OAUTH_TOKEN'].replace('oauth:','')
|
oauth = "OAuth "+str(conf['IRC_OAUTH_TOKEN'].replace('oauth:',''))
|
||||||
request = urllib.request.Request(url)
|
request = urllib.request.Request(url)
|
||||||
request.add_header('Authorization', oauth)
|
request.add_header('Authorization', oauth)
|
||||||
urllib.request.urlopen(request)
|
urllib.request.urlopen(request)
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
conf['IRC_OAUTH_TOKEN'] == "Invalid"
|
|
||||||
logging.fatal('Twitch rejected your OAuth Token. Please check and generate a new one.')
|
logging.fatal('Twitch rejected your OAuth Token. Please check and generate a new one.')
|
||||||
logging.info('Please open http://%s:%s/token to generate your OAuth-Token.', conf['HTTP_BIND'], conf['HTTP_PORT'])
|
logging.info('Please open http://%s:%s/token to generate your OAuth-Token.', conf['HTTP_BIND'], conf['HTTP_PORT'])
|
||||||
|
|
||||||
|
@ -842,12 +843,13 @@ def check_oauth_token(conf):
|
||||||
conf = load_config()
|
conf = load_config()
|
||||||
check_oauth_token()
|
check_oauth_token()
|
||||||
|
|
||||||
logging.info('OAuth Token is valid \o/')
|
logging.info('OAuth Token is valid.')
|
||||||
return
|
return conf
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main loop"""
|
"""Main loop"""
|
||||||
|
|
||||||
|
global conf # pylint: disable=global-statement,invalid-name
|
||||||
conf = load_config()
|
conf = load_config()
|
||||||
|
|
||||||
lastreload = datetime.datetime.now()
|
lastreload = datetime.datetime.now()
|
||||||
|
@ -862,7 +864,7 @@ def main():
|
||||||
|
|
||||||
http_thread = Thread(target=http_serve_forever, daemon=True, args=(httpd, ))
|
http_thread = Thread(target=http_serve_forever, daemon=True, args=(httpd, ))
|
||||||
http_thread.start()
|
http_thread.start()
|
||||||
check_oauth_token(conf)
|
check_oauth_token()
|
||||||
|
|
||||||
logging.info("Starting IRC bot")
|
logging.info("Starting IRC bot")
|
||||||
irc = IRC()
|
irc = IRC()
|
||||||
|
@ -901,15 +903,14 @@ def main():
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s')
|
||||||
|
sys.tracebacklimit = 3
|
||||||
|
|
||||||
conf = {}
|
conf = {}
|
||||||
tts_done = []
|
tts_done = []
|
||||||
msg_queue_raw = []
|
msg_queue_raw = []
|
||||||
msg_queue = {}
|
msg_queue = {}
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(module)s %(threadName)s %(levelname)s: %(message)s')
|
|
||||||
sys.tracebacklimit = 3
|
|
||||||
|
|
||||||
if sys.argv[1:]:
|
if sys.argv[1:]:
|
||||||
if sys.argv[1] == "--version":
|
if sys.argv[1] == "--version":
|
||||||
print('Simple TTS Bot')
|
print('Simple TTS Bot')
|
||||||
|
|
Loading…
Reference in New Issue