Giter VIP home page Giter VIP logo

onebot-11's Introduction

介绍

OneBot 标准是从原 CKYU 平台的 CQHTTP 插件接口修改而来的通用聊天机器人应用接口标准。

背景

CQHTTP 插件是 2017 年初出现的基于 CKYU 机器人平台的一款开源免费插件,它使用户能够通过 HTTP 或 WebSocket 对 CKYU 的事件进行上报以及接收请求来调用 CKYU 的 DLL 接口,从而可以使用其它语言(不方便编译到原生二进制的语言)编写 CKYU 插件。

有非常多的开发者使用 Python、Java、Node.js 等 web 开发常用语言基于 CQHTTP 插件编写各式各样的聊天机器人。

在新的机器人平台 Mirai 开始发展之后,以及 CKYU 决定停运之后,为了让原来基于 CQHTTP 插件编写的机器人能够继续运行,一些开发者在其它机器人平台上编写了兼容 CQHTTP 接口的插件/模块。

动机

基于 CQHTTP 插件编写的机器人项目有很多,CKYU 停运后,如果不能平滑迁移到其它平台,这些项目的很多代码都需要重写,甚至有很多项目可能被迫放弃维护,这对机器人开发社区来说是一种损失和浪费。

目前各 CQHTTP 兼容项目通常是实现了部分原 CQHTTP 插件的接口,并利用新平台的特性,新增了一些拓展接口。长远来看,这可能导致不同兼容项目最终形成了各自的「CQHTTP 接口变种」,当用户深度接入其中一个兼容项目后,可能又会出现与其它变种不兼容的情况,最终仍然存在潜在的迁移困难。

本项目希望通过改写原 CQHTTP 插件文档 + 引入 CQHTTP 兼容项目的新特性的方式,维护一个统一的、不断发展的接口标准(即 OneBot 标准),推动各 CQHTTP 兼容项目实现长远的兼容,为用户带来便利。

预期

开发者可以在各类机器人平台实现 OneBot 标准,从而使用户可以将基于 OneBot 标准的机器人项目无缝迁移到这些平台。

当需要添加新的功能(例如新的事件、API、消息段类型等)时,可以通过 pull request 扩充本标准,此后其它 OneBot 实现在添加同一功能时应参考扩充后的标准。

内容目录

onebot-11's People

Contributors

kanrichan avatar shigma avatar stdrc avatar zty012 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

onebot-11's Issues

【提议】:新增 reaction 事件

(2024.03)最近NTQQ 新增了群聊内表情回应。
尽管 Onebot11 标准已经很久没有更新了,但是相关需求仍然存在。 因此提议新增 GroupReactionEvent 事件。
当其他成员对 bot 所发送消息的回应会触发该事件。

字段名 数据类型 可能的值 说明
time number int64 - 事件发生的时间戳
self_id number int64 - 收到事件的机器人 QQ 号
post_type string notice 上报类型
notice_type string group_reaction 通知类型
group_id number int64 - 群号
user_id string - QQ 号
message_id string - 回应的目标消息 ID
qface_id string - QQ 表情 ID

QQ 方面,当新的回应出现时:

  1. 会收到目标消息的更新,内容是目标消息的当前状态,因此该消息中并不会明确指出这是 Emoji Reaction,只在 emojiLikesList 字段中给出消息此刻的所有 Emoji Reaction(回应事件发生,如新增/删除)
"emojiLikesList": [
    {
        "emojiId": "277",
        "emojiType": "1",
        "likesCnt": "1",
        "isClicked": false
    }
],
  1. 如果该回应是对本号所发送消息的回应时,同时会收到一个群聊事件,是与群聊邀请类似的 grayTipElement,可通过subElementType==12,通过 busiId=="4" && busiType="19270" 判断,如图
image

其xml content如下:

"xmlElement": {
      "busiType": "4",
      "busiId": "19270",
      "c2cType": 0,
      "serviceType": 0,
      "ctrlFlag": 0,
      "content": "<gtip align=\"center\"> <qq uin=\"replyer_qquin\" col=\"3\" jp=\"replyer_qqnumber\"/> <nor txt=\"回应了你的\"/> <url jp= \"\" msgseq=\"3893\" col=\"3\" txt=\"消息:\"/>  <face type=\"1\" id=\"277\">  </face> </gtip>",
      "templId": "10382",
      "seqId": "1713682981753442094",
      "templParam": {},
      "pbReserv": null,
      "members": {}
  }

在该消息中,可以获取到目标消息的SeqID,发送者 QQID,以及表情 ID。

目前是出于实现方便的考虑,仅对本号发送消息的新增 reaction 生效,因为其他变更只会触发上述 1. 。

如果要完善考虑,纳入对其他消息的 reaction 进行监听或是 reaction 删除事件,可考虑将类型由 event 改为 message。

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.