(current, total, ud_type, message, start)
| 3 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup |
| 4 | |
| 5 | async def progress_for_pyrogram(current, total, ud_type, message, start): |
| 6 | now = time.time() |
| 7 | diff = now - start |
| 8 | if round(diff % 5.00) == 0 or current == total: |
| 9 | percentage = current * 100 / total |
| 10 | speed = current / diff |
| 11 | elapsed_time = round(diff) * 1000 |
| 12 | time_to_completion = round((total - current) / speed) * 1000 |
| 13 | estimated_total_time = elapsed_time + time_to_completion |
| 14 | |
| 15 | elapsed_time = TimeFormatter(milliseconds=elapsed_time) |
| 16 | estimated_total_time = TimeFormatter(milliseconds=estimated_total_time) |
| 17 | |
| 18 | progress = "{0}{1}".format( |
| 19 | ''.join(["▣" for i in range(math.floor(percentage / 5))]), |
| 20 | ''.join(["▢" for i in range(20 - math.floor(percentage / 5))]) |
| 21 | ) |
| 22 | tmp = progress + rkn.PROGRESS.format( |
| 23 | round(percentage, 2), |
| 24 | humanbytes(current), |
| 25 | humanbytes(total), |
| 26 | humanbytes(speed), |
| 27 | estimated_total_time if estimated_total_time != '' else "0 s" |
| 28 | ) |
| 29 | try: |
| 30 | await message.edit( |
| 31 | text=f"{ud_type}\n\n{tmp}", |
| 32 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("✖️ 𝙲𝙰𝙽𝙲𝙴𝙻 ✖️", callback_data="close")]]) |
| 33 | ) |
| 34 | except: |
| 35 | pass |
| 36 | |
| 37 | def humanbytes(size): |
| 38 | if not size: |
nothing calls this directly
no test coverage detected