QQAPI

连接 MC 与 QQ

API

一键安装指令

!!MCDR plugin install qq_api

数据同步于

...

上次更新

...

最新版本

总下载量

1362

返回插件仓库

QQAPI

QQ bot development API.

Usage

QQAPI supports OneBot protocol, choice of QQ Bot is up to you. You may search QQNT and OneBot to find one that works for you.

Regarding Tencent's official Bot, we have noticed they have an official Python SDK. However, group bots registered under an individual are not opened yet. We plan to support it in the future. If you really need it immediately, please open an issue.

go-cqhttp Configuration

Note


go-cqhttp has announced stop maintenance, this section is an arcive.

Set qq account and password in account field:

account:
  uin: 1233456
  password: ''

We recommend to use WebSocket, please set http in config to false and websocket to true. Then set ws-reverse in servers field of go-cqhttp config (this example config should match the default config of QQAPI):

servers:
  - ws-reverse:
      universal: ws://127.0.0.1:5700/ws/
      reconnect-interval: 3000

If you wish to use HTTP, set http in config to true and websocket to false. Then set http in servers field of go-cqhttp config (this example config should match the default config of QQAPI):

servers:
  - http:
      address: 0.0.0.0:5700
      post:
      - url: http://127.0.0.1:5701/

配置文件

配置项默认值说明
http.enablefalse是否使用 HTTP
http.post_host127.0.0.1接收数据上报的地址
http.post_port5701对应 go-cqhttp 的 HTTP 监听端口
http.api_host127.0.0.1对应 go-cqhttp 的地址
http.api_port5700对应 go-cqhttp url 配置的端口
websocket.enabletrue是否使用 WebSocket
websocket.host127.0.0.1对应 go-cqhttp 的地址
websocket.port5700对应 go-cqhttp 的 WebSocket 监听端口

关于多服使用

QQBridge 是一个可以将机器人上报消息分发给多个服务器进行处理的应用。

安装依赖后直接运行 QQBridge.py 即可。

指令

指令功能
stop关闭QQBridge
help获取帮助
reload config重载配置文件
debug thread查看线程列表

配置

配置项默认值说明
webscocketfalse是否使用 WebSocket(为 true 则使用 HTTP)
host127.0.0.1接收数据上报的地址
port5700对应 go-cqhttp 的 HTTP 监听端口
server_list详见下文需要转发的服务器列表
debug_modefalse调试模式

server_list

需要转发的服务器列表, 参照以下格式填写

example:
  host: 127.0.0.1
  port: 5701

你还需要修改 QQAPI 配置文件的 post_host, post_port 使其与 server_list 的内容对应

建议从 5701 向上增加,如第一个服为 5701 第二个服为 5702

开发

示例模范插件:QQChat

事件

当从QQ接收到消息, 会触发以下各类事件

每个事件监听器需要使用 register_event_listener API 注册, 事件ID为 qq_api.事件名

事件参考
on_message(server, bot, event)on_message
on_notice(server, bot, event)on_notice
on_request(server, bot, event)on_request
on_meta_event(server, bot, event)on_meta_event

API

get_event_loop()

用于获取 asyncioevent_loop

get_bot()

用于获取 CQHttp 的实例。