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. #56

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
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
72 changes: 27 additions & 45 deletions AlexaMusic/core/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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 @@ -168,10 +172,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 @@ -205,7 +206,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 @@ -222,17 +228,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 @@ -325,9 +323,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, user_id):
check = db.get(chat_id)
Expand Down Expand Up @@ -421,17 +417,13 @@ async def change_stream(self, client, chat_id, user_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 @@ -467,7 +459,7 @@ async def change_stream(self, client, chat_id, user_id):
original_chat_id,
text=_["call_9"],
)
theme = await check_theme(chat_id)
theme = await check_theme(chat_id)
img = await gen_thumb(videoid, user_id, theme)
button = stream_markup(_, videoid, chat_id)
await mystic.delete()
Expand All @@ -492,9 +484,7 @@ async def change_stream(self, client, chat_id, user_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 @@ -555,9 +545,7 @@ async def change_stream(self, client, chat_id, user_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 @@ -567,9 +555,7 @@ async def change_stream(self, client, chat_id, user_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 @@ -654,9 +640,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 @@ -667,9 +653,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 @@ -680,11 +664,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()
4 changes: 2 additions & 2 deletions AlexaMusic/plugins/admins/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ async def del_back_playlist(client, CallbackQuery, _):
await Alexa.skip_stream(chat_id, link, video=status)
except Exception:
return await CallbackQuery.message.reply_text(_["call_9"])
theme = await check_theme(chat_id)
theme = await check_theme(chat_id)
button = telegram_markup(_, chat_id)
img = await gen_thumb(videoid, user_id, theme)
run = await CallbackQuery.message.reply_photo(
Expand Down Expand Up @@ -239,7 +239,7 @@ async def del_back_playlist(client, CallbackQuery, _):
await Alexa.skip_stream(chat_id, file_path, video=status)
except Exception:
return await mystic.edit_text(_["call_9"])
theme = await check_theme(chat_id)
theme = await check_theme(chat_id)
button = stream_markup(_, videoid, chat_id)
img = await gen_thumb(videoid, user_id, theme)
run = await CallbackQuery.message.reply_photo(
Expand Down