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
This commit is contained in:
Tim Wilson 2020-09-23 11:41:50 -06:00 committed by GitHub
parent f1d62b9ce5
commit 5e8f0b39cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
bot.py
View File

@ -49,6 +49,7 @@ CONFIG = {
"whitelist_user_ids": [], # discord users allowed to use bot "whitelist_user_ids": [], # discord users allowed to use bot
"blacklist_user_ids": [], # discord users disallowed to use bot "blacklist_user_ids": [], # discord users disallowed to use bot
"owner_user_ids": [], # discord users given full access "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 "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_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 "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] torrents = [t for t in torrents if not t.isPrivate]
elif f == "error": elif f == "error":
torrents = [t for t in torrents if t.error != 0] 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": elif f == "running":
torrents = [t for t in torrents if t.rateDownload + t.rateUpload > 0] torrents = [t for t in torrents if t.rateDownload + t.rateUpload > 0]
else: else:
@ -1119,6 +1128,7 @@ async def add(message, content = ""):
if content == "" and len(torFileList) == 0: if content == "" and len(torFileList) == 0:
await message.channel.send("🚫 Invalid string") await message.channel.send("🚫 Invalid string")
if CONFIG['delete_command_messages']:
try: try:
await message.delete() await message.delete()
except: except:
@ -1282,6 +1292,7 @@ async def summary(message, content="", repeat_msg_key=None):
if not repeat_msg_key: if not repeat_msg_key:
if len(REPEAT_MSGS) == 0: if len(REPEAT_MSGS) == 0:
reload_client() reload_client()
if CONFIG['delete_command_messages']:
try: try:
await message.delete() await message.delete()
except: except:
@ -1656,6 +1667,7 @@ async def list_transfers(message, content="", repeat_msg_key=None):
if not repeat_msg_key: if not repeat_msg_key:
if len(REPEAT_MSGS) == 0: if len(REPEAT_MSGS) == 0:
reload_client() reload_client()
if CONFIG['delete_command_messages']:
try: try:
await message.delete() await message.delete()
except: except:
@ -1813,6 +1825,7 @@ async def modify(message, content=""):
await message.channel.send("Must specify integer greater than 0 for `-N`!") await message.channel.send("Must specify integer greater than 0 for `-N`!")
return return
if CONFIG['delete_command_messages']:
try: try:
await message.delete() await message.delete()
except: except: