bot-ssttkkl / nonebot-plugin-access-control

Nonebot 权限控制插件
MIT License
42 stars 2 forks source link

奇怪的报错? assert len(subject) > 0, "require at least one subject" #17

Closed Redmomn closed 9 months ago

Redmomn commented 9 months ago

先上代码

#响应器
get_fuck = on_fullmatch('测码')

#ac插件
from nonebot import require
require('nonebot_plugin_access_control_api')
from nonebot_plugin_access_control_api.service import create_plugin_service
ex_service = create_plugin_service('nonebot_plugin_fuck')

get_fuck_subservice = ex_service.create_subservice('get_fuck')
get_fuck_subservice.patch_matcher(get_fuck)

然后触发这个get_fuck的响应器之后就报错

11-23 14:23:33 [SUCCESS] nonebot | OneBot V11 2697537872 | [message.group.normal]: Message -936202536 from 3098632978@[ 群:860501695] '测码'
11-23 14:23:33 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.fuck, lineno=17)
11-23 14:23:33 [ERROR] nonebot | Error when running RunPreProcessors. Running cancelled!
Traceback (most recent call last):
  File "<string>", line 15, in <module>
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\__init__.py", line 331, in run
    get_driver().run(*args, **kwargs)
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\drivers\fastapi.py", line 201, in run
    uvicorn.run(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\uvicorn\main.py", line 587, in run
    server.run()
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\uvicorn\server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python310\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "C:\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Python310\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Python310\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
  File "C:\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\message.py", line 476, in check_and_run_matcher
    await _run_matcher(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\message.py", line 414, in _run_matcher
    if not await _apply_run_preprocessors(
> File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\message.py", line 257, in _apply_run_preprocessors
    await asyncio.gather(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\utils.py", line 196, in run_coro_with_catch
    return await coro
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot\dependencies\__init__.py", line 113, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot_plugin_access_control\service\_impl\patcher.py", line 77, in check
    await service.check(bot, event, throw_on_fail=True)
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot_plugin_access_control_api\service\interface\service_base.py", line 66, in check
    return await self.check_by_subject(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot_plugin_access_control_api\service\service.py", line 61, in check_by_subject
    await self.acquire_token_for_rate_limit_by_subjects_receiving_result(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot_plugin_access_control_api\service\service.py", line 178, in acquire_token_for_rate_limit_by_subjects_receiving_result
    return await self._rate_limit_impl.acquire_token_for_rate_limit_by_subjects_receiving_result(
  File "D:\bot\Pallas-Bot-master\venv\lib\site-packages\nonebot_plugin_access_control\service\_impl\rate_limit.py", line 172, in acquire_token_for_rate_limit_by_subjects_receiving_result
    assert len(subject) > 0, "require at least one subject"
AssertionError: require at least one subject
ssttkkl commented 9 months ago

安装1.1.1版本试试

Redmomn commented 9 months ago

可以了,感谢