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
This commit is contained in:
Tim Wilson 2020-10-20 17:07:20 -06:00 committed by GitHub
parent 097ff37405
commit 179a26e07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
bot.py
View File

@ -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) return await check_notification_reactions(message, is_text_channel, torrents, starttime=starttime)
async def run_notifications(): async def run_notifications():
if CONFIG['notification_enabled'] and CONFIG['notification_channel_id'] > 0: if CONFIG['notification_enabled']:
# get all changes # get all changes
logger.debug("Running notification check") logger.debug("Running notification check")
changedTransfers = check_for_transfer_changes() changedTransfers = check_for_transfer_changes()
@ -916,7 +916,7 @@ async def run_notifications():
if nTotal > 0: if nTotal > 0:
addReactions = (sum([len(d['data']) for k,d in changedTransfers.items() if k != "removed"]) > 0) addReactions = (sum([len(d['data']) for k,d in changedTransfers.items() if k != "removed"]) > 0)
# first in_channel notifications # 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']) embeds, n, torrents = prepare_notifications(changedTransfers, CONFIG['notification_states']['in_channel'])
logger.debug("in_channel notifications: {}".format(n)) logger.debug("in_channel notifications: {}".format(n))
# now post notifications # now post notifications