From 179a26e07e997b6346846d3013b60d7df95c4d3c Mon Sep 17 00:00:00 2001 From: Tim Wilson Date: Tue, 20 Oct 2020 17:07:20 -0600 Subject: [PATCH] adding details to previous commit * NEW: added log rotation * NEW: improved error handling * NEW: makes backup copies of original when overwriting json files * NEW: `notification_channel_id` config item is now an integer (was previously a string) * NEW: bot prefix is optional in DMs * IMPROVED: don't print reactions to notifications that only contain removed transfers * IMPROVED: in-channel help now initiates a help DM to the user * FIXED: fixed potential access of `CONFIG` before being initialized * FIXED: validate notification channel before trying to post notifications * FIXED: `notification_DM_opt_out_user_ids` config is now properly respected --- bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 2d2892d..b529b04 100644 --- a/bot.py +++ b/bot.py @@ -908,7 +908,7 @@ async def check_notification_reactions(message, is_text_channel, torrents, start return await check_notification_reactions(message, is_text_channel, torrents, starttime=starttime) async def run_notifications(): - if CONFIG['notification_enabled'] and CONFIG['notification_channel_id'] > 0: + if CONFIG['notification_enabled']: # get all changes logger.debug("Running notification check") changedTransfers = check_for_transfer_changes() @@ -916,7 +916,7 @@ async def run_notifications(): if nTotal > 0: addReactions = (sum([len(d['data']) for k,d in changedTransfers.items() if k != "removed"]) > 0) # first in_channel notifications - if CONFIG['notification_enabled_in_channel']: + if CONFIG['notification_enabled_in_channel'] and CONFIG['notification_channel_id'] > 0 and len(str(CONFIG['notification_channel_id'])) == 18: embeds, n, torrents = prepare_notifications(changedTransfers, CONFIG['notification_states']['in_channel']) logger.debug("in_channel notifications: {}".format(n)) # now post notifications