Giter Club home page Giter Club logo

Comments (35)

yanyongyu avatar yanyongyu commented on September 3, 2024

如果你不使用docker或者k8s部署,你可以按照readme填写.env.prod后通过env ENVIRONMENT=prod python bot.py启动

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

好 待我尝试后反馈

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

目前我的环境是 Windows11 + LLOneBot 刚刚尝试在项目根目录创建 .env.prod 文件并执行对应命令报错,烦请有时间提供详细教程供我和其他用户参考,已提前赞助致谢🥰
image

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

请提供你的日志和报错截图

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

image

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

powershell 里你需要使用 $env:ENVIRONEMNT = 'prod' 设置环境变量

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

image

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

麻烦提供一下依赖列表?🤦‍♂️

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

还是说我新建一个nonebot直接覆盖进去?

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

安装环境:poetry install --without dev

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

目前的情况是:

  1. 我使用 Poetry 安装了依赖并且开启了 Poetry 的虚拟环境
    image
  2. 运行 bot.py 报错
    image

本次讨论结束后我会根据我的部署流程提供pr来完善Readme

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

你没有设置环境变量,请先切换到prod环境并根据readme填写完成.env.prod文件后启动。

或者你可以把以下内容复制并填写完整:

LOG_LEVEL=INFO

SUPERUSERS=[]

ONEBOT_API_ROOTS={}

QQ_IS_SANDBOX=false
QQ_BOTS='
[
  {
    "id": "xxx",
    "token": "xxx",
    "secret": "xxx",
    "intent": {
      "guild_messages": true,
      "at_messages": false
    }
  }
]
'

POSTGRES_HOST=
POSTGRES_PORT=
POSTGRES_USER=bot
POSTGRES_PASSWORD=bot_postgres
POSTGRES_DB=bot

REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=bot_redis

FILEHOST_URL_BASE=http://example.com

# Github App 配置
GITHUB_THEME=dark
GITHUB_APPS='
[
  {
    "app_id": "",
    "private_key": [
      "-----BEGIN RSA PRIVATE KEY-----",
      "~~ YOUR PRIVATE KEY HERE ~~",
      "-----END RSA PRIVATE KEY-----"
    ],
    "client_id": "",
    "client_secret": "",
    "webhook_secret": ""
  },
  {
    "client_id": "",
    "client_secret": ""
  }
]

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

你现在的启动流程和开发流程一致,已经不属于「部署」这个范围了

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

报错,好像是类型不匹配

