Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: github_release_notifier #3387

Open
1 task
HTony03 opened this issue Mar 23, 2025 · 13 comments · May be fixed by #3388
Open
1 task

Plugin: github_release_notifier #3387

HTony03 opened this issue Mar 23, 2025 · 13 comments · May be fixed by #3388
Labels
Plugin Publish Plugin Publish Publish things to store

Comments

@HTony03
Copy link

HTony03 commented Mar 23, 2025

PyPI 项目名

nonebot-plugin-github-release-notifier

插件 import 包名

nonebot_plugin_github_release_notifier

标签

[{"label":" Github","color":"#ea5252"},{"label":"Github","color":"#ea5252"}]

插件配置项

# 在获取失败时是否发送失败信息
GITHUB_SEND_FAILURE_GROUP=True
GITHUB_SEND_FAILURE_SUPERUSER=False

# 用于访问 GitHub API 的 GitHub Token
# 接受任何 Token,无论是classic Token还是full_grained access Token
GITHUB_TOKEN=""

# 群组到仓库的映射(自动添加到数据库,以数据库配置作为第一数据源)
# 格式: {group_id: [{repo: str (, commit: bool)(, issue: bool)(, pull_req: bool)(, release: bool)}]}
GITHUB_NOTIFY_GROUP={}

# 验证 GitHub Token 的最大重试次数
GITHUB_VALIDATE_RETRIES=3

# 每次验证重试之间的延迟(以秒为单位)
GITHUB_VALIDATE_DELAY=5

# 删除群组仓库(用于删除数据库配置)
# 格式: {group_id: ['repo']}
GITHUB_DEL_GROUP_REPO={}

# 在获取仓库数据失败时禁用配置
GITHUB_DISABLE_WHEN_FAIL=False

# bot发送模版
# 格式: {"commit": <your_template>, "issue": <your_template>, "pull_req": <your_template>, "release": <your_template>}
# 可用参数:
# commit: repo, message, author, url
# issue: repo, title, author, url
# pull_req: repo, title, author, url
# release: repo, name, version, details, url
# 用法: '{<parameter>}' (使用python format功能实现)
# 未设定时使用默认模版
GITHUB_SENDING_TEMPLATES={}

# repo添加入群聊时的默认设置
GITHUB_DEFAULT_CONFIG_SETTING=True

插件测试

  • 如需重新运行插件测试,请勾选左侧勾选框
@HTony03 HTony03 added Plugin Publish Plugin Publish Publish things to store labels Mar 23, 2025
@noneflow
Copy link
Contributor

noneflow bot commented Mar 23, 2025

📃 商店发布检查结果

Plugin: github_release_notifier

✅ 所有测试通过,一切准备就绪!

