Skip to content

Commit

Permalink
chrore: fixed unblock execution time when downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 12, 2023
1 parent eeb54ea commit cec0fd3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bot/commands/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ async def _(client: Client, message: Message):
await _message.edit("💾 **__Downloading...__**")
media = await client.download_media(
message.reply_to_message,
block=False,
file_name=file_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
block=False,
)
if VOICE_CHATS.get(message.chat.id) is None:
await _message.edit("🪄 **__Joining the voice chat...__**")
Expand Down
7 changes: 5 additions & 2 deletions bot/commands/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,21 @@ async def _(client: Client, message: Message):
await _message.edit("💾 **__Downloading...__**")
media = await assistant.download_media(
message.reply_to_message,
block=False,
file_name=file_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
block=False,
)
if VOICE_CHATS.get(message.chat.id) is None:
await _message.edit("🪄 **__Joining the voice chat...__**")
await tgcalls.start(message.chat.id)
VOICE_CHATS[message.chat.id] = tgcalls
await sleep(2)
await VOICE_CHATS[message.chat.id].start_video(
media, enable_experimental_lip_sync=True, repeat=False
media,
enable_experimental_lip_sync=True,
repeat=False,
with_audio=True,
)
# await _message.delete()
await _message.edit(
Expand Down
12 changes: 7 additions & 5 deletions bot/commands/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def _(client: Client, message: Message):
similary = SequenceMatcher(None, search, media["caption"]).ratio()
if similary >= 0.3:
await _message.edit(
f"**__Yeehaw, I found the {media['type']} you asked for...__**"
f"**__I found the {media['type']} you asked for...__**"
)
await sleep(2)
await _message.edit("💾 **__Downloading...__**")
Expand All @@ -73,13 +73,15 @@ async def _(client: Client, message: Message):
if media["type"] == "serie":
video = await assistant.download_media(
media["file_id"],
block=False,
file_name=serie_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
)
if media["type"] == "movie":
video = await assistant.download_media(
media["file_id"],
block=False,
file_name=movie_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
Expand Down Expand Up @@ -108,12 +110,12 @@ async def _(client: Client, message: Message):
"**__The request has not been found in our database, please try another name__**"
)
break
except Exception as e:
logging.error(e)
except Exception as err:
logging.error(err)
await _message.edit(
f"**__Oops master, something wrong has happened.__** \n\n`Error: {e}`",
f"**__Oops master, something wrong has happened.__** \n\n`Error: {err}`",
)
if message.chat.id in VOICE_CHATS:
await VOICE_CHATS[message.chat.id].stop()
await remove_queue(str(message.chat.id))
remove_queue(str(message.chat.id))
VOICE_CHATS.pop(message.chat.id)

0 comments on commit cec0fd3

Please sign in to comment.