Traceback (most recent call last):
  File "C:\Users\Administrator\Downloads\新建文件夹\QQ-GitHub-Bot-master\QQ-GitHub-Bot-master\bot.py", line 23, in <module>
    driver.register_adapter(GitHubAdapter)
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\internal\driver\abstract.py", line 79, in register_adapter
    self._adapters[name] = adapter(self, **kwargs)
                           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\adapters\github\adapter.py", line 40, in __init__
    self.github_config = get_plugin_config(Config)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\plugin\__init__.py", line 120, in get_plugin_config
    return type_validate_python(config, model_dump(get_driver().config))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\compat.py", line 215, in type_validate_python
    return TypeAdapter(type_).validate_python(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\pydantic\type_adapter.py", line 258, in validate_python
    return self.validator.validate_python(__object, strict=strict, from_attributes=from_attributes, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Config
github_apps
  Input should be a valid list [type=list_type, input_value='\n[\n  {\n    "app_id": ...t_secret": ""\n  }\n]\n', input_type=str]
    For further information visit https://errors.pydantic.dev/2.6/v/list_type

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

没有头绪、卡住了🤦‍♂️
我在 Nonebot 用户交流群内(浅风),如果需要我提供配置文件可以私聊我我发给您

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

你的github apps配置项填写错误,请确保为json格式

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

格式如下:
image

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

关键是我也没改过格式啊🤔

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

你需要给key每一行都要引号和逗号,除了最后一行不用逗号

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

懂了

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

依旧报错 持续傻眼中....

Traceback (most recent call last):
  File "C:\Users\Administrator\Downloads\新建文件夹\QQ-GitHub-Bot-master\QQ-GitHub-Bot-master\bot.py", line 24, in <module>
    driver.register_adapter(ONEBOT_V11_Adapter)
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\internal\driver\abstract.py", line 79, in register_adapter
    self._adapters[name] = adapter(self, **kwargs)
                           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\adapters\onebot\v11\adapter.py", line 71, in __init__
    self.onebot_config: Config = get_plugin_config(Config)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\plugin\__init__.py", line 120, in get_plugin_config
    return type_validate_python(config, model_dump(get_driver().config))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\compat.py", line 215, in type_validate_python
    return TypeAdapter(type_).validate_python(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\pydantic\type_adapter.py", line 258, in validate_python
    return self.validator.validate_python(__object, strict=strict, from_attributes=from_attributes, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Config
onebot_api_roots
  Input should be a valid dictionary [type=dict_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.6/v/dict_type

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

请参考 #76 (comment) 中的配置内容,你遗漏了配置项。

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

好我检查一下

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

对照后基本上能启动了,还有一个报错,是关于 RSA 密钥的,我已经明确比对过密钥填写完整并且按照约定的格式

04-30 21:22:48 [ERROR] uvicorn | Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\jwt\algorithms.py", line 350, in prepare_key
    RSAPrivateKey, load_pem_private_key(key_bytes, password=None)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 494, in _handle_key_loading_error
    raise ValueError(
ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [<OpenSSLError(code=503841036, lib=60, reason=524556, reason_text=unsupported)>])

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\core.py", line 303, in _arequest
    return await client.request(
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\httpx\_client.py", line 1574, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\httpx\_client.py", line 1661, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\httpx\_client.py", line 1686, in _send_handling_auth
    request = await auth_flow.__anext__()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\auth\app.py", line 209, in async_auth_flow
    request.headers["Authorization"] = f"Bearer {await self.aget_jwt()}"
                                                 ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\auth\app.py", line 84, in aget_jwt
    token = self._create_jwt()
            ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\auth\app.py", line 70, in _create_jwt
    return jwt.encode(
           ^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\jwt\api_jwt.py", line 73, in encode
    return api_jws.encode(
           ^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\jwt\api_jws.py", line 160, in encode
    key = alg_obj.prepare_key(key)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\jwt\algorithms.py", line 353, in prepare_key
    return cast(RSAPublicKey, load_pem_public_key(key_bytes))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. InvalidData(InvalidByte(0, 126))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\starlette\routing.py", line 734, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\drivers\fastapi.py", line 153, in _lifespan_manager
    await self._lifespan.startup()
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\internal\driver\_lifespan.py", line 41, in startup
    await self._run_lifespan_func(self._startup_funcs)
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\internal\driver\_lifespan.py", line 35, in _run_lifespan_func
    await cast(ASYNC_LIFESPAN_FUNC, func)()
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\adapters\github\adapter.py", line 68, in _startup
    await asyncio.gather(
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\adapters\github\adapter.py", line 75, in _startup_app
    await bot._get_self_info()
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\nonebot\adapters\github\bot.py", line 228, in _get_self_info
    res = await self._github.rest.apps.async_get_authenticated()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\versions\v2022_11_28\rest\apps.py", line 109, in async_get_authenticated
    return await self._github.arequest(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\core.py", line 459, in arequest
    raw_resp = await self._arequest(
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\qq-github-bot-ptmfP7eY-py3.12\Lib\site-packages\githubkit\core.py", line 317, in _arequest
    raise RequestError(repr(e)) from e
githubkit.exception.RequestError: ValueError('Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. InvalidData(InvalidByte(0, 126))')

image

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

请检查你填写的是否是private key

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

是呀 Github APP 生成下载的

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

那也没有其他办法,还是检查一下你的内容是否一致,报错就是你的key内容不正确无法解析

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

那我重新生成一个再试试

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

还是相同的情况

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

你下载的key文件应该是一模一样的BEGIN RSA PRIVATE KEY开头的文件,把这个文件一模一样复制到json里头尾加上引号和逗号,不应该有这个问题才对。

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

按照您上面提到的格式 两次的Key都无法被识别

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

那也有可能是你的openssl不支持这个格式的key,Windows的openssl我也不熟悉

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

没有头绪 临门一脚的东西 唉...

from qq-github-bot.

yanyongyu avatar yanyongyu commented on September 3, 2024

建议你可以在wsl里尝试,如果没问题的话应该就是系统原因

from qq-github-bot.

QianFuv avatar QianFuv commented on September 3, 2024

好我这就去试试

from qq-github-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.