详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 项目 nonebot-plugin-github-release-notifier 已发布至 PyPI。
  • ✅ 标签: Github-#ea5252, Github-#ea5252。
  • ✅ 插件类型: application。
  • ✅ 插件支持的适配器: nonebot.adapters.onebot.v11。
  • ✅ 插件 加载测试 通过。
  • ✅ 版本号: 0.1.6。
  • ✅ 发布时间:2025-03-30 10:52:02 CST。

  • 💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。
    💡 当插件加载测试失败时,请发布新版本后勾选插件测试勾选框重新运行插件测试。

    ♻️ 评论已更新至最新检查结果

    💪 Powered by NoneFlow

    @noneflow noneflow bot changed the title Plugin: nonebot-plugin-github-release-notifier Plugin: github_release_notifier Mar 23, 2025
    @noneflow noneflow bot linked a pull request Mar 23, 2025 that will close this issue
    @yanyongyu
    Copy link
    Member

    插件依赖版本限制错误,请使用如 nonebot2 ~= 2.3 限制 minor 版本。插件依赖内限制了 pydantic 版本,请删除。插件使用了 requests,请使用 httpx 或者 aiohttp 替代。

    插件有一处读取配置错误, https://github.com/HTony03/nonebot_plugin_github_release_notifier/blob/cbf9dbd9ffd88448e42816d546fb22399bf2535d/nonebot_plugin_github_release_notifier/group_commands.py#L23 。为什么不在 config.py 里 get_plugin_config 然后其他模块导入?

    插件数据请使用 localstore 插件获取目录,不需要提供配置项。

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 23, 2025

    requests是用于httpx的错误情况 测试时使用httpx所有错误将raise一个空消息的exception(当api返回数据为空,例如:[]这样的空列表时也会触发这个exception) 因而使用requests做第二次获取,消除因为空数据导致的无效错误

    插件依赖版本限制错误,请使用如 nonebot2 ~= 2.3 限制 minor 版本。插件依赖内限制了 pydantic 版本,请删除。插件使用了 requests,请使用 httpx 或者 aiohttp 替代。

    插件有一处读取配置错误, https://github.com/HTony03/nonebot_plugin_github_release_notifier/blob/cbf9dbd9ffd88448e42816d546fb22399bf2535d/nonebot_plugin_github_release_notifier/group_commands.py#L23 。为什么不在 config.py 里 get_plugin_config 然后其他模块导入?

    插件数据请使用 localstore 插件获取目录,不需要提供配置项。

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 23, 2025

    Image

    Image
    图示为因为api返回为空导致的多次无exception消息导致的错误处理
    api链接:https://api.github.com/repos/HTony03/MiniAirways_mod_manager/issues
    使用requests为了应对此情况 主要仍然使用httpx AsyncClent

    @yanyongyu
    Copy link
    Member

    yanyongyu commented Mar 23, 2025

    个人认为是你的处理有问题,看看什么报错 logger.opt(exception=e).error(repr(e))?requests 会导致机器人阻塞,特别是在访问 github 这类时延较高的接口时会导致机器人无法使用,建议以解决问题优先。

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 23, 2025

      File "C:\Users\Administrator\Desktop\nonebot_Htony03\nb_indev\src\plugins\nonebot_plugin_github_release_notifier\group_commands.py", line 369, in handle_refresh
        await check_and_notify_updates()
              └ <function check_and_notify_updates at 0x0000020117DC47C0>
    
      File "C:\Users\Administrator\Desktop\nonebot_Htony03\nb_indev\src\plugins\nonebot_plugin_github_release_notifier\repo_activity.py", line 191, in check_and_notify_updates
        data = await fetch_github_data(repo, endpoint)
                     │                 │     └ 'releases/latest'
                     │                 └ 'HTony03/rail_route_schedule_editor'
                     └ <function fetch_github_data at 0x0000020117DA7740>
    
    > File repo_activity.py", line 78, in fetch_github_data
        response = await client.get(api_url, headers=headers)
                         │      │   └ 'https://api.github.com/repos/HTony03/rail_route_schedule_editor/releases/latest'
                         │      └ <function AsyncClient.get at 0x0000020114E6EA20>
                         └ <httpx.AsyncClient object at 0x00000201188077D0>
    
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1768, in get
        return await self.request(
                     │    └ <function AsyncClient.request at 0x0000020114E6E5C0>
                     └ <httpx.AsyncClient object at 0x00000201188077D0>
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1540, in request
        return await self.send(request, auth=auth, follow_redirects=follow_redirects)
    
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1629, in send
        response = await self._send_handling_auth(
    
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1657, in _send_handling_auth
        response = await self._send_handling_redirects(
                         │    └ <function AsyncClient._send_handling_redirects at 0x0000020114E6E8E0>
                         └ <httpx.AsyncClient object at 0x00000201188077D0>
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1694, in _send_handling_redirects
        response = await self._send_single_request(request)
                         │    │                    └ <Request('GET', 'https://api.github.com/repos/HTony03/rail_route_schedule_editor/releases/latest')>
    
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_client.py", line 1730, in _send_single_request
        response = await transport.handle_async_request(request)
                         │         │                    └ <Request('GET', 'https://api.github.com/repos/HTony03/rail_route_schedule_editor/releases/latest')>
    
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_transports\default.py", line 393, in handle_async_request
        with map_httpcore_exceptions():
             └ <function map_httpcore_exceptions at 0x0000020114E56C00>
      File "C:\Program Files\Python313\Lib\contextlib.py", line 162, in __exit__
        self.gen.throw(value)
        │    │   │     └ ReadError(BrokenResourceError())
        │    │   └ <method 'throw' of 'generator' objects>
        │    └ <generator object map_httpcore_exceptions at 0x00000201184D2940>
        └ <contextlib._GeneratorContextManager object at 0x000002011842EF90>
      File "C:\Program Files\Python313\Lib\site-packages\httpx\_transports\default.py", line 118, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
              │          └ ''
              └ <class 'httpx.ReadError'>
    
    httpx.ReadError

    返回为httpx.ReadError 无任何消息
    我在尝试用aiohttp替代看看是否能解决此问题
    更正: 疑似是由于长时间未读取到信息的exception
    (由于先前返回错误均是api返回空时_恰好_返回了这个exception 做出了错误判断)

    Copy link
    Member

    你是否使用了代理?

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 23, 2025

    关闭了代理 未关闭时不会出现此错误

    Copy link
    Member

    github api 并不能在国内稳定访问,httpx默认会读取环境变量里的 https_proxy

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 23, 2025

    插件已更新 修改httpx至aiohttp,已删除requests,版本号为:0.1.4, 请求再次审阅

    @yanyongyu
    Copy link
    Member

    @HTony03
    Copy link
    Author

    HTony03 commented Mar 30, 2025

    问题已修复, 版本号0.1.6

    @yanyongyu
    Copy link
    Member

    插件元数据还是缺少配置类

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Plugin Publish Plugin Publish Publish things to store
    Development

    Successfully merging a pull request may close this issue.

    2 participants