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

新增 status_update 元事件 #202

Closed
stdrc opened this issue Aug 8, 2022 · 0 comments · Fixed by #216
Closed

新增 status_update 元事件 #202

stdrc opened this issue Aug 8, 2022 · 0 comments · Fixed by #216
Assignees
Labels
A-meta Area: 元接口 C-rfc Category: 改进提案 ST-accepted Status: 接收

Comments

@stdrc
Copy link
Member

stdrc commented Aug 8, 2022

摘要

新增 status_update 状态更新元事件,用于通知应用端机器人账号或 OneBot 实现的状态变化。

初步讨论内容见 #191

动机

应用端需要一种比较好的方式知道当前机器人账号是否在线,轮询 get_status 接口实时性较弱。

具体描述

元接口 - 元事件

  • 移动“建议 HTTP 通信方式忽略该类事件。”到开头,使适用于所有元事件,并明确表述为“get_latest_events 应该忽略所有元事件”

  • 新增“meta.status_update 状态更新”事件,事件字段同 多机器人账号连接复用 #181 定义的 get_status 响应数据:

    {
        "good": true,
        "bots": [
            {
                "self": {
                    "platform": "qq",
                    "user_id": "1234567"
                },
                "online": true,
                "qq.status": "信号弱"
            },
            {
                "self": {
                    "platform": "tg",
                    "user_id": "2345678"
                },
                "online": true
            }
        ]
    }
    • 正向和反向 WebSocket 通信方式,连接建立后应在适当时机(如所有机器人账号登录完成后)尽快发送所有机器人账号的状态,之后只在有变化时发送有变化的机器人状态,如果是 good 或其它根级别扩展字段变化,bots 字段可为空
    • HTTP Webhook 通信方式应在实现启动后的适当时机尽快发送,当推送失败时,实现可以选择重试直到成功
  • meta.heartbeat 事件移除 status 字段

局限

替代方案

@stdrc stdrc added C-rfc Category: 改进提案 ST-draft Status: 草稿 A-meta Area: 元接口 labels Aug 8, 2022
@stdrc stdrc added this to the OneBot 12 Candidate milestone Aug 13, 2022
@stdrc stdrc added ST-accepted Status: 接收 and removed ST-draft Status: 草稿 labels Aug 13, 2022
@stdrc stdrc self-assigned this Aug 14, 2022
stdrc added a commit that referenced this issue Aug 14, 2022
Fixes #202

Signed-off-by: Richard Chien <stdrc@outlook.com>
stdrc added a commit that referenced this issue Aug 14, 2022
* clarify `get_latest_events`

Signed-off-by: Richard Chien <stdrc@outlook.com>

* 新增 `status_update` 元事件
Fixes #202

Signed-off-by: Richard Chien <stdrc@outlook.com>

Signed-off-by: Richard Chien <stdrc@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: 元接口 C-rfc Category: 改进提案 ST-accepted Status: 接收
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant