diff --git a/program/music.py b/program/music.py index c8f9395..56dfe3f 100644 --- a/program/music.py +++ b/program/music.py @@ -111,7 +111,10 @@ async def play(c: Client, m: Message): b = await c.get_chat_member(chat_id, ubot) if b.status == "kicked": await c.unban_chat_member(chat_id, ubot) - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" @@ -120,7 +123,10 @@ async def play(c: Client, m: Message): await remove_active_chat(chat_id) except UserNotParticipant: try: - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" diff --git a/program/userbot_tools.py b/program/userbot_tools.py index 070111b..8ed2c79 100644 --- a/program/userbot_tools.py +++ b/program/userbot_tools.py @@ -23,14 +23,18 @@ async def join_chat(c: Client, m: Message): await m.reply_text("❗️ **You've blocked from using this bot!**") return try: - invitelink = await c.export_chat_invite_link(chat_id) + # If it exists, use it. + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" ) - await user.join_chat(invitelink) - await remove_active_chat(chat_id) - return await user.send_message(chat_id, "✅ userbot joined chat") + await user.join_chat(invitelink) + await remove_active_chat(chat_id) + return await user.send_message(chat_id, "✅ userbot joined chat") except UserAlreadyParticipant: return await user.send_message(chat_id, "✅ userbot already in chat") diff --git a/program/video.py b/program/video.py index 942ff63..793969a 100644 --- a/program/video.py +++ b/program/video.py @@ -126,7 +126,10 @@ async def vplay(c: Client, m: Message): b = await c.get_chat_member(chat_id, ubot) if b.status == "kicked": await c.unban_chat_member(chat_id, ubot) - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" @@ -135,7 +138,10 @@ async def vplay(c: Client, m: Message): await remove_active_chat(chat_id) except UserNotParticipant: try: - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" @@ -422,7 +428,10 @@ async def vstream(c: Client, m: Message): b = await c.get_chat_member(chat_id, ubot) if b.status == "kicked": await c.unban_chat_member(chat_id, ubot) - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/" @@ -431,7 +440,10 @@ async def vstream(c: Client, m: Message): await remove_active_chat(chat_id) except UserNotParticipant: try: - invitelink = await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link + if not invitelink: + await c.export_chat_invite_link(chat_id) + invitelink = (await c.get_chat(chat_id)).invite_link if invitelink.startswith("https://t.me/+"): invitelink = invitelink.replace( "https://t.me/+", "https://t.me/joinchat/"