nvd commited on
Commit
8d6acba
Β·
verified Β·
1 Parent(s): 1107167

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +22 -0
bot.py CHANGED
@@ -266,6 +266,28 @@ async def handle_callback(callback: dict):
266
  try:
267
  await download_file(url, tmp_path)
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  file_size = os.path.getsize(tmp_path)
270
  size_mb = file_size / (1024 * 1024)
271
  logger.info(f"βœ… Downloaded: {size_mb:.2f} MB")
 
266
  try:
267
  await download_file(url, tmp_path)
268
 
269
+ # Inside handle_callback, right after await download_file(url, tmp_path)
270
+
271
+ # ─── Detect APK and rename if needed ───
272
+ if filename.lower().endswith('.apk'):
273
+ new_path = tmp_path + '.bin'
274
+ os.rename(tmp_path, new_path)
275
+ original_tmp = tmp_path
276
+ tmp_path = new_path
277
+ filename_for_upload = filename + '.bin'
278
+ caption = "Here you go!\n\nπŸ“ Rename to .apk after downloading."
279
+ else:
280
+ filename_for_upload = filename
281
+ caption = "Here you go!"
282
+
283
+ # Now pass the (possibly renamed) file to send_document_file
284
+ result = await send_document_file(
285
+ chat_id,
286
+ tmp_path,
287
+ caption=caption,
288
+ display_filename=filename_for_upload
289
+ )
290
+
291
  file_size = os.path.getsize(tmp_path)
292
  size_mb = file_size / (1024 * 1024)
293
  logger.info(f"βœ… Downloaded: {size_mb:.2f} MB")