🐛 优化权限管理

This commit is contained in:
CMHopeSunshine 2022-11-27 20:47:48 +08:00
parent b0879f6e02
commit 5bd5dd6b01

View File

@ -129,6 +129,7 @@ async def _(state: T_State):
msg = f'{"启用" if state["bool"] else "禁用"}{" ".join(map(str, state["group"]))}的插件{" ".join(state["plugin"]) if not state["is_all"] else "全部"}使用权限{extra_msg}' msg = f'{"启用" if state["bool"] else "禁用"}{" ".join(map(str, state["group"]))}的插件{" ".join(state["plugin"]) if not state["is_all"] else "全部"}使用权限{extra_msg}'
else: else:
filter_arg['user_id__in'] = state['user'] filter_arg['user_id__in'] = state['user']
filter_arg['group_id'] = None
logger.info('插件管理器', logger.info('插件管理器',
f'{"<g>启用</g>" if state["bool"] else "<r>禁用</r>"}用户<m>{" ".join(map(str, state["user"]))}</m>的插件<m>{" ".join(state["plugin"]) if not state["is_all"] else "全部"}</m>使用权限') f'{"<g>启用</g>" if state["bool"] else "<r>禁用</r>"}用户<m>{" ".join(map(str, state["user"]))}</m>的插件<m>{" ".join(state["plugin"]) if not state["is_all"] else "全部"}</m>使用权限')
msg = f'{"启用" if state["bool"] else "禁用"}用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"]) if not state["is_all"] else "全部"}使用权限{extra_msg}' msg = f'{"启用" if state["bool"] else "禁用"}用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"]) if not state["is_all"] else "全部"}使用权限{extra_msg}'
@ -142,10 +143,10 @@ async def _(state: T_State):
for user in state['user']: for user in state['user']:
await PluginDisable.update_or_create(name=plugin, group_id=group, user_id=user) await PluginDisable.update_or_create(name=plugin, group_id=group, user_id=user)
else: else:
await PluginDisable.update_or_create(name=plugin, group_id=group) await PluginDisable.update_or_create(name=plugin, group_id=group, user_id=None)
else: else:
for user in state['user']: for user in state['user']:
await PluginDisable.update_or_create(name=plugin, user_id=user) await PluginDisable.update_or_create(name=plugin, user_id=user, group_id=None)
await manage_cmd.finish(msg) await manage_cmd.finish(msg)