aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/__init__.py2
-rw-r--r--utils/filters.py27
2 files changed, 15 insertions, 14 deletions
diff --git a/utils/__init__.py b/utils/__init__.py
new file mode 100644
index 0000000..05fcb09
--- /dev/null
+++ b/utils/__init__.py
@@ -0,0 +1,2 @@
1# isort: skip_file
2from . import filters
diff --git a/utils/filters.py b/utils/filters.py
index 9b8ce5c..59302fb 100644
--- a/utils/filters.py
+++ b/utils/filters.py
@@ -5,27 +5,26 @@ from random import randint
5from aiogram import filters as f 5from aiogram import filters as f
6from aiogram import types as t 6from aiogram import types as t
7 7
8from shared import config 8from shared.instances import config
9 9
10 10
11class message: 11class message:
12 is_chat = f.ChatTypeFilter((t.ChatType.GROUP, t.ChatType.SUPERGROUP)) 12 is_chat = f.ChatTypeFilter((t.ChatType.GROUP, t.ChatType.SUPERGROUP))
13 13
14 @staticmethod 14 @staticmethod
15 def chance(msg: t.Message): 15 def chance(msg: t.Message) -> bool:
16 return config.chances.get(str(msg.chat.id), 10) >= randint(1, 100) 16 return config.get_config(msg.chat.id).gen.chance >= randint(1, 100)
17
18 @staticmethod
19 def has_text(msg: t.Message):
20 if msg.text or msg.caption:
21 return True
22 17
23 18
24class user: 19class user:
25 @staticmethod 20 @staticmethod
26 def add_member(upd: t.ChatMemberUpdated): 21 async def is_admin(msg: t.Message) -> bool:
27 old = upd.old_chat_member 22 if not await message.is_chat.check(msg):
28 new = upd.new_chat_member 23 return True
29 return not t.ChatMemberStatus.is_chat_member( 24 member = await msg.chat.get_member(msg.from_user.id)
30 old.status 25 if not member.is_chat_admin():
31 ) and t.ChatMemberStatus.is_chat_member(new.status) 26 await msg.answer(
27 "Вы не администратор. Данное действие будет занесено в журнал."
28 )
29 return False
30 return True