File size: 3,717 Bytes
21bc372 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# Copyright (C) 2020-2023 TeamKillerX <https://github.com/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")
|