Improved logging

This commit is contained in:
gpkvt 2022-08-16 22:45:36 +02:00
parent 995738368c
commit 4097b6f615
3 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

BIN
dist/tts.exe vendored

Binary file not shown.

12
tts.py
View File

@ -61,6 +61,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:
@ -640,12 +641,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)
@ -776,8 +780,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.')
@ -843,7 +846,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():
@ -872,6 +875,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)
@ -914,7 +918,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()