forked from AnonymousR1025/FallenMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assistant.py
34 lines (32 loc) · 1.56 KB
/
assistant.py
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
import asyncio
from pyrogram.types import Message
from pyrogram import Client, filters
from helpers.filters import command, other_filters
from pyrogram.errors import UserAlreadyParticipant
from helpers.decorators import authorized_users_only
from callsmusic.callsmusic import client as user
@Client.on_message(
command(["join", "assistant", " userbotjoin"]) & ~filters.private & ~filters.bot
)
@authorized_users_only
async def join_chat(c: Client, m: Message):
chat_id = m.chat.id
try:
invite_link = await m.chat.export_invite_link()
if "+" in invite_link:
link_hash = (invite_link.replace("+", "")).split("t.me/")[1]
await user.join_chat(f"https://t.me/joinchat/{link_hash}")
await m.chat.promote_member(
(await user.get_me()).id,
can_manage_voice_chats=True
)
return await user.send_message(chat_id, "🙂ᴀssɪsᴛᴀɴᴛ sᴜᴄᴄᴇssꜰᴜʟʟʏ ᴊᴏɪɴᴇᴅ ᴛʜᴇ ᴄʜᴀᴛ ʙᴀʙʏ.")
except UserAlreadyParticipant:
admin = await m.chat.get_member((await user.get_me()).id)
if not admin.can_manage_voice_chats:
await m.chat.promote_member(
(await user.get_me()).id,
can_manage_voice_chats=True
)
return await user.send_message(chat_id, "🙂ᴀssɪsᴛᴀɴᴛ ᴀʟʀᴇᴀᴅʏ ᴊᴏɪɴᴇᴅ ᴛʜᴇ ᴄʜᴀᴛ ʙᴀʙʏ.")
return await user.send_message(chat_id, "🙂ᴀssɪsᴛᴀɴᴛ ᴀʟʀᴇᴀᴅʏ ᴊᴏɪɴᴇᴅ ᴛʜᴇ ᴄʜᴀᴛ ʙᴀʙʏ.")