Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +12 -8
chatbot/plugins/chat.py
CHANGED
@@ -115,10 +115,18 @@ class TaskManager:
|
|
115 |
|
116 |
task_manager = TaskManager()
|
117 |
|
118 |
-
async def progress(current, total, message, start, type_of_ps, file_name=None
|
119 |
"""Progress Bar For Showing Progress While Uploading / Downloading File - Normal"""
|
120 |
now = time.time()
|
121 |
diff = now - start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
if round(diff % 10.00) == 0 or current == total:
|
123 |
percentage = current * 100 / total
|
124 |
speed = current / diff
|
@@ -148,7 +156,7 @@ async def progress(current, total, message, start, type_of_ps, file_name=None, r
|
|
148 |
await message.edit_text(
|
149 |
f"{type_of_ps}\n{tmp}",
|
150 |
parse_mode=enums.ParseMode.MARKDOWN,
|
151 |
-
reply_markup=
|
152 |
)
|
153 |
except FloodWait as e:
|
154 |
await asyncio.sleep(e.x)
|
@@ -212,9 +220,7 @@ async def handle_photo(client, message):
|
|
212 |
)
|
213 |
seconds_time = time.time()
|
214 |
file_path = await message.download(
|
215 |
-
progress=progress
|
216 |
-
reply_markup=InlineKeyboardMarkup(buttons)
|
217 |
-
),
|
218 |
progress_args=(ai_reply, seconds_time, "Uploading..."),
|
219 |
)
|
220 |
caption = message.caption or "What's this?"
|
@@ -270,9 +276,7 @@ async def handle_video(client, message, model_):
|
|
270 |
seconds_time = time.time()
|
271 |
video_file_name = await message.download(
|
272 |
file_name="newvideo.mp4",
|
273 |
-
progress=progress
|
274 |
-
reply_markup=InlineKeyboardMarkup(buttons)
|
275 |
-
),
|
276 |
progress_args=(ai_reply, seconds_time, "Uploading...")
|
277 |
)
|
278 |
caption = message.caption or "What's this?"
|
|
|
115 |
|
116 |
task_manager = TaskManager()
|
117 |
|
118 |
+
async def progress(current, total, message, start, type_of_ps, file_name=None):
|
119 |
"""Progress Bar For Showing Progress While Uploading / Downloading File - Normal"""
|
120 |
now = time.time()
|
121 |
diff = now - start
|
122 |
+
buttons = [
|
123 |
+
[
|
124 |
+
InlineKeyboardButton(
|
125 |
+
text="Cancel",
|
126 |
+
callback_data="cancels"
|
127 |
+
)
|
128 |
+
],
|
129 |
+
]
|
130 |
if round(diff % 10.00) == 0 or current == total:
|
131 |
percentage = current * 100 / total
|
132 |
speed = current / diff
|
|
|
156 |
await message.edit_text(
|
157 |
f"{type_of_ps}\n{tmp}",
|
158 |
parse_mode=enums.ParseMode.MARKDOWN,
|
159 |
+
reply_markup=InlineKeyboardMarkup(buttons)
|
160 |
)
|
161 |
except FloodWait as e:
|
162 |
await asyncio.sleep(e.x)
|
|
|
220 |
)
|
221 |
seconds_time = time.time()
|
222 |
file_path = await message.download(
|
223 |
+
progress=progress,
|
|
|
|
|
224 |
progress_args=(ai_reply, seconds_time, "Uploading..."),
|
225 |
)
|
226 |
caption = message.caption or "What's this?"
|
|
|
276 |
seconds_time = time.time()
|
277 |
video_file_name = await message.download(
|
278 |
file_name="newvideo.mp4",
|
279 |
+
progress=progress,
|
|
|
|
|
280 |
progress_args=(ai_reply, seconds_time, "Uploading...")
|
281 |
)
|
282 |
caption = message.caption or "What's this?"
|