Init commit
This commit is contained in:
7
filters/__init__.py
Normal file
7
filters/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from load import dp
|
||||
from .main import BotAdmin #OnlyMy
|
||||
|
||||
|
||||
if __name__ == "filters":
|
||||
dp.filters_factory.bind(BotAdmin)
|
||||
#dp.filters_factory.bind(OnlyMy)
|
36
filters/main.py
Normal file
36
filters/main.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from aiogram import types
|
||||
from aiogram.dispatcher.filters import BoundFilter
|
||||
|
||||
from load import config
|
||||
|
||||
'''
|
||||
class OnlyMy(BoundFilter):
|
||||
key = 'only_my'
|
||||
|
||||
def __init__(self, only_my):
|
||||
self.onlymy = only_my
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
logging.info("User: {user_id} - {username}".format(
|
||||
user_id=str(message.from_user.id),
|
||||
username=str(message.from_user.username)
|
||||
))
|
||||
if message.from_user.id in config.allowed_users:
|
||||
return True
|
||||
return False
|
||||
'''
|
||||
|
||||
|
||||
class BotAdmin(BoundFilter):
|
||||
key = 'admin'
|
||||
|
||||
def __init__(self, admin):
|
||||
self.admin = admin
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
if message.from_user.id in config.admin_user:
|
||||
return True
|
||||
else:
|
||||
await message.answer("Хорошая попытка, но ты не администратор!")
|
||||
return False
|
||||
|
Reference in New Issue
Block a user