mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +00:00
🔧 修改BOT ADMIN权限检查修饰器获取依赖服务的方式
This commit is contained in:
parent
0414998e2d
commit
8b49356836
@ -8,9 +8,12 @@ from utils.apps.inject import inject
|
|||||||
def bot_admins_rights_check(func: Callable) -> Callable:
|
def bot_admins_rights_check(func: Callable) -> Callable:
|
||||||
"""BOT ADMIN 权限检查"""
|
"""BOT ADMIN 权限检查"""
|
||||||
|
|
||||||
@wraps(func)
|
|
||||||
@inject
|
@inject
|
||||||
async def decorator(*args, bot_admin_service: BotAdminService, **kwargs):
|
def get_bot_admin_service(bot_admin_service: BotAdminService = None):
|
||||||
|
return bot_admin_service
|
||||||
|
|
||||||
|
@wraps(func)
|
||||||
|
async def decorator(*args, **kwargs):
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
# self update context
|
# self update context
|
||||||
_, update, context = args
|
_, update, context = args
|
||||||
@ -19,6 +22,7 @@ def bot_admins_rights_check(func: Callable) -> Callable:
|
|||||||
update, context = args
|
update, context = args
|
||||||
else:
|
else:
|
||||||
return await func(*args, **kwargs)
|
return await func(*args, **kwargs)
|
||||||
|
bot_admin_service = get_bot_admin_service()
|
||||||
if bot_admin_service is None:
|
if bot_admin_service is None:
|
||||||
raise RuntimeError("bot_admin_service is None")
|
raise RuntimeError("bot_admin_service is None")
|
||||||
admin_list = await bot_admin_service.get_admin_list()
|
admin_list = await bot_admin_service.get_admin_list()
|
||||||
|
Loading…
Reference in New Issue
Block a user