Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code. #30

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 26 additions & 44 deletions AlexaMusic/core/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ async def force_stop_stream(self, chat_id: int):
pass

async def skip_stream(
self, chat_id: int, link: str, video: Union[bool, str] = None, image: Union[bool, str] = None
self,
chat_id: int,
link: str,
video: Union[bool, str] = None,
image: Union[bool, str] = None,
):
assistant = await group_assistant(self, chat_id)
audio_stream_quality = await get_audio_bitrate(chat_id)
Expand All @@ -167,10 +171,7 @@ async def skip_stream(
stream,
)


async def seek_stream(
self, chat_id, file_path, to_seek, duration, mode
):
async def seek_stream(self, chat_id, file_path, to_seek, duration, mode):
assistant = await group_assistant(self, chat_id)
audio_stream_quality = await get_audio_bitrate(chat_id)
video_stream_quality = await get_video_bitrate(chat_id)
Expand Down Expand Up @@ -204,7 +205,12 @@ async def join_assistant(self, original_chat_id, chat_id):
await app.unban_chat_member(chat_id, userbot.id)
except:
raise AssistantErr(
_["call_2"].format(config.BOT_NAME, userbot.id, userbot.mention, userbot.username),
_["call_2"].format(
config.BOT_NAME,
userbot.id,
userbot.mention,
userbot.username,
),
)
except UserNotParticipant:
chat = await app.get_chat(chat_id)
Expand All @@ -221,17 +227,9 @@ async def join_assistant(self, original_chat_id, chat_id):
try:
invitelink = chat.invite_link
if invitelink is None:
invitelink = (
await app.export_chat_invite_link(
chat_id
)
)
invitelink = await app.export_chat_invite_link(chat_id)
except:
invitelink = (
await app.export_chat_invite_link(
chat_id
)
)
invitelink = await app.export_chat_invite_link(chat_id)
except ChatAdminRequired:
raise AssistantErr(_["call_4"])
except Exception as e:
Expand Down Expand Up @@ -324,9 +322,7 @@ async def join_call(
counter[chat_id] = {}
users = len(await assistant.get_participants(chat_id))
if users == 1:
autoend[chat_id] = datetime.now() + timedelta(
minutes=AUTO_END_TIME
)
autoend[chat_id] = datetime.now() + timedelta(minutes=AUTO_END_TIME)

async def change_stream(self, client, chat_id):
check = db.get(chat_id)
Expand Down Expand Up @@ -417,17 +413,13 @@ async def change_stream(self, client, chat_id):
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "tg"
elif "vid_" in queued:
mystic = await app.send_message(
original_chat_id, _["call_10"]
)
mystic = await app.send_message(original_chat_id, _["call_10"])
try:
file_path, direct = await YouTube.download(
videoid,
mystic,
videoid=True,
video=True
if str(streamtype) == "video"
else False,
video=True if str(streamtype) == "video" else False,
)
except:
return await mystic.edit_text(
Expand Down Expand Up @@ -487,9 +479,7 @@ async def change_stream(self, client, chat_id):
video_parameters=video_stream_quality,
)
if str(streamtype) == "video"
else AudioPiped(
videoid, audio_parameters=audio_stream_quality
)
else AudioPiped(videoid, audio_parameters=audio_stream_quality)
)
try:
await client.change_stream(chat_id, stream)
Expand Down Expand Up @@ -550,9 +540,7 @@ async def change_stream(self, client, chat_id):
photo=config.TELEGRAM_AUDIO_URL
if str(streamtype) == "audio"
else config.TELEGRAM_VIDEO_URL,
caption=_["stream_3"].format(
title, check[0]["dur"], user
),
caption=_["stream_3"].format(title, check[0]["dur"], user),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
Expand All @@ -562,9 +550,7 @@ async def change_stream(self, client, chat_id):
run = await app.send_photo(
original_chat_id,
photo=config.SOUNCLOUD_IMG_URL,
caption=_["stream_3"].format(
title, check[0]["dur"], user
),
caption=_["stream_3"].format(title, check[0]["dur"], user),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
Expand Down Expand Up @@ -648,9 +634,9 @@ async def stream_end_handler1(client, update: Update):
@self.four.on_participants_change()
@self.five.on_participants_change()
async def participants_change_handler(client, update: Update):
if not isinstance(
update, JoinedGroupCallParticipant
) and not isinstance(update, LeftGroupCallParticipant):
if not isinstance(update, JoinedGroupCallParticipant) and not isinstance(
update, LeftGroupCallParticipant
):
return
chat_id = update.chat_id
users = counter.get(chat_id)
Expand All @@ -661,9 +647,7 @@ async def participants_change_handler(client, update: Update):
return
counter[chat_id] = got
if got == 1:
autoend[chat_id] = datetime.now() + timedelta(
minutes=AUTO_END_TIME
)
autoend[chat_id] = datetime.now() + timedelta(minutes=AUTO_END_TIME)
return
autoend[chat_id] = {}
else:
Expand All @@ -674,11 +658,9 @@ async def participants_change_handler(client, update: Update):
)
counter[chat_id] = final
if final == 1:
autoend[chat_id] = datetime.now() + timedelta(
minutes=AUTO_END_TIME
)
autoend[chat_id] = datetime.now() + timedelta(minutes=AUTO_END_TIME)
return
autoend[chat_id] = {}


Alexa = Call()
Alexa = Call()