some fixes

This commit is contained in:
levina 2022-01-15 21:00:09 +07:00 committed by GitHub
parent 614817b7fa
commit 0096af672d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,7 +78,7 @@ async def vplay(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» ❌ __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» ❌ __Add users__\n» ❌ __Add new Admins__\n» ❌ __Manage video chat__\n\nData is **updated** automatically after you **promote me**"
) )
return return
if not a.can_manage_voice_chats: if not a.can_manage_voice_chats:
@ -94,37 +94,41 @@ async def vplay(c: Client, m: Message):
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("missing required permission:" + "\n\n» ❌ __Add users__")
return return
if not a.can_promote_members:
await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__")
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(chat_id, ubot)
if b.status == "kicked": if b.status == "kicked":
await m.reply_text( await c.unban_chat_member(chat_id, ubot)
f"@{ASSISTANT_NAME} **is banned in group** {m.chat.title}\n\n» **unban the userbot first if you want to use this bot.**" invitelink = await c.export_chat_invite_link(chat_id)
) if invitelink.startswith("https://t.me/+"):
return
except UserNotParticipant:
if m.chat.username:
try:
await user.join_chat(m.chat.username)
except Exception as e:
await m.reply_text(f"❌ **userbot failed to join**\n\n**reason**: `{e}`")
return
else:
try:
invitelink = await c.export_chat_invite_link(
m.chat.id
)
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 user.join_chat(invitelink)
except UserAlreadyParticipant: await m.chat.promote_member(
pass ubot, can_manage_voice_chats=True
except Exception as e: )
return await m.reply_text( except UserNotParticipant:
f"❌ **userbot failed to join**\n\n**reason**: `{e}`" try:
) ubot = (await user.get_me()).id
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/"
)
await user.join_chat(invitelink)
await m.chat.promote_member(
ubot, can_manage_voice_chats=True
)
except UserAlreadyParticipant:
pass
except Exception as e:
return await m.reply_text(
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
)
if replied: if replied:
if replied.video or replied.document: if replied.video or replied.document:
@ -346,37 +350,41 @@ async def vstream(c: Client, m: Message):
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("missing required permission:" + "\n\n» ❌ __Add users__")
return return
if not a.can_promote_members:
await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__")
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(chat_id, ubot)
if b.status == "kicked": if b.status == "kicked":
await m.reply_text( await c.unban_chat_member(chat_id, ubot)
f"@{ASSISTANT_NAME} **is banned in group** {m.chat.title}\n\n» **unban the userbot first if you want to use this bot.**" invitelink = await c.export_chat_invite_link(chat_id)
) if invitelink.startswith("https://t.me/+"):
return
except UserNotParticipant:
if m.chat.username:
try:
await user.join_chat(m.chat.username)
except Exception as e:
await m.reply_text(f"❌ **userbot failed to join**\n\n**reason**: `{e}`")
return
else:
try:
invitelink = await c.export_chat_invite_link(
m.chat.id
)
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 user.join_chat(invitelink)
except UserAlreadyParticipant: await m.chat.promote_member(
pass ubot, can_manage_voice_chats=True
except Exception as e: )
return await m.reply_text( except UserNotParticipant:
f"❌ **userbot failed to join**\n\n**reason**: `{e}`" try:
) ubot = (await user.get_me()).id
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/"
)
await user.join_chat(invitelink)
await m.chat.promote_member(
ubot, can_manage_voice_chats=True
)
except UserAlreadyParticipant:
pass
except Exception as e:
return await m.reply_text(
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
)
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") await m.reply("» give me a live-link/m3u8 url/youtube link to stream.")