Skip to content

Commit

Permalink
update telegram_uploader.py
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Sep 17, 2024
1 parent 6b714ba commit d3c1235
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions bot/helper/mirror_leech_utils/telegram_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,22 @@ async def _upload_photo(self, cap_mono, thumb):

async def _copy_message(self, m, cap_mono):
msg = await bot.get_messages(self._listener.upDest, m.id)
try:
await msg.copy(self._user_id, caption=cap_mono)
except Exception as e:
LOGGER.error(e)

async def retry_copy(target, caption, retries=5):
for attempt in range(retries):
try:
await msg.copy(target, caption=caption)
return
except Exception as e:
LOGGER.error(f"Attempt {attempt + 1} failed: {e}")
if attempt < retries - 1:
await asyncio.sleep(2)
LOGGER.error(f"Failed to copy message after {retries} attempts")

await retry_copy(self._user_id, cap_mono)

if self._user_dump:
try:
await msg.copy(self._user_dump, caption=cap_mono)
except Exception as e:
LOGGER.error(e)
await retry_copy(self._user_dump, cap_mono)

def _get_image_dimensions(self, thumb):
if thumb:
Expand Down

0 comments on commit d3c1235

Please sign in to comment.