Skip to content

Commit

Permalink
refactor inline and change inline media
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisan09 committed May 2, 2023
1 parent f22804e commit b56ece0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 34 deletions.
54 changes: 21 additions & 33 deletions helper/inlinevc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .function import vc_player

vcimg = "https://github.com/TgCatUB/CatVCPlayer/raw/beta/resources/vcimg.jpg"
vcimg = "https://github.com/TgCatUB/CatVCPlayer/raw/beta/resources/vcfileW.mp4"

buttons = (
[
Expand Down Expand Up @@ -47,7 +47,7 @@
async def joinvc(event):
chat = event.chat_id
if vc_player.app.active_calls:
return await event.answer(f"You have already Joined in {vc_player.CHAT_NAME}")
return await event.answer(f"You have already Joined in: {vc_player.CHAT_NAME}")

try:
vc_chat = await catub.get_entity(chat)
Expand All @@ -58,7 +58,7 @@ async def joinvc(event):
return await event.answer("Voice Chats are not available in Private Chats")

out = await vc_player.join_vc(vc_chat, False)
await event.answer(out, alert=True)
await event.answer(out)


@catub.tgbot.on(CallbackQuery(data=re.compile(r"^leavevc$")))
Expand Down Expand Up @@ -196,13 +196,8 @@ async def repeatvc(event):


# SETTINGS BUTTONS
@catub.tgbot.on(CallbackQuery(data=re.compile(r"^settingvc$")))
@check_owner
async def settingvc(event):
abtntext = "🏢 Public" if vc_player.PUBLICMODE else "🏠 Private"
bbtntext = "✅ Enabled" if vc_player.BOTMODE else "❌ Disabled"
cbtntext = "✅ Enabled" if vc_player.CLEANMODE else "❌ Disabled"
buttons = [
def fetch_button_layout(abtntext, bbtntext, cbtntext):
return [
[
Button.inline("🎩 Auth Mode", data="amodeinfo"),
Button.inline(abtntext, data="amode"),
Expand All @@ -220,16 +215,27 @@ async def settingvc(event):
Button.inline("🗑 close", data="vc_close"),
],
]

def fetch_button_text():
abtntext = "🏢 Public" if vc_player.PUBLICMODE else "🏠 Private"
bbtntext = "✅ Enabled" if vc_player.BOTMODE else "❌ Disabled"
cbtntext = "✅ Enabled" if vc_player.CLEANMODE else "❌ Disabled"
return abtntext,bbtntext,cbtntext


@catub.tgbot.on(CallbackQuery(data=re.compile(r"^settingvc$")))
@check_owner
async def settingvc(event):
abtntext, bbtntext, cbtntext = fetch_button_text()
buttons = fetch_button_layout(abtntext, bbtntext, cbtntext)
await event.edit("** | Settings | **", buttons=buttons)


@catub.tgbot.on(CallbackQuery(pattern="^(a|b|c)mode$"))
@check_owner
async def vc(event):
mode = (event.pattern_match.group(1)).decode("UTF-8")
abtntext = "🏢 Public" if vc_player.PUBLICMODE else "🏠 Private"
bbtntext = "✅ Enabled" if vc_player.BOTMODE else "❌ Disabled"
cbtntext = "✅ Enabled" if vc_player.CLEANMODE else "❌ Disabled"
abtntext, bbtntext, cbtntext = fetch_button_text()
if mode == "a":
vc_player.PUBLICMODE = not vc_player.PUBLICMODE
abtntext = "🏢 Public" if vc_player.PUBLICMODE else "🏠 Private"
Expand All @@ -240,25 +246,7 @@ async def vc(event):
vc_player.CLEANMODE = not vc_player.CLEANMODE
cbtntext = "✅ Enabled" if vc_player.CLEANMODE else "❌ Disabled"

buttons = [
[
Button.inline("🎩 Auth Mode", data="amodeinfo"),
Button.inline(abtntext, data="amode"),
],
[
Button.inline("🤖 Bot Mode", data="bmodeinfo"),
Button.inline(bbtntext, data="bmode"),
],
[
Button.inline("🗑 Clean Mode", data="cmodeinfo"),
Button.inline(cbtntext, data="cmode"),
],
[
Button.inline("⬅️ Back", data="backvc"),
Button.inline("🗑 close", data="vc_close"),
],
]

buttons = fetch_button_layout(abtntext, bbtntext, cbtntext)
await event.edit("** | Settings | **", buttons=buttons)


Expand All @@ -272,7 +260,7 @@ async def vc(event):
text = "⁉️ What is This?\n\nWhen activated, Your assistant responds to the commands with interactive buttons"
elif mode == "c":
text = "⁉️ What is This?\n\nWhen activated, Bot will delete its message after leaving vc to make your chat clean and clear."
await event.answer(text, cache_time=0, alert=True)
await event.answer(text, alert=True)


# COMMON BUTTONS
Expand Down
4 changes: 3 additions & 1 deletion helper/vcp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
from telethon import functions
from telethon.errors import ChatAdminRequiredError
from userbot.helpers.functions import get_ytthumb, yt_search
from userbot.core.logger import logging
from userbot.helpers.utils import _catutils
from yt_dlp import YoutubeDL

from .stream_helper import Stream, check_url, video_dl, yt_regex

LOGS = logging.getLogger(__name__)

class CatVC:
def __init__(self, client) -> None:
Expand Down Expand Up @@ -189,7 +191,7 @@ async def play_song(
msg = f"**🎧 Playing:** [{title}]({url})\n"
msg += f"**⏳ Duration:** `{duration}`\n"
msg += f"**💭 Chat:** `{self.CHAT_NAME}`"
print(playable)
LOGS.info(playable)
if self.PLAYING and not force:
self.PLAYLIST.append(
{
Expand Down
Binary file added resources/vcfileUW.mp4
Binary file not shown.
Binary file added resources/vcfileW.mp4
Binary file not shown.
Binary file removed resources/vcimg.jpg
Binary file not shown.
1 change: 1 addition & 0 deletions vcplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ async def play_audio(event):
input_str = input_str.replace("-f", "").strip()
forced = True
LOGS.info("Playing Audio..")
reply = await event.get_reply_message()
event = await vc_reply(event, "`Searching...`", edit=True)
if reply and reply.media and not reply.photo:
inputstr = await tg_dl(
Expand Down

0 comments on commit b56ece0

Please sign in to comment.