Skip to content

Commit

Permalink
chore: updating callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 11, 2023
1 parent 02abb4a commit d205567
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
8 changes: 5 additions & 3 deletions bot/callbacks/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup

from bot import kreacher, VOICE_CHATS
from bot.decorators.only_managers import only_managers
from bot.decorators.only_managers import only_admins_or_requester
from bot.helpers.queues import (
get_queues,
next_in_queue,
Expand All @@ -18,7 +18,7 @@


@kreacher.on_callback_query(filters.regex("pause_or_resume"))
@only_managers
@only_admins_or_requester
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)
Expand All @@ -33,6 +33,7 @@ async def _(client: Client, callback: CallbackQuery):
),
InlineKeyboardButton("⏭️", callback_data="next"),
],
InlineKeyboardButton("sᴛᴏᴘ ᴀʟʟ", callback_data="quit"),
]
),
)
Expand All @@ -46,8 +47,9 @@ async def _(client: Client, callback: CallbackQuery):
"▶️",
callback_data="pause_or_resume",
),
InlineKeyboardButton("️", callback_data="next"),
InlineKeyboardButton("️", callback_data="next"),
],
InlineKeyboardButton("sᴛᴏᴘ ᴀʟʟ", callback_data="quit"),
]
),
)
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from pyrogram import filters, Client
from bot import tgcalls, kreacher, VOICE_CHATS
from bot.decorators.only_admins import only_admins
from bot.decorators.only_grps_chnns import only_grps_chnns
from bot.decorators.only_groups_or_channels import only_groups_or_channels


@kreacher.on_message(filters.regex(pattern="^[!?/]join"))
@only_grps_chnns
@only_groups_or_channels
@only_admins
async def _(client: Client, message: Message):
try:
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from bot import kreacher, VOICE_CHATS
from bot.helpers.queues import remove_queue
from bot.decorators.only_admins import only_admins
from bot.decorators.only_grps_chnns import only_grps_chnns
from bot.decorators.only_groups_or_channels import only_groups_or_channels


@kreacher.on_message(filters.regex(pattern="^[!?/]leave"))
@only_grps_chnns
@only_groups_or_channels
@only_admins
async def _(client: Client, message: Message):
try:
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/play_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bot.helpers.tts import tts
from bot.helpers.progress import progress
from bot import kreacher, tgcalls, VOICE_CHATS
from bot.decorators.only_grps_chnns import only_grps_chnns
from bot.decorators.only_groups_or_channels import only_groups_or_channels
from bot.helpers.queues import (
add_or_create_queue,
get_queues,
Expand All @@ -26,7 +26,7 @@


@kreacher.on_message(filters.regex(pattern="^[!?/]play_book"))
@only_grps_chnns
@only_groups_or_channels
async def _(client: Client, message: Message):
text = ""
h = _HTMLFilter()
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from bot.helpers.progress import progress
from bot.scrapers.images import ImageScraper
from bot import assistant, kreacher, tgcalls, VOICE_CHATS
from bot.decorators.only_grps_chnns import only_grps_chnns
from bot.decorators.only_groups_or_channels import only_groups_or_channels
from bot.helpers.queues import (
remove_queue,
)


@kreacher.on_message(filters.regex(pattern="^[!?/]streaming"))
@only_grps_chnns
@only_groups_or_channels
async def _(client: Client, message: Message):
results = []
try:
Expand Down
2 changes: 1 addition & 1 deletion bot/decorators/only_admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def only_admins(func):
"""Allow only admins to use any command."""
"""Allow only admins to use any command"""

@functools.wraps(func)
async def _(client: Client, message: Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pyrogram.enums.chat_type import ChatType


def only_managers(func):
"""Allow only admins and user requester to use any command."""
def only_admin_and_requester(func):
"""Allow only admins and user requester to use any command"""

@functools.wraps(func)
async def _(client: Client, anything):
Expand Down
2 changes: 1 addition & 1 deletion bot/decorators/only_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def only_dev(func):
"""Allow only dev to use any command."""
"""Allow only dev to use any command"""

@functools.wraps(func)
async def _(client: Client, message: Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pyrogram.enums.chat_type import ChatType


def only_grps_chnns(func):
"""Command can be used in groups and channels only."""
def only_groups_or_channels(func):
"""Command can be used in groups and channels only"""

@functools.wraps(func)
async def _(client: Client, message: Message):
Expand Down

0 comments on commit d205567

Please sign in to comment.