From 55ae0bb6f5a7e8565ebfa1d479e0fa67a16a236b Mon Sep 17 00:00:00 2001 From: Tim Wilson Date: Wed, 9 Sep 2020 17:35:29 -0600 Subject: [PATCH] performance improvements added labeling to multi-message output for `t/list` and `t/modify` (e.g. message 1 of 2) Played with the output of `t/list` and `t/modify` to make it a bit easier to interpret --- bot.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 7d01f05..fe2b58d 100644 --- a/bot.py +++ b/bot.py @@ -1462,13 +1462,13 @@ def torList(torrents, author_name="Torrent Transfers",title=None,description=Non down = humanbytes(t.progress * 0.01 * t.totalSize) out = "{} {} {} {} ".format(stateEmoji[t.status],errorStrs[t.error],'šŸš€' if t.rateDownload + t.rateUpload > 0 else '🐢' if t.isStalled else 'šŸ‡', 'šŸ”' if t.isPrivate else 'šŸ”“') if t.status == 'downloading': - out += "ā¬ {}/{} ({:.1f}%) {}ā¬‡ļø {}/s ā¬†ļø *{}/s* āš–ļø *{:.2f}*".format(down,humanbytes(t.totalSize),t.progress, '' if eta <= 0 else '\nā³ {} @ '.format(humanseconds(eta)), humanbytes(t.rateDownload),humanbytes(t.rateUpload),t.uploadRatio) + out += "{:.1f}% of {} ā¬ {} {}/s ā¬‡ļø *{}/s* ā¬†ļø *{:.2f}* āš–ļø".format(t.progress, humanbytes(t.totalSize, d=1), '' if eta <= 0 else 'ā³ {} @ '.format(humanseconds(eta)), humanbytes(t.rateDownload), humanbytes(t.rateUpload), t.uploadRatio) elif t.status == 'seeding': - out += "ā¬ {} ā¬†ļø *{}/s* āš–ļø *{:.2f}*".format(humanbytes(t.totalSize),humanbytes(t.rateUpload),t.uploadRatio) + out += "{} ā¬ *{}/s* ā¬†ļø *{:.2f}* āš–ļø".format(humanbytes(t.totalSize, d=1), humanbytes(t.rateUpload), t.uploadRatio) elif t.status == 'stopped': - out += "ā¬ {}/{} ({:.1f}%) āš–ļø *{:.2f}*".format(down,humanbytes(t.totalSize),t.progress,t.uploadRatio) + out += "{:.1f}% of {} ā¬ *{:.2f}* āš–ļø".format(t.progress, humanbytes(t.totalSize, d=1), t.uploadRatio) elif t.status == 'finished': - out += "ā¬ {} āš–ļø {:.2f}".format(humanbytes(t.totalSize),t.uploadRatio) + out += "{} ā¬ {:.2f} āš–ļø".format(humanbytes(t.totalSize, d=1), t.uploadRatio) elif t.status == "checking": out += "{:.2f}%".format(t.recheckProgress*100.0) @@ -1484,16 +1484,19 @@ def torList(torrents, author_name="Torrent Transfers",title=None,description=Non n = 0 i = 0 + eNum = 1 + eNumTotal = 1 + len(torrents) // 25 embeds = [] if len(torrents) > 0: while i < len(torrents): - embed=discord.Embed(title=title,description=description,color=0xb51a00) + embed=discord.Embed(title=title + ('' if eNumTotal == 1 else ' ({} of {})'.format(eNum, eNumTotal)),description=description,color=0xb51a00) for j in range(25): embed.add_field(name=nameList[i],value=valList[i],inline=False) i += 1 n += 1 if n >= 25: n = 0 + eNum += 1 break if i >= len(torrents): break