some fixes
fixed command userbotjoin & userbotleave
This commit is contained in:
parent
2d4e5d83e3
commit
703a989868
@ -1,8 +1,8 @@
|
||||
import asyncio
|
||||
from driver.veez import user
|
||||
from config import BOT_USERNAME, SUDO_USERS
|
||||
from driver.decorators import authorized_users_only, sudo_users_only, errors
|
||||
from driver.filters import command, other_filters
|
||||
from driver.veez import user as USER
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.errors import UserAlreadyParticipant
|
||||
|
||||
@ -11,51 +11,46 @@ from pyrogram.errors import UserAlreadyParticipant
|
||||
command(["userbotjoin", f"userbotjoin@{BOT_USERNAME}"]) & ~filters.private & ~filters.bot
|
||||
)
|
||||
@authorized_users_only
|
||||
@errors
|
||||
async def join_group(client, message):
|
||||
chid = message.chat.id
|
||||
async def join_chat(c: Client, m: Message):
|
||||
chat_id = m.chat.id
|
||||
try:
|
||||
invitelink = await client.export_chat_invite_link(chid)
|
||||
except BaseException:
|
||||
await message.reply_text(
|
||||
"• **i'm not have permission:**\n\n» ❌ __Add Users__",
|
||||
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
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
user = await USER.get_me()
|
||||
except BaseException:
|
||||
user.first_name = "music assistant"
|
||||
|
||||
try:
|
||||
await USER.join_chat(invitelink)
|
||||
return await user.send_message(chat_id, "✅ userbot entered chat")
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
await message.reply_text(
|
||||
f"🛑 Flood Wait Error 🛑 \n\n**userbot couldn't join your group due to heavy join requests for userbot**"
|
||||
"\n\n**or add assistant manually to your Group and try again**",
|
||||
)
|
||||
return
|
||||
await message.reply_text(
|
||||
f"✅ **userbot succesfully entered chat**",
|
||||
)
|
||||
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)
|
||||
f"leave@{BOT_USERNAME}"]) & filters.group & ~filters.edited
|
||||
)
|
||||
@authorized_users_only
|
||||
async def leave_one(client, message):
|
||||
async def leave_chat(_, m: Message):
|
||||
chat_id = m.chat.id
|
||||
try:
|
||||
await USER.send_message(message.chat.id, "✅ userbot successfully left chat")
|
||||
await USER.leave_chat(message.chat.id)
|
||||
except BaseException:
|
||||
await message.reply_text(
|
||||
"❌ **userbot couldn't leave your group, may be floodwaits.**\n\n**» or manually kick userbot from your group**"
|
||||
await user.leave_chat(chat_id)
|
||||
return await _.send_message(
|
||||
chat_id,
|
||||
"✅ userbot leaved chat",
|
||||
)
|
||||
except UserNotParticipant:
|
||||
return await _.send_message(
|
||||
chat_id,
|
||||
"❌ userbot already leave chat",
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@Client.on_message(command(["leaveall", f"leaveall@{BOT_USERNAME}"]))
|
Loading…
Reference in New Issue
Block a user