-
Notifications
You must be signed in to change notification settings - Fork 1
/
MuteChat
38 lines (34 loc) · 1.73 KB
/
MuteChat
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
from .. import loader, utils
from telethon.tl.types import ChatBannedRights as cb
from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest as br
@loader.tds
class MuteChatMod(loader.Module):
"""Мут чата."""
strings = {'name': 'MuteChat'}
async def client_ready(self, client, db):
self.db = db
async def mccmd(self, message):
"""Включить/выключить мут чата."""
if utils.get_args_raw(message) == "clearall":
self.db.set("MuteChat", "mc", [])
return await message.edit("Отключено во всех чатах.")
if not message.is_private:
chat = await message.get_chat()
if not chat.admin_rights and not chat.creator:
return await message.edit("сэр,вы тут не админ.")
else:
if chat.admin_rights.ban_users == False:
return await message.edit("У вас недостаточно прав.")
mc = self.db.get("MuteChat", "mc", [])
chatid = str(message.chat_id)
if chatid in mc:
await message.client(br(message.chat_id, cb(until_date=None, send_messages=None)))
mc.remove(chatid)
self.db.set("MuteChat", "mc", mc)
return await message.edit("Все вправе говорить.")
else:
await message.client(br(message.chat_id, cb(until_date=0, send_messages=True)))
mc.append(chatid)
self.db.set("MuteChat", "mc", mc)
await message.edit("Умолкли!")
else: return await message.edit("Это не чат!")