Skip to content

Commit

Permalink
Update callbacks.py and help.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Aug 6, 2023
1 parent 0ea41d2 commit a25b520
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 40 deletions.
60 changes: 37 additions & 23 deletions tlg_bot/kreacher/plugins/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from asyncio import sleep
from kreacher import kreacher
from kreacher import config, kreacher
from kreacher.dicts.dicts import QUEUE, VOICE_CHATS
from telethon import events, Button
from kreacher.helpers.queues_handler import next_item, skip_current
Expand All @@ -16,30 +16,32 @@ async def _(event):
chat = await event.get_chat()
if VOICE_CHATS[chat.id].is_video_paused:
await VOICE_CHATS[chat.id].set_pause(True)
await kreacher.edit_message(event.sender_id, event.message_id,
"\U00002378 <i>Started Video Streaming!</i>",
file=thumb,
buttons=[
[Button.inline("\U000023ee ʙᴀᴄᴋ", data="back_callback"),
Button.inline("\U00002378 ᴘᴀᴜsᴇ", data="pause_or_resume_callback"),
Button.inline("\U000023ED ɴᴇxᴛ", data="next_callback")
],
[Button.inline("cʟᴏꜱᴇ", data="cls")],
],
parse_mode="HTML")
await event.edit("\U00002378 <i>Started Video Streaming!</i>",
file=thumb,
buttons=[
[Button.inline("\U000023ee ʙᴀᴄᴋ", data="back_callback"),
Button.inline("\U00002378 ᴘᴀᴜsᴇ",
data="pause_or_resume_callback"),
Button.inline("\U000023ED ɴᴇxᴛ",
data="next_callback")
],
[Button.inline("cʟᴏꜱᴇ", data="cls")],
],
parse_mode="HTML")
return await sleep(3)
await VOICE_CHATS[chat.id].set_pause(True)
await kreacher.edit_message(event.sender_id, event.message_id,
"\U00002378 <i>Started Video Streaming!</i>",
file=thumb,
buttons=[
[Button.inline("\U000023ee ʙᴀᴄᴋ", data="back_callback"),
Button.inline("\U0001F501 ʀᴇsᴜᴍᴇ", data="pause_or_resume_callback"),
Button.inline("\U000023ED ɴᴇxᴛ", data="next_callback")
],
[Button.inline("cʟᴏꜱᴇ", data="cls")],
],
parse_mode="HTML")
await event.edit("\U00002378 <i>Started Video Streaming!</i>",
file=thumb,
buttons=[
[Button.inline("\U000023ee ʙᴀᴄᴋ", data="back_callback"),
Button.inline("\U0001F501 ʀᴇsᴜᴍᴇ",
data="pause_or_resume_callback"),
Button.inline("\U000023ED ɴᴇxᴛ",
data="next_callback")
],
[Button.inline("cʟᴏꜱᴇ", data="cls")],
],
parse_mode="HTML")
return await sleep(3)


Expand Down Expand Up @@ -87,3 +89,15 @@ async def _(event):
await VOICE_CHATS[chat.id].stop()
VOICE_CHATS.pop(chat.id)
return await sleep(3)


@kreacher.on(events.callbackquery.CallbackQuery(data="help"))
async def _(event):
if config.MANAGEMENT_MODE == "ENABLE":
return
await event.edit("ᴄʜᴏᴏsᴇ ᴛʜᴇ ᴄᴀᴛᴇɢᴏʀʏ ғᴏʀ ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴɴᴀ ɢᴇᴛ ʜᴇʟᴩ\n\nᴀʟʟ ᴄᴏᴍᴍᴀɴᴅs ᴄᴀɴ ʙᴇ ᴜsᴇᴅ ᴡɪᴛʜ : `/`",
buttons=[
[Button.inline("ᴀᴅᴍɪɴ", data="admin"),
Button.inline("ᴘʟᴀʏ", data="play")],
[Button.inline("ʜᴏᴍᴇ", data="start")],
])
27 changes: 10 additions & 17 deletions tlg_bot/kreacher/plugins/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
from kreacher import kreacher, config


btn = [
[Button.inline("ᴀᴅᴍɪɴ", data="admin"), Button.inline("ᴘʟᴀʏ", data="play")],
[Button.inline("ʜᴏᴍᴇ", data="start")],
]

HELP_TEXT = "ᴄʜᴏᴏsᴇ ᴛʜᴇ ᴄᴀᴛᴇɢᴏʀʏ ғᴏʀ ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴɴᴀ ɢᴇᴛ ʜᴇʟᴩ\n\nᴀʟʟ ᴄᴏᴍᴍᴀɴᴅs ᴄᴀɴ ʙᴇ ᴜsᴇᴅ ᴡɪᴛʜ : `/`"


@kreacher.on(events.NewMessage(pattern="[!?/]help"))
async def help(event):
if config.MANAGEMENT_MODE == "ENABLE":
Expand All @@ -28,18 +20,19 @@ async def help(event):
)
return

await event.reply(HELP_TEXT, buttons=btn)
await event.reply("ᴄʜᴏᴏsᴇ ᴛʜᴇ ᴄᴀᴛᴇɢᴏʀʏ ғᴏʀ ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴɴᴀ ɢᴇᴛ ʜᴇʟᴩ\n\nᴀʟʟ ᴄᴏᴍᴍᴀɴᴅs ᴄᴀɴ ʙᴇ ᴜsᴇᴅ ᴡɪᴛʜ : `/`", buttons=[
[Button.inline("ᴀᴅᴍɪɴ", data="admin"),
Button.inline("ᴘʟᴀʏ", data="play")],
[Button.inline("ʜᴏᴍᴇ", data="start")],
])


@kreacher.on(events.NewMessage(pattern="^/start help"))
async def _(event):
if config.MANAGEMENT_MODE == "ENABLE":
return
await event.reply(HELP_TEXT, buttons=btn)


@kreacher.on(events.callbackquery.CallbackQuery(data="help"))
async def _(event):
if config.MANAGEMENT_MODE == "ENABLE":
return
await event.edit(HELP_TEXT, buttons=btn)
await event.reply("ᴄʜᴏᴏsᴇ ᴛʜᴇ ᴄᴀᴛᴇɢᴏʀʏ ғᴏʀ ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴɴᴀ ɢᴇᴛ ʜᴇʟᴩ\n\nᴀʟʟ ᴄᴏᴍᴍᴀɴᴅs ᴄᴀɴ ʙᴇ ᴜsᴇᴅ ᴡɪᴛʜ : `/`", buttons=[
[Button.inline("ᴀᴅᴍɪɴ", data="admin"),
Button.inline("ᴘʟᴀʏ", data="play")],
[Button.inline("ʜᴏᴍᴇ", data="start")],
])

0 comments on commit a25b520

Please sign in to comment.