feat: 支持命令限权

This commit is contained in:
Rock Chin
2023-03-31 06:49:13 +00:00
parent 73dccb21f5
commit df494da9e4
3 changed files with 20 additions and 1 deletions

View File

@@ -311,3 +311,16 @@ def register_all():
walk(pkg.qqbot.cmds, '', '')
logging.debug(__command_list__)
def apply_privileges():
"""读取cmdpriv.json并应用指令权限"""
with open('cmdpriv.json', 'r') as f:
data = json.load(f)
for path, priv in data.items():
if path == 'comment':
continue
if __command_list__[path]['privilege'] != priv:
logging.debug('应用权限: {} -> {}(default: {})'.format(path, priv, __command_list__[path]['privilege']))
__command_list__[path]['privilege'] = priv