Create leaveallmute.py
Browse files
Akeno/plugins/leaveallmute.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from asyncio import *
|
2 |
+
import asyncio
|
3 |
+
from pyrogram import Client, filters
|
4 |
+
from pyrogram.types import *
|
5 |
+
from pyrogram.enums import ChatMemberStatus, ChatType
|
6 |
+
from pyrogram.errors import UserNotParticipant, UserIsBlocked, UserAlreadyParticipant
|
7 |
+
from pyrogram.errors import MessageNotModified
|
8 |
+
from Akeno.utils.handler import *
|
9 |
+
from config import *
|
10 |
+
|
11 |
+
custom_boost = "<emoji id=5812442283206775108>🗿</emoji>"
|
12 |
+
|
13 |
+
@Akeno(
|
14 |
+
~filters.scheduled
|
15 |
+
& filters.command(["leaveallmute"], CMD_HANDLER)
|
16 |
+
& filters.me
|
17 |
+
& ~filters.forwarded
|
18 |
+
)
|
19 |
+
async def leaveallmute(client: Client, message: Message):
|
20 |
+
leave = 0
|
21 |
+
failed = 0
|
22 |
+
u = ""
|
23 |
+
try:
|
24 |
+
pro = await message.reply_text("Wait prossing.....")
|
25 |
+
async for dialog in client.get_dialogs():
|
26 |
+
chat_id = dialog.chat.id if dialog.chat else 0
|
27 |
+
chat_title = dialog.chat.title if dialog.chat else ""
|
28 |
+
if dialog.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
29 |
+
try:
|
30 |
+
member = await client.get_chat_member(chat_id, "me")
|
31 |
+
if member.status == ChatMemberStatus.RESTRICTED:
|
32 |
+
await client.leave_chat(chat_id)
|
33 |
+
leave += 1
|
34 |
+
u += f"Chat ID: `{chat_id}` | Chat Title: {chat_title}\n"
|
35 |
+
except (UserNotParticipant, UserAlreadyParticipant):
|
36 |
+
continue
|
37 |
+
except Exception as e:
|
38 |
+
u += str(e) + "\n"
|
39 |
+
failed += 1
|
40 |
+
if client.me.is_premium:
|
41 |
+
await pro.edit_text(f"{custom_boost}Successfully leave {leave} from group")
|
42 |
+
else:
|
43 |
+
await pro.edit_text(f"Successfully leave {leave} from group")
|
44 |
+
except MessageNotModified:
|
45 |
+
pass
|
46 |
+
except Exception as e:
|
47 |
+
await pro.edit_text(str(e))
|
48 |
+
|
49 |
+
@Akeno(
|
50 |
+
~filters.scheduled
|
51 |
+
& filters.command(["listmuted"], CMD_HANDLER)
|
52 |
+
& filters.me
|
53 |
+
& ~filters.forwarded
|
54 |
+
)
|
55 |
+
async def listmuted(client: Client, message: Message):
|
56 |
+
leave = 0
|
57 |
+
failed = 0
|
58 |
+
u = "Nothing found\n"
|
59 |
+
try:
|
60 |
+
pro = await message.reply_text("Wait prossing.....")
|
61 |
+
async for dialog in client.get_dialogs():
|
62 |
+
chat_id = dialog.chat.id if dialog.chat else 0
|
63 |
+
chat_title = dialog.chat.title if dialog.chat else ""
|
64 |
+
if dialog.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
65 |
+
try:
|
66 |
+
member = await client.get_chat_member(chat_id, "me")
|
67 |
+
if member.status == ChatMemberStatus.RESTRICTED:
|
68 |
+
leave += 1
|
69 |
+
u += f"{leave}: {chat_title} | {chat_id}\n"
|
70 |
+
except (UserNotParticipant, UserAlreadyParticipant):
|
71 |
+
continue
|
72 |
+
except Exception as e:
|
73 |
+
u += str(e) + "\n"
|
74 |
+
failed += 1
|
75 |
+
formatting = (
|
76 |
+
f"{u}\n"
|
77 |
+
f"Failed: {failed}\n"
|
78 |
+
)
|
79 |
+
await pro.edit_text(formatting)
|
80 |
+
except MessageNotModified:
|
81 |
+
pass
|
82 |
+
except Exception as e:
|
83 |
+
await pro.edit_text(str(e))
|