From 5e8f0b39cb0796dda838a68a1502eeeaa4d69685 Mon Sep 17 00:00:00 2001 From: Tim Wilson Date: Wed, 23 Sep 2020 11:41:50 -0600 Subject: [PATCH] bugfix added missing filters for `t/list` and `t/modify` added configuration option to control whether command messages are deleted by the bot. if disabled, you can see the commands that prompted a result message --- bot.py | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/bot.py b/bot.py index 2deb42d..6c749b9 100644 --- a/bot.py +++ b/bot.py @@ -49,6 +49,7 @@ CONFIG = { "whitelist_user_ids": [], # discord users allowed to use bot "blacklist_user_ids": [], # discord users disallowed to use bot "owner_user_ids": [], # discord users given full access + "delete_command_messages": False, # delete command messages from users "private_transfers_protected": True, # prevent transfers on private trackers from being removed "whitelist_user_can_remove": True, # if true, whitelisted users can remove any transfer "whitelist_user_can_delete": True, # if true, whitelisted users can remove and delete any transfer @@ -365,6 +366,14 @@ class TSClient(transmissionrpc.Client): torrents = [t for t in torrents if not t.isPrivate] elif f == "error": torrents = [t for t in torrents if t.error != 0] + elif f == "err_none": + torrents = [t for t in torrents if t.error == 0] + elif f == "err_tracker_warn": + torrents = [t for t in torrents if t.error == 1] + elif f == "err_tracker_error": + torrents = [t for t in torrents if t.error == 2] + elif f == "err_local": + torrents = [t for t in torrents if t.error == 3] elif f == "running": torrents = [t for t in torrents if t.rateDownload + t.rateUpload > 0] else: @@ -1119,10 +1128,11 @@ async def add(message, content = ""): if content == "" and len(torFileList) == 0: await message.channel.send("🚫 Invalid string") - try: - await message.delete() - except: - pass + if CONFIG['delete_command_messages']: + try: + await message.delete() + except: + pass torStr = [] for t in torFileList: @@ -1282,10 +1292,11 @@ async def summary(message, content="", repeat_msg_key=None): if not repeat_msg_key: if len(REPEAT_MSGS) == 0: reload_client() - try: - await message.delete() - except: - pass + if CONFIG['delete_command_messages']: + try: + await message.delete() + except: + pass if TSCLIENT is None: reload_client() @@ -1656,10 +1667,11 @@ async def list_transfers(message, content="", repeat_msg_key=None): if not repeat_msg_key: if len(REPEAT_MSGS) == 0: reload_client() - try: - await message.delete() - except: - pass + if CONFIG['delete_command_messages']: + try: + await message.delete() + except: + pass if TSCLIENT is None: reload_client() @@ -1813,10 +1825,11 @@ async def modify(message, content=""): await message.channel.send("Must specify integer greater than 0 for `-N`!") return - try: - await message.delete() - except: - pass + if CONFIG['delete_command_messages']: + try: + await message.delete() + except: + pass if TSCLIENT is None: reload_client()