Merge branch 'main' of gitlab.com:gpvkt/twitchtts

This commit is contained in:
gpkvt 2022-08-18 16:45:16 +02:00
commit 1fa9fd072e
2 changed files with 14 additions and 4 deletions

View File

@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. If there is a `Changed` section please read carefully, as this often means that you will need to adapt your `config.yml`, otherwise the bot might fail to start.
## [1.2.5] - 2022-08.16
### Changed
* Improved logging
## [1.2.4] - 2022-08-15
### Added 1.2.4

12
tts.py
View File

@ -63,6 +63,7 @@ class IRC:
def connect(self, server, port, channel, botnick, botpass):
""" Connect to Twitch IRC servers """
logging.info("Connecting to: %s", server)
logging.info('Waiting...')
try:
self.irc.connect((server, port))
except ConnectionResetError:
@ -790,12 +791,15 @@ class HTTPserv(BaseHTTPRequestHandler):
usermap = conf['USERMAP']
sorted_tts = {k: msg_queue[k] for k in sorted(msg_queue, reverse=True)}
logging.debug(usermap)
for key in list(sorted_tts.keys()):
if key not in tts_done:
if msg_queue[key][0].lower() in usermap:
logging.info('Using usermap for user: %s (%s)', msg_queue[key][0], usermap[msg_queue[key][0].lower()])
tts = {str(key): str(usermap[msg_queue[key][0].lower()]) + " " + str(conf['MESSAGE']['SAYS']) + ":" + str(msg_queue[key][1])}
else:
logging.debug('No usermap entry found for user: %s', msg_queue[key][0])
tts = {str(key): str(msg_queue[key][0]) + " " + str(conf['MESSAGE']['SAYS']) + ":" + str(msg_queue[key][1])}
tts_json = json.dumps(tts)
@ -930,8 +934,7 @@ def load_config():
if conf['WHITELIST']:
logging.info('Whitelist mode enabled')
logging.debug('Whitelist:')
logging.debug(conf['WHITELIST_USER'])
logging.debug('Whitelist: %s', conf['WHITELIST_USER'])
if not conf['IRC_CHANNEL']:
raise ValueError('Please add your twitch channel to config.yml.')
@ -997,7 +1000,7 @@ def check_oauth_token():
conf = load_config()
check_oauth_token()
logging.info('OAuth Token is valid.')
logging.info('OAuth Token is valid')
return conf
def main():
@ -1026,6 +1029,7 @@ def main():
irc.connect(conf['IRC_SERVER'], 6667, conf['IRC_CHANNEL'], conf['IRC_USERNAME'], conf['IRC_OAUTH_TOKEN'])
irc.sendmsg(conf['IRC_CHANNEL'], 'MrDestructoid', conf['MESSAGE']['READY'])
logging.info('Connected and joined')
url = get_url()
logging.info("Please open your browser and visit: %s", url)
webbrowser.open_new_tab(url)
@ -1068,7 +1072,7 @@ if __name__ == "__main__":
if sys.argv[1:]:
if sys.argv[1] == "--version":
print('Simple TTS Bot')
print('Version 1.2.4')
print('Version 1.2.5')
sys.exit(1)
main()