BEISNWKZNAN / nonebot-plugin-essence-message

NoneBot-Plugin
MIT License
7 stars 2 forks source link

报错”type object 'config' has no attribute 'model_validate'“ #3

Closed LeoWrDeom closed 2 weeks ago

LeoWrDeom commented 3 weeks ago

环境:WINDOWS10,Python310,llob v3.30,nonebot2 报错:

08-24 07:46:00 [ERROR] nonebot | Failed to import "nonebot_plugin_essence_message"
Traceback (most recent call last):
  File "G:\lhcbot\lhcbot\bot.py", line 38, in <module>
    nonebot.load_from_toml("pyproject.toml")
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\load.py", line 131, in load_from_toml
    return load_all_plugins(plugins, plugin_dirs)
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\load.py", line 65, in load_all_plugins
    return manager.load_all_plugins()
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 203, in load_all_plugins
    return set(
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 204, in <genexpr>
    filter(None, (self.load_plugin(name) for name in self.available_plugins))
> File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 167, in load_plugin
    module = importlib.import_module(self._third_party_plugin_ids[name])
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 255, in exec_module
    super().exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_essence_message\__init__.py", line 18, in <module>
    from .Helper import format_msg, reach_limit, get_name, trigger_rule, db
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_essence_message\Helper.py", line 15, in <module>
    cfg = config.model_validate(get_driver().config.model_dump())
AttributeError: type object 'config' has no attribute 'model_validate'

依赖列表:

aiocache==0.11.1
aiofiles==0.8.0
aiohappyeyeballs==2.3.4
aiohttp==3.10.1
aiohttp_socks==0.9.0
aiosignal==1.3.1
aiosqlite==0.20.0
aiowebsocket==1.0.0.dev2
alembic==1.13.2
amis-python==1.0.8.post2
annotated-types==0.7.0
anyio==4.4.0
APScheduler==3.10.4
arclet-alconna==1.8.28
arclet-alconna-tools==0.7.9
argcomplete==3.5.0
arrow==1.3.0
async-timeout==4.0.3
asyncio==3.4.3
asyncmy==0.2.9
asyncodbc==0.1.1
asyncpg==0.28.0
attrs==24.1.0
bbcode==1.1.0
beautifulsoup4==4.12.3
bidict==0.23.1
binaryornot==0.4.4
black==22.12.0
Brotli==1.1.0
bs4==0.0.2
cachetools==5.4.0
cashews==7.1.0
certifi==2024.7.4
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
contourpy==1.2.1
cookiecutter==2.6.0
cookit==0.8.0
cpm-kernels==1.0.11
cycler==0.12.1
dashscope==1.20.3
dateparser==1.2.0
distlib==0.3.8
ecdsa==0.19.0
emoji==2.12.1
exceptiongroup==1.2.2
expiringdictx==1.0.1
fake-useragent==1.5.1
fastapi==0.112.0
feedparser==6.0.11
ffmpy==0.3.3
filelock==3.15.4
filetype==1.2.0
fleep==1.0.1
fonttools==4.53.1
frozenlist==1.4.1
fsspec==2024.2.0
gradio==4.41.0
gradio_client==1.3.0
greenlet==3.0.3
h11==0.14.0
h2==4.1.0
hishel==0.0.20
hoshino==0.1.0
hpack==4.0.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
huggingface-hub==0.24.5
hyperframe==6.0.1
icalendar==5.0.13
icetk==0.0.4
idna==3.7
importlib_metadata==8.2.0
importlib_resources==6.4.0
iso8601==1.1.0
Janome==0.4.2
jieba==0.42.1
Jinja2==3.1.4
kiwisolver==1.4.5
llvmlite==0.39.1
loguru==0.7.2
lru-dict==1.3.0
lxml==5.2.2
Mako==1.3.5
Markdown==3.6
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.0
mdurl==0.1.2
meme-generator==0.0.21
mpmath==1.3.0
msgpack==1.0.8
multidict==6.0.5
mutagen==1.47.0
mypy-extensions==1.0.0
nb-cli==1.4.1
nepattern==0.7.6
networkx==3.2.1
nonebot-adapter-cqhttp==2.0.0b1
nonebot-adapter-onebot==2.4.4
nonebot-bison==0.9.3
nonebot-plugin-abstract==1.0.6
nonebot-plugin-alconna==0.51.4
nonebot-plugin-animalvoice==0.2.2
nonebot-plugin-anime-trace==0.1.5
nonebot-plugin-animeres==1.0.4
nonebot-plugin-apscheduler==0.2.0
nonebot-plugin-authrespond==1.7
nonebot-plugin-batarot==0.2.1.post3
nonebot-plugin-BitTorrent==0.0.21
nonebot-plugin-blacklist==1.4.0
nonebot-plugin-capoo==0.1.5
nonebot-plugin-cesaa==0.4.0
nonebot-plugin-cloudsignx==2.1.0
nonebot-plugin-colormind==0.1.0
nonebot-plugin-customemote==0.1.0
nonebot-plugin-datastore==1.3.0
nonebot-plugin-essence-message==0.1.8
nonebot-plugin-fakepic==0.1.1
nonebot-plugin-finallines==0.1.1.post2
nonebot-plugin-fortune==0.4.12
nonebot-plugin-forwarder==2.1.6
nonebot-plugin-helpwithpic==1.6
nonebot-plugin-htmlrender==0.2.3
nonebot-plugin-impact==0.12.114514
nonebot-plugin-localstore==0.7.1
nonebot-plugin-logpile==0.2.1
nonebot-plugin-longtu==0.1.1.post1
nonebot-plugin-looklike==0.0.2
nonebot-plugin-megumin==0.0.5
nonebot-plugin-multincm==1.1.0.post2
nonebot-plugin-mypower==0.1.6
nonebot-plugin-ncm-saying==0.1.0
nonebot-plugin-oddtext==0.2.0
nonebot-plugin-orm==0.7.5
nonebot-plugin-p5generator==0.1.4
nonebot-plugin-person==0.0.5
nonebot-plugin-picstatus==2.0.0.post4
nonebot-plugin-pjsk==0.4.0.post1
nonebot-plugin-pluginupdatecheck==0.1.2
nonebot-plugin-poke==0.1.2
nonebot-plugin-questionmark==0.4.1
nonebot-plugin-random==0.0.9
nonebot-plugin-randomnana==0.1.3
nonebot-plugin-resolver==1.1.16
nonebot-plugin-runagain==0.1.1
nonebot-plugin-savepic==0.3.1
nonebot-plugin-sayoroll==1.0.5
nonebot-plugin-send-anything-anywhere==0.6.1
nonebot-plugin-sendmsg-by-bots==0.1.6
nonebot-plugin-setu-now==0.6.4
nonebot-plugin-tarot==0.4.0.post4
nonebot-plugin-today-waifu==0.1.5
nonebot-plugin-tortoise-orm==0.1.4
nonebot-plugin-tts-gal==0.3.11
nonebot-plugin-twitter==0.2.4
nonebot-plugin-waiter==0.7.1
nonebot-plugin-who-at-me==0.3.2
nonebot-plugin-withdraw==0.2.3
nonebot-plugin-wordcloud==0.7.3
nonebot-plugin-ygo==1.0.2
nonebot-plugin-yinyu==0.0.6
nonebot-plugin-zsmeme==0.0.4
nonebot2==2.3.2
nonebot_plugin_chatrecorder==0.6.0
nonebot_plugin_duel==0.1.2
nonebot_plugin_emojimix==0.4.0
nonebot_plugin_imagetools==0.4.2
nonebot_plugin_learning_chat==0.4.0
nonebot_plugin_memes==0.6.2
nonebot_plugin_random_stereotypes==0.2.0
nonebot_plugin_remake==0.4.2
nonebot_plugin_session==0.3.2
nonebot_plugin_session_orm==0.2.0
nonebot_plugin_shindan==0.6.1
nonebot_plugin_userinfo==0.2.5
noneprompt==0.1.9
numba==0.56.2
numpy==1.23.5
OpenCC==1.1.8
opencv-python-headless==4.10.0.84
orjson==3.10.7
outcome==1.3.0.post0
packaging==24.1
pandas==2.2.2
pathspec==0.12.1
peewee==3.17.6
pil-utils==0.1.10
Pillow==9.5.0
pinecone-client==3.2.2
pinyin==0.4.0
pipx==1.6.0
platformdirs==4.2.2
playwright==1.45.1
pokepoke_miss==0.1.20
prompt_toolkit==3.0.47
protobuf==3.20.0
psutil==6.0.0
py-cpuinfo==9.0.0
pyasn1==0.6.0
pycparser==2.22
pycryptodomex==3.20.0
pydantic==1.10.17
pydantic_core==2.20.1
pydub==0.25.1
pyee==11.1.0
PyExecJS==1.5.1
pyfiglet==1.0.2
Pygments==2.18.0
pygtrie==2.5.0
PyJWT==2.9.0
pymdown-extensions==10.9
pyncm==1.6.15
pyodbc==5.1.0
pyopenjtalk==0.3.4
pyparsing==3.1.2
pypika-tortoise==0.1.6
pypinyin==0.47.1
pypng==0.20220715.0
PySocks==1.7.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-engineio==4.9.1
python-jose==3.3.0
python-markdown-math==0.8
python-multipart==0.0.9
python-slugify==8.0.4
python-socketio==5.11.3
python-socks==2.5.0
pytz==2024.1
PyYAML==6.0.1
qrcode==7.4.2
rapidfuzz==3.9.5
rcnb==1.0.3
regex==2024.7.24
requests==2.32.3
rfc3986==1.5.0
rich==13.7.1
rsa==4.9
ruamel.yaml==0.17.40
ruamel.yaml.clib==0.2.8
ruff==0.6.1
safetensors==0.4.4
scipy==1.14.0
selenium==2.48.0
semantic-version==2.10.0
sentencepiece==0.2.0
sgmllib3k==1.0.0
shellingham==1.5.4
silk-python==0.2.6
simple-websocket==1.0.0
six==1.16.0
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.5
SQLAlchemy==2.0.31
starlette==0.37.2
StrEnum==0.4.15
sympy==1.12
tarina==0.5.5
tatarubot2==1.0
text-unidecode==1.3
tinydb==4.8.0
tokenizers==0.19.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.12.0
torch==1.13.1+cu117
torchaudio==2.4.0+cu124
torchvision==0.14.1+cu117
tortoise-orm==0.20.0
tqdm==4.66.5
transformers==4.44.0
trio==0.26.2
trio-websocket==0.11.1
typer==0.12.4
types-python-dateutil==2.9.0.20240316
typing_extensions==4.12.2
tzdata==2024.1
tzlocal==5.2
ujson==5.10.0
Unidecode==1.3.8
urllib3==2.2.2
userpath==1.9.2
uvicorn==0.30.5
virtualenv==20.26.3
watchfiles==0.22.0
wcwidth==0.2.13
websocket-client==1.8.0
websockets==12.0
win32-setctime==1.1.0
wordcloud==1.9.3
wsproto==1.2.0
yarl==1.9.4
yinglish==1.0.1
yt-dlp==2024.8.1
zipp==3.19.2
BEISNWKZNAN commented 3 weeks ago

使用Pydantic V2或者使用nonebot_plugin_essence_message 0.1.9以解决此问题(后者我刚刚发布)

LeoWrDeom commented 3 weeks ago

还是无法正常使用 系统:windows10 QQ版本:9.9.15-26909 框架:LLOneBot V3.29.6/NapCat V2.0.37/Lagrange最新版【均已测试】 LLOneBot貌似不支持精华操作,NapCat/Lagrange有响应但是还是无法正常使用 essence export指令均不可用, NapCat使用essence fetchall指令返回【成功保存 0\3 条精华消息】 nonebot-plugin-essence-message 0.1.8与0.1.9均已测试,报错基本一致 Lagrange使用essence fetchall报错,报错日志如下:

08-27 00:25:05 [INFO] nonebot | Event will be handled by AlconnaMatcher(type='', module=nonebot_plugin_essence_message, lineno=33)
08-27 00:25:05 [INFO] nonebot | AlconnaMatcher(type='', module=nonebot_plugin_essence_message, lineno=33) running complete
08-27 00:25:05 [INFO] nonebot | Event will be handled by AlconnaMatcher(type='', module=nonebot_plugin_essence_message, lineno=154)
08-27 00:25:08 [INFO] nonebot | AlconnaMatcher(type='', module=nonebot_plugin_essence_message, lineno=154) running complete
08-27 00:25:08 [ERROR] nonebot | Running AlconnaMatcher(type='', module=nonebot_plugin_essence_message, lineno=154) failed.
Traceback (most recent call last):
  File "G:\today\today\bot.py", line 46, in <module>
    nonebot.run(app="__mp_main__:app")
  File "G:\today\today\.venv\lib\site-packages\nonebot\__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "G:\today\today\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 186, in run
    uvicorn.run(
  File "G:\today\today\.venv\lib\site-packages\uvicorn\main.py", line 577, in run
    server.run()
  File "G:\today\today\.venv\lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
  File "C:\Users\Leo\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "G:\today\today\.venv\lib\site-packages\nonebot\message.py", line 476, in check_and_run_matcher
    await _run_matcher(
> File "G:\today\today\.venv\lib\site-packages\nonebot\message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "G:\today\today\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 850, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "G:\today\today\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 825, in simple_run
    await handler(
  File "G:\today\today\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 94, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "G:\today\today\.venv\lib\site-packages\nonebot_plugin_essence_message\__init__.py", line 176, in fetchall_cmd
    if not await db.check_entry_exists(data):
  File "G:\today\today\.venv\lib\site-packages\nonebot_plugin_essence_message\dateset.py", line 268, in check_entry_exists
    cursor = await conn.execute(
  File "G:\today\today\.venv\lib\site-packages\aiosqlite\core.py", line 193, in execute
    cursor = await self._execute(self._conn.execute, sql, parameters)
  File "G:\today\today\.venv\lib\site-packages\aiosqlite\core.py", line 132, in _execute
    return await future
  File "G:\today\today\.venv\lib\site-packages\aiosqlite\core.py", line 115, in run
    result = function()
sqlite3.OperationalError: no such table: essence_data

依赖列表如下:

aiohappyeyeballs==2.4.0
aiohttp==3.10.5
aiosignal==1.3.1
aiosqlite==0.20.0
annotated-types==0.7.0
anyio==4.4.0
arclet-alconna==1.8.28
arclet-alconna-tools==0.7.9
async-timeout==4.0.3
attrs==24.2.0
Brotli==1.1.0
certifi==2024.7.4
click==8.1.7
colorama==0.4.6
exceptiongroup==1.2.2
fastapi==0.112.1
frozenlist==1.4.1
h11==0.14.0
h2==4.1.0
hpack==4.0.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
hyperframe==6.0.1
idna==3.8
importlib_metadata==8.4.0
loguru==0.7.2
msgpack==1.0.8
multidict==6.0.5
nepattern==0.7.6
nonebot-adapter-onebot==2.4.4
nonebot-plugin-alconna==0.51.4
nonebot-plugin-localstore==0.7.1
nonebot-plugin-waiter==0.7.1
nonebot2==2.3.3
pydantic==2.8.2
pydantic_core==2.20.1
pygtrie==2.5.0
python-dotenv==1.0.1
PyYAML==6.0.2
sniffio==1.3.1
starlette==0.38.2
tarina==0.5.5
tomli==2.0.1
typing_extensions==4.12.2
uvicorn==0.30.6
watchfiles==0.23.0
websockets==13.0
win32-setctime==1.1.0
yarl==1.9.4
zipp==3.20.0
BEISNWKZNAN commented 3 weeks ago

十分感谢您的测试! 主要问题在数据库的初始化 并且我修改的时候还发现Lagrange改变了一些返回值

我在发布前在Lagrange下测试过了,应该可以运行)))

LeoWrDeom commented 3 weeks ago

您好,插件确实可以正常运行了,请问插件能否实现把精华图片批量保存到本地文件夹内,和批量删除精华的功能,目前因为群精华满了,迫切需要这个功能,还有因为C盘满了,能否加个配置指定数据库文件的存放位置,谢谢您!

BEISNWKZNAN commented 2 weeks ago
  1. 批量删除精华已更新
  2. 配置指定数据库文件的存放位置由nonebot-plugin-localstore 决定,参考其配置项
  3. 图片精华现在以base64形式存储在数据库中,我的想法是把export改为由指定csv保存图片文件名和精华消息,并和一个image子文件夹压缩后一并导出(没写完)
  4. 那就用saveall吧
LeoWrDeom commented 2 weeks ago

因为是自用的所以有些写的很随意,pr部分还需要修改,让您费心了!