File size: 7,190 Bytes
a8e9b84 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
import asyncio
from pyrogram.enums import ChatMemberStatus
from pyrogram.errors import (
ChatAdminRequired,
InviteRequestSent,
UserAlreadyParticipant,
UserNotParticipant,
)
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from DragMusic import YouTube, app
from DragMusic.misc import SUDOERS
from DragMusic.utils.database import (
get_assistant,
get_cmode,
get_lang,
get_playmode,
get_playtype,
is_active_chat,
is_maintenance,
)
from DragMusic.utils.inline import botplaylist_markup
from config import PLAYLIST_IMG_URL, SUPPORT_CHAT, adminlist
from strings import get_string
links = {}
def PlayWrapper(command):
async def wrapper(client, message):
language = await get_lang(message.chat.id)
_ = get_string(language)
if message.sender_chat:
upl = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="ʜᴏᴡ ᴛᴏ ғɪx ?",
callback_data="DragmousAdmin",
),
]
]
)
return await message.reply_text(_["general_3"], reply_markup=upl)
if await is_maintenance() is False:
if message.from_user.id not in SUDOERS:
return await message.reply_text(
text=f"{app.mention} ɪs ᴜɴᴅᴇʀ ᴍᴀɪɴᴛᴇɴᴀɴᴄᴇ, ᴠɪsɪᴛ <a href={SUPPORT_CHAT}>sᴜᴘᴘᴏʀᴛ ᴄʜᴀᴛ</a> ғᴏʀ ᴋɴᴏᴡɪɴɢ ᴛʜᴇ ʀᴇᴀsᴏɴ.",
disable_web_page_preview=True,
)
try:
await message.delete()
except:
pass
audio_telegram = (
(message.reply_to_message.audio or message.reply_to_message.voice)
if message.reply_to_message
else None
)
video_telegram = (
(message.reply_to_message.video or message.reply_to_message.document)
if message.reply_to_message
else None
)
url = await YouTube.url(message)
if audio_telegram is None and video_telegram is None and url is None:
if len(message.command) < 2:
if "stream" in message.command:
return await message.reply_text(_["str_1"])
buttons = botplaylist_markup(_)
return await message.reply_photo(
photo=PLAYLIST_IMG_URL,
caption=_["play_18"],
reply_markup=InlineKeyboardMarkup(buttons),
)
if message.command[0][0] == "c":
chat_id = await get_cmode(message.chat.id)
if chat_id is None:
return await message.reply_text(_["setting_7"])
try:
chat = await app.get_chat(chat_id)
except:
return await message.reply_text(_["cplay_4"])
channel = chat.title
else:
chat_id = message.chat.id
channel = None
playmode = await get_playmode(message.chat.id)
playty = await get_playtype(message.chat.id)
if playty != "Everyone":
if message.from_user.id not in SUDOERS:
admins = adminlist.get(message.chat.id)
if not admins:
return await message.reply_text(_["admin_13"])
else:
if message.from_user.id not in admins:
return await message.reply_text(_["play_4"])
if message.command[0][0] == "v":
video = True
else:
if "-v" in message.text:
video = True
else:
video = True if message.command[0][1] == "v" else None
if message.command[0][-1] == "e":
if not await is_active_chat(chat_id):
return await message.reply_text(_["play_16"])
fplay = True
else:
fplay = None
if not await is_active_chat(chat_id):
userbot = await get_assistant(chat_id)
try:
try:
get = await app.get_chat_member(chat_id, userbot.id)
except ChatAdminRequired:
return await message.reply_text(_["call_1"])
if (
get.status == ChatMemberStatus.BANNED
or get.status == ChatMemberStatus.RESTRICTED
):
return await message.reply_text(
_["call_2"].format(
app.mention, userbot.id, userbot.name, userbot.username
)
)
except UserNotParticipant:
if chat_id in links:
invitelink = links[chat_id]
else:
if message.chat.username:
invitelink = message.chat.username
try:
await userbot.resolve_peer(invitelink)
except:
pass
else:
try:
invitelink = await app.export_chat_invite_link(chat_id)
except ChatAdminRequired:
return await message.reply_text(_["call_1"])
except Exception as e:
return await message.reply_text(
_["call_3"].format(app.mention, type(e).__name__)
)
if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
myu = await message.reply_text(_["call_4"].format(app.mention))
try:
await asyncio.sleep(1)
await userbot.join_chat(invitelink)
except InviteRequestSent:
try:
await app.approve_chat_join_request(chat_id, userbot.id)
except Exception as e:
return await message.reply_text(
_["call_3"].format(app.mention, type(e).__name__)
)
await asyncio.sleep(3)
await myu.edit(_["call_5"].format(app.mention))
except UserAlreadyParticipant:
pass
except Exception as e:
return await message.reply_text(
_["call_3"].format(app.mention, type(e).__name__)
)
links[chat_id] = invitelink
try:
await userbot.resolve_peer(chat_id)
except:
pass
return await command(
client,
message,
_,
chat_id,
video,
channel,
playmode,
url,
fplay,
)
return wrapper
|