From afb4ccede4a27050bde33681b8a273ab4bec2f79 Mon Sep 17 00:00:00 2001 From: gpkvt Date: Tue, 16 Aug 2022 22:45:36 +0200 Subject: [PATCH] Improved logging --- CHANGELOG.md | 6 ++++++ tts.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b4983e..a779839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tts.py b/tts.py index 2a442ac..4c5bd10 100644 --- a/tts.py +++ b/tts.py @@ -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()