1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

doc update.

This commit is contained in:
Mrs4s 2020-07-23 06:17:25 +08:00
parent feb4ff4ac9
commit 2c8d941cee
5 changed files with 160 additions and 3 deletions

View File

@ -241,7 +241,7 @@ func (bot *CQBot) CQGetImage(file string) MSG {
r.ReadBytes(16) r.ReadBytes(16)
return OK(MSG{ return OK(MSG{
"size": r.ReadInt32(), "size": r.ReadInt32(),
"filenames": r.ReadString(), "filename": r.ReadString(),
"url": r.ReadString(), "url": r.ReadString(),
}) })
} }

44
docs/config.md Normal file
View File

@ -0,0 +1,44 @@
# 配置
go-cqhttp 包含 `config.json``device.json` 两个配置文件, 其中 `config.json` 为运行配置 `device.json` 为虚拟设备信息.
## 从原CQHTTP导入配置
go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
1. 找到CQHTTP原配置文件 `{CQ工作目录}/app/io.github.richardchien.coolqhttpapi/config/{qq号}.json`
2. 将文件复制到go-cqhttp根目录并重命名为 `cqhttp.json`
3. 重启go-cqhttp后将自动导入配置
## 配置信息
默认生成的配置文件如下所示:
````json
{
"uin": 0,
"password": "",
"enable_db": true,
"access_token": "",
"http_config": {
"enabled": true,
"host": "0.0.0.0",
"port": 5700
},
"ws_config": {
"enabled": true,
"host": "0.0.0.0",
"port": 6700
}
}
````
| 字段 | 类型 | 说明 |
| ------------ | ------ | ------------------------------------------------------------ |
| uin | int64 | 登录用QQ号 |
| password | string | 登录用密码 |
| enable_db | bool | 是否开启内置数据库, 关闭后将无法使用 **回复/撤回** 等上下文相关接口 |
| access_token | string | 同CQHTTP的 `access_token` 用于身份验证 |
| http_config | object | HTTP API配置 |
| ws_config | object | Websocket API 配置 |

72
docs/cqhttp.md Normal file
View File

@ -0,0 +1,72 @@
# 拓展API
由于部分 api 原版 CQHTTP 并未实现go-cqhttp 修改并增加了一些拓展 api .
## CQCode
| Code | 示例 | 说明 |
| ----- | -------------------- | ---------------------------------------------------------- |
| reply | [CQ:reply,id=123456] | 回复ID为 `123456`的信息. 发送时一条 `message` 仅能使用一次 |
## API
`/set_group_name` **设置群名**
**参数**
| 字段 | 类型 | 说明 |
| -------- | ------ | ---- |
| group_id | int64 | 群号 |
| name | string | 新名 |
`/get_image` **获取图片信息**
> 该接口为 CQHTTP 接口修改
参数
| 字段 | 类型 | 说明 |
| ------ | ------ | -------------- |
| `file` | string | 图片缓存文件名 |
响应数据
| 字段 | 类型 | 说明 |
| ---------- | ------ | -------------- |
| `size` | int32 | 图片源文件大小 |
| `filename` | string | 图片文件原名 |
| `url` | string | 图片下载地址 |
`/get_group_msg` **获取群消息**
参数
| 字段 | 类型 | 说明 |
| ------------ | ----- | ------ |
| `message_id` | int32 | 消息id |
响应数据
| 字段 | 类型 | 说明 |
| ------------ | ------- | ---------- |
| `message_id` | int32 | 消息id |
| `real_id` | int32 | 消息真实id |
| `sender` | object | 发送者 |
| `time` | int32 | 发送时间 |
| `content` | message | 消息内容 |
## 事件
#### 群消息撤回
**上报数据**
| 字段 | 类型 | 可能的值 | 说明 |
| ------------- | ------ | -------------- | -------------- |
| `post_type` | string | `notice` | 上报类型 |
| `notice_type` | string | `group_recall` | 消息类型 |
| `group_id` | int64 | | 群号 |
| `user_id` | int64 | | 消息发送者id |
| `operator_id` | int64 | | 操作者id |
| `message_id` | int64 | | 被撤回的消息id |

38
docs/file.md Normal file
View File

@ -0,0 +1,38 @@
# 文件
go-cqhttp 默认生成的文件树如下所示:
````
.
├── go-cqhttp
├── config.json
├── device.json
├── logs
│ └── xx-xx-xx.log
└── data
├── images
│ └── xxxx.image
└── db
````
| 文件 | 用途 |
| ----------- | ------------------- |
| go-cqhttp | go-cqhttp可执行文件 |
| config.json | 运行配置文件 |
| device.json | 虚拟设备配置文件 |
| logs | 日志存放目录 |
| data | 数据目录 |
| data/images | 图片缓存目录 |
| data/db | 数据库目录 |
## 图片缓存文件
出于性能考虑go-cqhttp 并不会将图片源文件下载到本地而是生成一个可以和QQ服务器对应的缓存文件 (.image),该缓存文件结构如下:
| 偏移 | 类型 | 说明 |
| --------------- | -------- | ------------------ |
| 0x00 | [16]byte | 图片源文件MD5 HASH |
| 0x10 | uint32 | 图片源文件大小 |
| 0x14 | string | 图片原名(QQ内部ID) |
| 0x14 + 原名长度 | string | 图片下载链接 |

3
docs/quick_start.md Normal file
View File

@ -0,0 +1,3 @@
# 开始
欢迎来到 go-cqhttp 文档