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( @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):