Spaces:
Paused
Paused
| # | |
| # Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >. | |
| # | |
| # This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project, | |
| # and is released under the "GNU v3.0 License Agreement". | |
| # Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE > | |
| # | |
| # All rights reserved. | |
| import random | |
| import string | |
| from ast import ExceptHandler | |
| import traceback | |
| from pyrogram import filters | |
| from pyrogram import enums | |
| from pyrogram.types import (InlineKeyboardMarkup,InlineKeyboardButton,WebAppInfo, InputMediaPhoto,KeyboardButton,ReplyKeyboardMarkup, | |
| Message) | |
| from pytgcalls.exceptions import NoActiveGroupCall | |
| #from pyrogram.raw.types import UpdateWebViewResultSent, UpdateWebPage | |
| from pyrogram.raw import functions, types | |
| from pytube import extract | |
| import config | |
| import json | |
| from config import BANNED_USERS, lyrical, MEMBERS_GROUPS,OWNER_ID | |
| from strings import get_command | |
| from pyrogram.enums import ParseMode, ChatType | |
| from YukkiMusic import (Apple, Resso, SoundCloud, Spotify, Telegram, | |
| YouTube, app) | |
| from strings import get_string | |
| from YukkiMusic.utils.database import (get_cmode, get_lang, | |
| get_playmode, get_playtype, | |
| is_active_chat, | |
| is_commanddelete_on, | |
| is_served_private_chat) | |
| from YukkiMusic.core.call import Yukki | |
| from YukkiMusic.utils import seconds_to_min, time_to_seconds | |
| from YukkiMusic.utils.channelplay import get_channeplayCB | |
| from YukkiMusic.utils.database import is_video_allowed | |
| from YukkiMusic.utils.decorators.language import languageCB | |
| from YukkiMusic.utils.decorators.play import PlayWrapper | |
| from YukkiMusic.utils.formatters import formats | |
| from YukkiMusic.utils.inline.play import (livestream_markup, | |
| playlist_markup, | |
| slider_markup, track_markup) | |
| from YukkiMusic.utils.inline.playlist import botplaylist_markup | |
| from YukkiMusic.utils.logger import play_logs | |
| from YukkiMusic.utils.stream.stream import stream | |
| #from .Chat_Selecter import chat_selecter | |
| # Define GROUP as a global variable | |
| GROUP =int(-1001847684787) # Declare GROUP as global | |
| async def add_user(client, message): | |
| # Print and debug | |
| print(MEMBERS_GROUPS, type(MEMBERS_GROUPS)) | |
| # Send usage message | |
| await message.reply_text(f"**Usage:** 1. Nalle Berozgar \n 2. Only Logs [ Updates Group ] \n 3. Me & Her \n <code> /select_group <1,2,3> </code>") | |
| # Check if the command is valid | |
| if len(message.command) == 1: | |
| return await message.reply_text(f"**Wrong One Follow Usage:** 1. Nalle Berozgar \n 2. Only Logs [ Updates Group ] \n 3. Me & Her \n <code> /select_group <0,1,2> </code>") | |
| try: | |
| user_id = int(message.command[1]) | |
| except (ValueError, UnboundLocalError): | |
| return await message.reply_text(f"**Usage:**\n <code> /select_group <1,2,3> </code> \n ValueError or UnboundLocalError") | |
| # Convert MEMBERS_GROUPS string to list of integers | |
| number_strings = MEMBERS_GROUPS.split() | |
| number_list = [int(num) for num in number_strings] | |
| # Debug information | |
| print(user_id, type(user_id), number_list[int(user_id)], type(number_list[user_id])) | |
| global GROUP | |
| # Update the global GROUP variable | |
| GROUP = number_list[user_id] | |
| # Print the updated GROUP | |
| print(GROUP) | |
| # Confirm the update | |
| await message.reply_text(f"**Group Set Successfully**") | |
| # Command | |
| WEB_APP = get_command("WEB_APP_COMMAND") | |
| async def send_webapp_button(client, message: Message): | |
| custom_keyboard = ReplyKeyboardMarkup( | |
| [ | |
| [KeyboardButton("Open WebApp", web_app=WebAppInfo(url="https://privateone-onesvc-bot.hf.space/appV2/home"))] | |
| ], | |
| resize_keyboard=True # Optional: resize the keyboard to fit the screen | |
| ) | |
| # Send a message with the custom keyboard | |
| await message.reply_text("Click the button below to open the WebApp:", reply_markup=custom_keyboard) | |
| async def raw_update_handler(client, message: Message): | |
| if message.web_app_data: | |
| # Handling WebApp data | |
| web_app_data = str(message.web_app_data.data) | |
| split_data=web_app_data.split(' ') | |
| id=split_data[1] | |
| id=id.replace('"', '') | |
| id=id.replace("'", "") | |
| #split_data = web_app_data.split(':') | |
| print(f"WebApp data received: {web_app_data},{id}") | |
| if message.chat.type == ChatType.PRIVATE: | |
| user_idx = message.from_user.id | |
| else: | |
| user_idx = message.chat.id | |
| # You can process the web app data here | |
| #chat_id = message.peer.user_id if hasattr(message.peer, "user_id") else update.peer.chat_id | |
| language = await get_lang(message.chat.id) | |
| _ = get_string(language) | |
| user_id = message.from_user.id | |
| user_name = message.from_user.first_name | |
| global GROUP | |
| print(GROUP) | |
| chat_id = GROUP | |
| #video_url=f'https://www.youtube.com/watch?v={id}' | |
| details, track_id = await YouTube.track(id,True) | |
| streamtype = "nodownload" | |
| img = details["thumb"] | |
| cap = _["play_19"].format( | |
| details["title"], | |
| details["duration_min"], | |
| ) | |
| check=split_data[0].replace('"', '') | |
| check=check.replace("'",'') | |
| check=check.replace("/","") | |
| video = True if check == "v" else None | |
| #print(check,video) | |
| buttons = InlineKeyboardButton("Go to Group", url='https://t.me/+MeO0kQmZ5ddiYmZl') | |
| await message.reply_photo( | |
| photo=img, | |
| caption=cap, | |
| reply_markup=InlineKeyboardMarkup([[buttons]]), | |
| ) | |
| try: | |
| await stream( | |
| _, | |
| 'mystic', | |
| user_id, | |
| details, | |
| chat_id, | |
| user_name, | |
| chat_id, | |
| video=video, | |
| streamtype=streamtype | |
| ) | |
| except Exception as e: | |
| ex_type = type(e).__name__ | |
| err = ( | |
| e | |
| if ex_type == "AssistantErr" | |
| else _["general_3"].format(ex_type) | |
| ) | |
| return await client.send_message(user_idx, f"Received err: {err}") | |
| await play_logs(message, streamtype=streamtype) |