assert _bot is Bot
这个写法有点奇怪,这里想表达的是不是isinstance(bot, Bot)
复现代码:
msg_id = ...
api = API(bot.self_id)
await api.delete_msg(msg_id)
报错:
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 231, in run
super().run()
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 202, in run
self.manage_workers()
File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 551, in manage_workers
self.spawn_workers()
File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 622, in spawn_workers
self.spawn_worker()
File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.10/site-packages/uvicorn/workers.py", line 66, in init_process
super(UvicornWorker, self).init_process()
File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 142, in init_process
self.run()
File "/usr/local/lib/python3.10/site-packages/uvicorn/workers.py", line 98, in run
return asyncio.run(self._serve())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_revoke/__init__.py", line 21, in _
await api.delete_msg(reply_msg_id)
File "/usr/local/lib/python3.10/site-packages/gocqapi/message.py", line 159, in delete_msg
await self.call("delete_msg", message_id=message_id)
File "/usr/local/lib/python3.10/site-packages/gocqapi/_api.py", line 42, in call
raise e
File "/usr/local/lib/python3.10/site-packages/gocqapi/_api.py", line 36, in call
assert _bot is Bot
AssertionError