nonebot-plugin-setu-now
nonebot-plugin-setu-now copied to clipboard
插件启动时 没有自动连接数据库
更新至最新版本后,发送setu
命令出现报错:
(/st-r是自己加了命令别名)
07-01 21:51:04 [SUCCESS] nonebot | OneBot V11 292****540 | [message.group.normal]: Message -66702554 from 174****912@[群:100****102] '/st-r'
07-01 21:51:04 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_setu_now)
07-01 21:51:04 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_setu_now) running complete
07-01 21:51:04 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_setu_now) failed.
Traceback (most recent call last):
File "/root/XTBot/bot.py", line 37, in <module>
nonebot.run(app="__mp_main__:app")
File "/usr/local/lib/python3.10/site-packages/nonebot/__init__.py", line 309, in run
get_driver().run(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 198, in run
uvicorn.run(
File "/usr/local/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run
server.run()
File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
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 467, in check_and_run_matcher
await _run_matcher(
> File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 419, 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 753, 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 728, in simple_run
await handler(
File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 104, in __call__
values = await self.solve(**kwargs)
File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 219, in solve
values = await asyncio.gather(
File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 208, in _solve_field
value = await cast(Param, field.field_info)._solve(**params)
File "/usr/local/lib/python3.10/site-packages/nonebot/internal/params.py", line 163, in _solve
return await task
File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_setu_now/r18_whitelist.py", line 14, in get_group_white_list_record
res = await GroupWhiteListRecord.get_or_none(group_id=event.group_id)
File "/usr/local/lib/python3.10/site-packages/tortoise/models.py", line 1353, in get_or_none
db = using_db or cls._choose_db()
File "/usr/local/lib/python3.10/site-packages/tortoise/models.py", line 1033, in _choose_db
db = router.db_for_read(cls)
File "/usr/local/lib/python3.10/site-packages/tortoise/router.py", line 36, in db_for_read
return self._db_route(model, "db_for_read")
File "/usr/local/lib/python3.10/site-packages/tortoise/router.py", line 31, in _db_route
return connections.get(self._router_func(model, action))
File "/usr/local/lib/python3.10/site-packages/tortoise/router.py", line 18, in _router_func
for r in self._routers:
TypeError: 'NoneType' object is not iterable
估计是你想看r18 但是没有添加到白名单 于是读不到数据库就是None了,或者是数据库没有初始化完成?
就是用的正常的命令,没有加r18参数 好像是数据库没初始化完成,这个怎么解决
看了一下 nonebot-plugin-tortoise-orm
的源码,好像在启动时会有一个 数据库: 连接成功
的日志,但是我的日志里没有,也没有其他报错,这是什么问题
配置的sqlite3数据库文件也没有创建
改代码测试了一下,似乎
@driver.on_startup
async def connect():
这个函数没有被调用
给这个函数加了个on_command之后手动调用,插件就能正常用了
所以问题所在是没有自动连接数据库
有问题解决前时,载入插件的时候的日志吗?
日志就是很正常的加载插件,没有任何报错什么的,关于 nonebot-plugin-tortoise-orm
插件的日志只有一个
[SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_tortoise_orm"
[SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 添加模型: nonebot_plugin_setu_now.database
用sqlite把数据库删了都没有复现出来,是不是用了别的驱动器,然后你这个帐号没有创建权限导致的? @xxtg666