Skip to content

Commit

Permalink
chore: callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 11, 2023
1 parent 942c65c commit 02abb4a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
18 changes: 8 additions & 10 deletions bot/callbacks/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,31 @@
async def _(client: Client, callback: CallbackQuery):
if VOICE_CHATS[callback.message.chat.id].is_video_paused:
await VOICE_CHATS[callback.message.chat.id].set_pause(False)
return await callback.edit_message_text(
callback.message.text,
return await callback.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u25B6\uFE0F",
"⏸️",
callback_data="pause_or_resume",
),
InlineKeyboardButton("\u23ED\uFE0F", callback_data="next"),
InlineKeyboardButton("⏭️", callback_data="next"),
],
]
),
)
await VOICE_CHATS[callback.message.chat.id].set_pause(True)
return await callback.edit_message_text(
callback.message.text,
return await callback.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
"▶️",
callback_data="pause_or_resume",
),
InlineKeyboardButton("\u25B6\uFE0F", callback_data="next"),
InlineKeyboardButton("▶️", callback_data="next"),
],
]
),
Expand Down
10 changes: 5 additions & 5 deletions bot/commands/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"⏸️",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F",
"⏭️",
callback_data="next",
),
],
Expand Down Expand Up @@ -162,7 +162,7 @@ async def _(client: Client, message: Message):
position=position,
)
return await msg.edit(
f"__Added to queue at {position} \n\n Title: [{name}]({url})\nDuration: {duration} Minutes\n Requested by:__ [{data['first_name']}]({data['mention']})",
f"__Added to queue at {position} \n\n Title: [{name}]({url_mention})\nDuration: {duration} Minutes\n Requested by:__ [{data['first_name']}]({data['mention']})",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("cʟᴏꜱᴇ", callback_data="close")]]
),
Expand Down Expand Up @@ -190,13 +190,13 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F",
"⏭️",
callback_data="next",
),
],
Expand Down
14 changes: 6 additions & 8 deletions bot/commands/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F", callback_data="next"
),
InlineKeyboardButton("⏭️", callback_data="next"),
],
],
),
Expand Down Expand Up @@ -148,13 +146,13 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F",
"⏭️",
callback_data="next",
),
],
Expand Down Expand Up @@ -210,12 +208,12 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton("", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton("\u23ED\uFE0F", callback_data="next"),
InlineKeyboardButton("⏭️", callback_data="next"),
],
],
),
Expand Down
1 change: 1 addition & 0 deletions bot/commands/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
remove_queue,
)


@kreacher.on_message(filters.regex(pattern="^[!?/]streaming"))
@only_grps_chnns
async def _(client: Client, message: Message):
Expand Down
20 changes: 10 additions & 10 deletions bot/decorators/only_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ def only_managers(func):
@functools.wraps(func)
async def _(client: Client, anything):
try:
if isinstance(any, Message):
if not any.chat.type == ChatType.PRIVATE:
if isinstance(anything, Message):
if not anything.chat.type == ChatType.PRIVATE:
user = await client.get_chat_member(
anything.chat.id, anything.from_user.id
)
if not user.privileges:
return await any.reply(
return await anything.reply(
"**__You are not my master, you do not order me what to do, bye__** \U0001f621"
)

elif isinstance(any, CallbackQuery):
if not any.message.chat.type == ChatType.PRIVATE:
elif isinstance(anything, CallbackQuery):
if not anything.message.chat.type == ChatType.PRIVATE:
user = await client.get_chat_member(
any.message.chat.id, any.message.from_user.id
anything.message.chat.id, anything.message.from_user.id
)
if not user.privileges:
return await client.answer_callback_query(
any.id,
anything.id,
text="**__You are not my master or played user, you cannot execute this action.__** \U0001f621",
show_alert=True,
)
await func(client, any)
except Exception as e:
logging.error(e)
await func(client, anything)
except Exception as err:
logging.error(err)

return _

0 comments on commit 02abb4a

Please sign in to comment.