Skip to content

Commit

Permalink
chore: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 12, 2023
1 parent c8761bc commit 56b0eba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
bot_token=_BOT_TOKEN,
)

assistant = Client(
userbot = Client(
"userbot.assistant",
api_id=_API_ID,
api_hash=_API_HASH,
Expand All @@ -87,13 +87,13 @@
# ------------------------------------------------------------------------------

tgcalls = GroupCallFactory(
assistant, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM
userbot, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM
).get_group_call()

# ------------------------------------------------------------------------------

kreacher.start()
assistant.start()
userbot.start()
driver = get_driver()

START_TIME = datetime.utcnow()
Expand Down
6 changes: 3 additions & 3 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyrogram.types import BotCommand

from bot.setup import setup_plugins
from bot import kreacher, assistant
from bot import kreacher, userbot

ay = asyncio.get_event_loop()

Expand All @@ -18,7 +18,7 @@ async def start_bot():
BotCommand("help", "How to use this one"),
BotCommand("leave", "Leave the voice chat"),
BotCommand("ping", "Check server latency"),
BotCommand("play_book", "Play pdf file as audiobook"),
BotCommand("play_book", "Play pdf or epub file as audiobook"),
BotCommand("play_song", "Play audio in voice chat"),
BotCommand("play_video", "Play video in voice chat"),
BotCommand("speedtest", "Run server speed test"),
Expand All @@ -35,5 +35,5 @@ async def start_bot():
idle()
except KeyboardInterrupt:
kreacher.disconnect()
assistant.disconnect()
userbot.disconnect()
print(f'{colored("[INFO]:", "blue")} CLIENTS DISCONNECTED')
5 changes: 2 additions & 3 deletions bot/commands/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from bot.helpers.progress import progress
from bot.helpers.yt import ytdl, ytsearch
from bot.helpers.user_info import user_info
from bot import assistant, kreacher, tgcalls, VOICE_CHATS
from bot import kreacher, tgcalls, userbot, VOICE_CHATS
from bot.helpers.queues import (
add_or_create_queue,
get_queues,
Expand Down Expand Up @@ -201,7 +201,7 @@ async def _(client: Client, message: Message):
type_of="video_media",
)
await _message.edit("💾 **__Downloading...__**")
media = await assistant.download_media(
media = await userbot.download_media(
message.reply_to_message,
file_name=file_name,
progress=progress,
Expand All @@ -216,7 +216,6 @@ async def _(client: Client, message: Message):
media,
enable_experimental_lip_sync=True,
repeat=False,
with_audio=True,
)
# await _message.delete()
await _message.edit(
Expand Down
13 changes: 6 additions & 7 deletions bot/commands/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyrogram.enums import MessagesFilter
from bot.helpers.progress import progress
from bot.scrapers.images import ImageScraper
from bot import assistant, kreacher, tgcalls, VOICE_CHATS
from bot import userbot, kreacher, tgcalls, VOICE_CHATS
from bot.decorators.sides import only_groups_or_channels
from bot.helpers.queues import (
remove_queue,
Expand All @@ -27,9 +27,9 @@ async def _(client: Client, message: Message):
_message = await message.reply("🔎 **__Searching...__**")
await sleep(2)
search = message.text.split(maxsplit=1)[1]
series_channel = await assistant.get_chat(config.ES_SERIES_CHANNEL)
movies_channel = await assistant.get_chat(config.ES_MOVIES_CHANNEL)
async for serie in assistant.search_messages(
series_channel = await userbot.get_chat(config.ES_SERIES_CHANNEL)
movies_channel = await userbot.get_chat(config.ES_MOVIES_CHANNEL)
async for serie in userbot.search_messages(
chat_id=series_channel.id,
query=search,
limit=1000,
Expand All @@ -42,7 +42,7 @@ async def _(client: Client, message: Message):
"file_id": serie.video.file_id,
}
)
async for movie in assistant.search_messages(
async for movie in userbot.search_messages(
chat_id=movies_channel.id,
query=search,
limit=1000,
Expand Down Expand Up @@ -74,7 +74,7 @@ async def _(client: Client, message: Message):
else message.reply_to_message.file.mime_type.split("/", 1)[1]
)
file_name = f"/tmp/{str(uuid.uuid4())}.{mime_type}"
video = await assistant.download_media(
video = await userbot.download_media(
media["file_id"],
file_name=file_name,
progress=progress,
Expand All @@ -89,7 +89,6 @@ async def _(client: Client, message: Message):
video,
enable_experimental_lip_sync=True,
repeat=False,
with_audio=True,
)
await _message.delete()
await client.send_photo(
Expand Down

0 comments on commit 56b0eba

Please sign in to comment.