some fixes

This commit is contained in:
levina 2022-01-18 19:59:57 +07:00 committed by GitHub
parent 32e1af6fa2
commit 80d5fafb9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,51 +63,43 @@ async def play(c: Client, m: Message):
a = await c.get_chat_member(chat_id, aing.id) a = await c.get_chat_member(chat_id, aing.id)
if a.status != "administrator": if a.status != "administrator":
await m.reply_text( await m.reply_text(
f"💡 To use me, I need to be an **Administrator** with the following **permissions**:\n\n» ❌ __Delete messages__\n» ❌ __Add users__\n» ❌ __Add new Admins__\n» ❌ __Manage video chat__\n\nData is **updated** automatically after you **promote me**" f"💡 To use me, I need to be an **Administrator** with the following **permissions**:\n\n» ❌ __Delete messages__\n» ❌ __Invite users__\n» ❌ __Manage video chat__\n\nOnce done, type /reload"
) )
return return
if not a.can_manage_voice_chats: if not a.can_manage_voice_chats:
await m.reply_text( await m.reply_text(
"missing required permission:" + "\n\n» ❌ __Manage video chat__" "💡 To use me, Give me the following permission below:"
) + "\n\n» ❌ __Manage video chat__\n\nOnce done, try again.")
return return
if not a.can_delete_messages: if not a.can_delete_messages:
await m.reply_text( await m.reply_text(
"missing required permission:" + "\n\n» ❌ __Delete messages__" "💡 To use me, Give me the following permission below:"
) + "\n\n» ❌ __Delete messages__\n\nOnce done, try again.")
return return
if not a.can_invite_users: if not a.can_invite_users:
await m.reply_text("missing required permission:" + "\n\n» ❌ __Add users__") await m.reply_text(
return "💡 To use me, Give me the following permission below:"
if not a.can_promote_members: + "\n\n» ❌ __Add users__\n\nOnce done, try again.")
await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__")
return return
try: try:
ubot = (await user.get_me()).id ubot = (await user.get_me()).id
b = await c.get_chat_member(chat_id, ubot) b = await c.get_chat_member(m.chat.id, ubot)
if b.status == "kicked": if b.status == "kicked":
await c.unban_chat_member(chat_id, ubot) await c.unban_chat_member(m.chat.id, ubot)
invitelink = await c.export_chat_invite_link(chat_id) invitelink = await c.export_chat_invite_link(m.chat.id)
if invitelink.startswith("https://t.me/+"): if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace( invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/" "https://t.me/+", "https://t.me/joinchat/"
) )
await user.join_chat(invitelink) await ubot.join_chat(invitelink)
await m.chat.promote_member(
ubot, can_manage_voice_chats=True
)
except UserNotParticipant: except UserNotParticipant:
try: try:
ubot = (await user.get_me()).id invitelink = await c.export_chat_invite_link(m.chat.id)
invitelink = await c.export_chat_invite_link(chat_id)
if invitelink.startswith("https://t.me/+"): if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace( invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/" "https://t.me/+", "https://t.me/joinchat/"
) )
await user.join_chat(invitelink) await ubot.join_chat(invitelink)
await m.chat.promote_member(
ubot, can_manage_voice_chats=True
)
except UserAlreadyParticipant: except UserAlreadyParticipant:
pass pass
except Exception as e: except Exception as e: