Kyomotoi / ATRI

A project for ATRI, use go-cqhttp and Nonebot2.
https://atri.imki.moe
GNU General Public License v3.0
722 stars 87 forks source link

配置文件报错? #79

Closed fatinghenji closed 1 year ago

fatinghenji commented 1 year ago

描述问题 | Describe the question 参照配置本项目中提供内容配置后,运行报错。报错代码如下:

(atri-py3.8) :/data/data/com.termux/files/home/ATRI # python main.py
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import ATRI
  File "/data/data/com.termux/files/home/ATRI/ATRI/__init__.py", line 13, in <module>
    conf = __conf.parse()
  File "/data/data/com.termux/files/home/ATRI/ATRI/configs/config.py", line 38, in parse
    return ConfigModel.parse_obj(self.config)
  File "/data/data/com.termux/files/home/.suroot/.cache/pypoetry/virtualenvs/atri-IWL-4cR8-py3.8/lib/python3.8/site-packages/pydantic/main.py", line 527, in parse_obj
    return cls(**obj)
  File "/data/data/com.termux/files/home/.suroot/.cache/pypoetry/virtualenvs/atri-IWL-4cR8-py3.8/lib/python3.8/site-packages/pydantic/main.py", line 342, in __init__
    raise validation_error
pydantic.error_wrappers.ValidationError: 2 validation errors for ConfigModel
WithGoCQHTTP -> accounts -> 0 -> uin
  value is not a valid integer (type=type_error.integer)
WithGoCQHTTP -> accounts -> 0 -> protocol
  value is not a valid integer (type=type_error.integer)

百度了以后,说是文本格式的错误信息,没有解决的头绪。 补充内容 | Additional context 报错相关的WithGoCQHTTP配置填写如下(部分敏感内容做打码处理):

WithGoCQHTTP:
  enabled: false
  accounts:
    - uin: {102****696}
      password: "{password}"
      protocol: {0}

  download_domain: "{download_domain}"
  download_version: "v1.0.0-rc4"

  gocq_webui_username: "ATRI"
  gocq_webui_password: "ATRI1314000***"
fatinghenji commented 1 year ago

这个错误消息表明,在使用 Pydantic 库的 Python 脚本中出现了验证错误。看起来,ConfigModel 类期望在 WithGoCQHTTP -> accounts -> 0 对象中的 uinprotocol 字段的值是整数,但它接收到了不同的数据类型。 您需要检查传递给这些字段的数据,并确保它们确实是整数。您还可以检查 ConfigModel 类的定义,以确保这些字段被定义为整数。

明白是哪里的问题了,应当把”{}“去掉。