# Copyright (C) 2020-2023 TeamKillerX # # This file is part of TeamKillerX project, # and licensed under GNU Affero General Public License v3. # See the GNU Affero General Public License for more details. # # All rights reserved. See COPYING, AUTHORS. # from pyrogram import Client from pyrogram import Client as ren from pyrogram import * from pyrogram.types import * from akn import log_detailed_error from akn.utils.handler import * from akn.Akeno.help import add_command_help from akn.utils.prefixprem import command @Akeno( ~filters.scheduled & command(["joinchat"]) & filters.me & ~filters.forwarded ) async def join_chat(client: Client, message: Message): tex = message.command[1] if len(message.command) > 1 else message.chat.id g = await message.reply_text("`Processing...`") try: await client.join_chat(tex) await g.edit(f"**Successfully Joined Chat ID** `{tex}`") except Exception as ex: await log_detailed_error(ex, where=client.me.id, who=message.chat.title) await g.edit(f"**ERROR:** \n\n{str(ex)}") @Akeno( ~filters.scheduled & command(["leftchat"]) & filters.me & ~filters.forwarded ) async def leave_chat(client: Client, message: Message): xd = message.command[1] if len(message.command) > 1 else message.chat.id xv = await message.reply_text("`Processing...`") try: await xv.edit_text(f"{client.me.first_name} has left this group, bye!!") await client.leave_chat(xd) except Exception as ex: await log_detailed_error(ex, where=client.me.id, who=message.chat.title) await xv.edit_text("**ERROR:** \n\n{}".format(ex)) @Akeno( ~filters.scheduled & command(["kickmeall"]) & filters.me & ~filters.forwarded ) async def kickmeall(client: Client, message: Message): tex = await message.reply_text("`Global Leave from group chats...`") er = 0 done = 0 async for dialog in client.get_dialogs(): if dialog.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP): chat = dialog.chat.id try: done += 1 await client.leave_chat(chat) except BaseException: er += 1 await tex.edit(f"**Successfully left {done} Groups, Failed to left {er} Groups**") @Akeno( ~filters.scheduled & command(["kickmeallch"]) & filters.me & ~filters.forwarded ) async def kickmeallch(client: Client, message: Message): ok = await message.reply_text("`Global Leave from group chats...`") er = 0 done = 0 async for dialog in client.get_dialogs(): if dialog.chat.type in (enums.ChatType.CHANNEL): chat = dialog.chat.id try: done += 1 await client.leave_chat(chat) except BaseException: er += 1 await ok.edit(f"**Successfully left {done} Channel, failed to left {er} Channel**") add_command_help( "joinleave", [ [ "kickme", "To leave!!.", ], ["leaveallgc", "to leave all groups where you joined."], ["leaveallch", "to leaveall channel where you joined."], ["joinchat [Username]", "give an specific username to join."], ["leftchat [Username]", "give an specific username to leave."], ], ) module = modules_help.add_module("joinleave", __file__) module.add_command("leaveallgc", "to leave all groups where you joined.") module.add_command("leaveallch", "to leaveall channel where you joined") module.add_command("joinchat", "give an specific username to join") module.add_command("leftchat", "give an specific username to leave")