some fixes
This commit is contained in:
parent
0594b06e4f
commit
fe95837c7f
@ -9,34 +9,25 @@ from driver.decorators import authorized_users_only, sudo_users_only
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
command(["userbotjoin", f"userbotjoin@{BOT_USERNAME}"]) & ~filters.private & ~filters.bot
|
command(["userbotjoin", f"userbotjoin@{BOT_USERNAME}"]) & ~filters.group & ~filters.edited
|
||||||
)
|
)
|
||||||
@authorized_users_only
|
@authorized_users_only
|
||||||
async def join_chat(c: Client, m: Message):
|
async def join_chat(c: Client, m: Message):
|
||||||
chat_id = m.chat.id
|
chat_id = m.chat.id
|
||||||
try:
|
try:
|
||||||
invite_link = await m.chat.export_invite_link()
|
invitelink = await c.export_chat_invite_link(chat_id)
|
||||||
if "+" in invite_link:
|
if invitelink.startswith("https://t.me/+"):
|
||||||
link_hash = (invite_link.replace("+", "")).split("t.me/")[1]
|
invitelink = invitelink.replace(
|
||||||
await user.join_chat(f"https://t.me/joinchat/{link_hash}")
|
"https://t.me/+", "https://t.me/joinchat/"
|
||||||
await m.chat.promote_member(
|
|
||||||
(await user.get_me()).id,
|
|
||||||
can_manage_voice_chats=True
|
|
||||||
)
|
|
||||||
return await user.send_message(chat_id, "✅ userbot entered chat")
|
|
||||||
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, "✅ userbot already in chat")
|
await user.join_chat(invitelink)
|
||||||
|
await user.send_message(chat_id, "✅ userbot entered chat")
|
||||||
|
except UserAlreadyParticipant:
|
||||||
return await user.send_message(chat_id, "✅ userbot already in chat")
|
return await user.send_message(chat_id, "✅ userbot already in chat")
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["userbotleave",
|
@Client.on_message(
|
||||||
f"leave@{BOT_USERNAME}"]) & filters.group & ~filters.edited
|
command(["userbotleave", f"userbotleave@{BOT_USERNAME}"]) & filters.group & ~filters.edited
|
||||||
)
|
)
|
||||||
@authorized_users_only
|
@authorized_users_only
|
||||||
async def leave_chat(_, m: Message):
|
async def leave_chat(_, m: Message):
|
||||||
|
Loading…
Reference in New Issue
Block a user