some fixes

This commit is contained in:
levina 2022-01-21 01:01:52 +07:00 committed by GitHub
parent 0594b06e4f
commit fe95837c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,34 +9,25 @@ from driver.decorators import authorized_users_only, sudo_users_only
@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
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
invitelink = await c.export_chat_invite_link(chat_id)
if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
return await user.send_message(chat_id, "✅ userbot entered chat")
await user.join_chat(invitelink)
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")
return await user.send_message(chat_id, "✅ userbot already in chat")
@Client.on_message(command(["userbotleave",
f"leave@{BOT_USERNAME}"]) & filters.group & ~filters.edited
@Client.on_message(
command(["userbotleave", f"userbotleave@{BOT_USERNAME}"]) & filters.group & ~filters.edited
)
@authorized_users_only
async def leave_chat(_, m: Message):