mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-06-30 03:43:25 +00:00
Compare commits
71 Commits
v0.9.34
...
v0.9.37-fi
Author | SHA1 | Date | |
---|---|---|---|
1843bd6a4e | |||
938ebf630f | |||
2bbf969cfa | |||
416a3460ab | |||
f98c334089 | |||
0e5276ea4d | |||
6113eb9200 | |||
1e56c4f986 | |||
9573ce1f16 | |||
a02219a64f | |||
773952d6d6 | |||
b8916d2570 | |||
6769421b7a | |||
4262430340 | |||
d20ff4eeb2 | |||
935faa1159 | |||
9c81b81820 | |||
808c275f3d | |||
d6fba106d3 | |||
e25536fbe5 | |||
1de12bdcd2 | |||
f8fc023e2f | |||
6c89921a87 | |||
cfc5d6d2ff | |||
a6a78dfcac | |||
5a8d918d9d | |||
ec3c2d6244 | |||
c1af182732 | |||
4c942964c7 | |||
0080011f40 | |||
589fbd21df | |||
97acd956f0 | |||
f7144523d9 | |||
ad51264efa | |||
9c17f501b1 | |||
2baf622b83 | |||
99a68b144b | |||
569b89a117 | |||
690384a9a3 | |||
20f2290ba4 | |||
fc2fc3494e | |||
5664567685 | |||
13a0a0cfd1 | |||
86e98c8287 | |||
7b831cfa1e | |||
05f2503631 | |||
e398dc2e02 | |||
4b32b30f89 | |||
17ea1e54bd | |||
68a41d4543 | |||
73774681af | |||
f258b010b9 | |||
a1e19bb66e | |||
e32137ceeb | |||
9dc519ff77 | |||
3d5cec13d0 | |||
6ea4bd829e | |||
6e3501a6f8 | |||
289b96f187 | |||
aa77810491 | |||
474de6ad3d | |||
cbbe196f26 | |||
00783380b7 | |||
4ef476cb67 | |||
d50442b85f | |||
370e08ad7e | |||
627924fbf9 | |||
c492465480 | |||
d84b7c423a | |||
1af61737dc | |||
f789609a23 |
15
.github/ISSUE_TEMPLATE/bug--.md
vendored
15
.github/ISSUE_TEMPLATE/bug--.md
vendored
@ -7,11 +7,20 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<!--
|
||||||
|
在提出ISSUE前,希望您能花费一定的时间执行以下几个步骤以方便我们定位BUG.
|
||||||
|
1: 确定没有相同问题的ISSUE已被提出.
|
||||||
|
2: 准确填写环境信息.
|
||||||
|
3: 最好能打开DEBUG模式并复现相关问题.
|
||||||
|
4: 如果涉及内存泄漏/CPU占用异常请打开DEBUG模式并下载pprof性能分析.
|
||||||
|
-->
|
||||||
|
|
||||||
**环境信息**
|
**环境信息**
|
||||||
请根据实际使用环境修改以下信息
|
请根据实际使用环境修改以下信息
|
||||||
go-cqhttp版本: v0.9.10
|
go-cqhttp版本:
|
||||||
运行环境: windows_amd64
|
运行环境:
|
||||||
连接方式: 反向WS
|
连接方式:
|
||||||
|
使用协议:
|
||||||
|
|
||||||
**bug内容**
|
**bug内容**
|
||||||
请在这里详细描述bug的内容
|
请在这里详细描述bug的内容
|
||||||
|
159
README.md
159
README.md
@ -1,47 +1,87 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="https://ishkong.github.io/go-cqhttp-docs/"><img src="https://i.loli.net/2020/12/20/qSLMDWxiocRQgu6.jpg" width="200" height="200" alt="go-cqhttp"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
# go-cqhttp
|
# go-cqhttp
|
||||||
使用 [mirai](https://github.com/mamoe/mirai) 以及 [MiraiGo](https://github.com/Mrs4s/MiraiGo) 开发的cqhttp golang原生实现, 并在[cqhttp原版](https://github.com/richardchien/coolq-http-api)的基础上做了部分修改和拓展.
|
|
||||||
文档暂时可查看 `docs` 目录, 目前还在撰写中.
|
|
||||||
|
|
||||||
测试版可前往 Release 下载
|
_✨ 基于 [Mirai](https://github.com/mamoe/mirai) 以及 [MiraiGo](https://github.com/Mrs4s/MiraiGo) 的 [cqhttp](https://github.com/howmanybots/onebot/blob/master/README.md) golang 原生实现 ✨_
|
||||||
|
|
||||||
# 兼容性
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://raw.githubusercontent.com/Mrs4s/go-cqhttp/master/LICENSE">
|
||||||
|
<img src="https://img.shields.io/github/license/Mrs4s/go-cqhttp" alt="license">
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/Mrs4s/go-cqhttp/releases">
|
||||||
|
<img src="https://img.shields.io/github/v/release/Mrs4s/go-cqhttp?color=blueviolet&include_prereleases" alt="release">
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/howmanybots/onebot/blob/master/README.md">
|
||||||
|
<img src="https://img.shields.io/badge/OneBot-v11-blue?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="cqhttp">
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/Mrs4s/go-cqhttp/actions">
|
||||||
|
<img src="https://github.com/Mrs4s/go-cqhttp/workflows/CI/badge.svg" alt="action">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="http://ishkong.github.io/go-cqhttp-docs">文档</a>
|
||||||
|
·
|
||||||
|
<a href="https://github.com/Mrs4s/go-cqhttp/releases">下载</a>
|
||||||
|
·
|
||||||
|
<a href="https://ishkong.github.io/go-cqhttp-docs/guide/quick_start.html">开始使用</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
go-cqhttp 在[原版 cqhttp](https://github.com/richardchien/coolq-http-api)的基础上做了部分修改和拓展.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 兼容性
|
||||||
|
|
||||||
|
### 接口
|
||||||
|
|
||||||
#### 接口
|
|
||||||
- [x] HTTP API
|
- [x] HTTP API
|
||||||
- [x] 反向HTTP POST
|
- [x] 反向 HTTP POST
|
||||||
- [x] 正向Websocket
|
- [x] 正向 Websocket
|
||||||
- [x] 反向Websocket
|
- [x] 反向 Websocket
|
||||||
|
|
||||||
#### 拓展支持
|
### 拓展支持
|
||||||
> 拓展API可前往 [文档](docs/cqhttp.md) 查看
|
|
||||||
- [x] HTTP POST多点上报
|
> 拓展 API 可前往 [文档](docs/cqhttp.md) 查看
|
||||||
- [x] 反向WS多点连接
|
|
||||||
|
- [x] HTTP POST 多点上报
|
||||||
|
- [x] 反向 WS 多点连接
|
||||||
- [x] 修改群名
|
- [x] 修改群名
|
||||||
- [x] 消息撤回事件
|
- [x] 消息撤回事件
|
||||||
- [x] 解析/发送 回复消息
|
- [x] 解析/发送 回复消息
|
||||||
- [x] 解析/发送 合并转发
|
- [x] 解析/发送 合并转发
|
||||||
- [x] 使用代理请求网络图片
|
- [x] 使用代理请求网络图片
|
||||||
|
|
||||||
#### 实现
|
### 实现
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>已实现CQ码</summary>
|
<summary>已实现CQ码</summary>
|
||||||
|
|
||||||
##### 符合Onebot标准的CQ码
|
#### 符合 Onebot 标准的 CQ 码
|
||||||
| CQ码 | 功能 |
|
|
||||||
| ------------ | ---------------------------- |
|
|
||||||
| [CQ:face] | [QQ表情] |
|
|
||||||
| [CQ:record] | [语音] |
|
|
||||||
| [CQ:video] | [短视频] |
|
|
||||||
| [CQ:at] | [@某人] |
|
|
||||||
| [CQ:share] | [链接分享] |
|
|
||||||
| [CQ:music] | [音乐分享] [音乐自定义分享] |
|
|
||||||
| [CQ:reply] | [回复] |
|
|
||||||
| [CQ:forward] | [合并转发] |
|
|
||||||
| [CQ:node] | [合并转发节点] |
|
|
||||||
| [CQ:xml] | [XML消息] |
|
|
||||||
| [CQ:json] | [JSON消息] |
|
|
||||||
|
|
||||||
[QQ表情]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#qq-%E8%A1%A8%E6%83%85
|
| CQ 码 | 功能 |
|
||||||
|
| ------------ | --------------------------- |
|
||||||
|
| [CQ:face] | [QQ 表情] |
|
||||||
|
| [CQ:record] | [语音] |
|
||||||
|
| [CQ:video] | [短视频] |
|
||||||
|
| [CQ:at] | [@某人] |
|
||||||
|
| [CQ:share] | [链接分享] |
|
||||||
|
| [CQ:music] | [音乐分享] [音乐自定义分享] |
|
||||||
|
| [CQ:reply] | [回复] |
|
||||||
|
| [CQ:forward] | [合并转发] |
|
||||||
|
| [CQ:node] | [合并转发节点] |
|
||||||
|
| [CQ:xml] | [XML 消息] |
|
||||||
|
| [CQ:json] | [JSON 消息] |
|
||||||
|
|
||||||
|
[qq 表情]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#qq-%E8%A1%A8%E6%83%85
|
||||||
[语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E8%AF%AD%E9%9F%B3
|
[语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E8%AF%AD%E9%9F%B3
|
||||||
[短视频]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E7%9F%AD%E8%A7%86%E9%A2%91
|
[短视频]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E7%9F%AD%E8%A7%86%E9%A2%91
|
||||||
[@某人]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E6%9F%90%E4%BA%BA
|
[@某人]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E6%9F%90%E4%BA%BA
|
||||||
@ -51,26 +91,27 @@
|
|||||||
[回复]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%9E%E5%A4%8D
|
[回复]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%9E%E5%A4%8D
|
||||||
[合并转发]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-
|
[合并转发]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-
|
||||||
[合并转发节点]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E8%8A%82%E7%82%B9-
|
[合并转发节点]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E8%8A%82%E7%82%B9-
|
||||||
[XML消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#xml-%E6%B6%88%E6%81%AF
|
[xml 消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#xml-%E6%B6%88%E6%81%AF
|
||||||
[JSON消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#json-%E6%B6%88%E6%81%AF
|
[json 消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#json-%E6%B6%88%E6%81%AF
|
||||||
|
|
||||||
##### 拓展CQ码及与Onebot标准有略微差异的CQ码
|
#### 拓展 CQ 码及与 Onebot 标准有略微差异的 CQ 码
|
||||||
| 拓展CQ码 | 功能 |
|
|
||||||
| -------------- | ------------------------------- |
|
| 拓展 CQ 码 | 功能 |
|
||||||
| [CQ:image] | [图片] |
|
| -------------- | --------------------------------- |
|
||||||
| [CQ:redbag] | [红包] |
|
| [CQ:image] | [图片] |
|
||||||
| [CQ:poke] | [戳一戳] |
|
| [CQ:redbag] | [红包] |
|
||||||
| [CQ:gift] | [礼物] |
|
| [CQ:poke] | [戳一戳] |
|
||||||
| [CQ:node] | [合并转发消息节点] |
|
| [CQ:gift] | [礼物] |
|
||||||
| [CQ:cardimage] | [一种xml的图片消息(装逼大图)] |
|
| [CQ:node] | [合并转发消息节点] |
|
||||||
| [CQ:tts] | [文本转语音] |
|
| [CQ:cardimage] | [一种 xml 的图片消息(装逼大图)] |
|
||||||
|
| [CQ:tts] | [文本转语音] |
|
||||||
|
|
||||||
[图片]: docs/cqhttp.md#%E5%9B%BE%E7%89%87
|
[图片]: docs/cqhttp.md#%E5%9B%BE%E7%89%87
|
||||||
[红包]: docs/cqhttp.md#%E7%BA%A2%E5%8C%85
|
[红包]: docs/cqhttp.md#%E7%BA%A2%E5%8C%85
|
||||||
[戳一戳]: docs/cqhttp.md#%E6%88%B3%E4%B8%80%E6%88%B3
|
[戳一戳]: docs/cqhttp.md#%E6%88%B3%E4%B8%80%E6%88%B3
|
||||||
[礼物]: docs/cqhttp.md#%E7%A4%BC%E7%89%A9
|
[礼物]: docs/cqhttp.md#%E7%A4%BC%E7%89%A9
|
||||||
[合并转发消息节点]: docs/cqhttp.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF%E8%8A%82%E7%82%B9
|
[合并转发消息节点]: docs/cqhttp.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF%E8%8A%82%E7%82%B9
|
||||||
[一种xml的图片消息(装逼大图)]: docs/cqhttp.md#cardimage-%E4%B8%80%E7%A7%8Dxml%E7%9A%84%E5%9B%BE%E7%89%87%E6%B6%88%E6%81%AF%E8%A3%85%E9%80%BC%E5%A4%A7%E5%9B%BE
|
[一种 xml 的图片消息(装逼大图)]: docs/cqhttp.md#cardimage-%E4%B8%80%E7%A7%8Dxml%E7%9A%84%E5%9B%BE%E7%89%87%E6%B6%88%E6%81%AF%E8%A3%85%E9%80%BC%E5%A4%A7%E5%9B%BE
|
||||||
[文本转语音]: docs/cqhttp.md#%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3
|
[文本转语音]: docs/cqhttp.md#%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@ -78,7 +119,8 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>已实现API</summary>
|
<summary>已实现API</summary>
|
||||||
|
|
||||||
##### 符合Onebot标准的API
|
#### 符合 Onebot 标准的 API
|
||||||
|
|
||||||
| API | 功能 |
|
| API | 功能 |
|
||||||
| ------------------------ | ---------------------- |
|
| ------------------------ | ---------------------- |
|
||||||
| /send_private_msg | [发送私聊消息] |
|
| /send_private_msg | [发送私聊消息] |
|
||||||
@ -106,10 +148,9 @@
|
|||||||
| /can_send_image | [检查是否可以发送图片] |
|
| /can_send_image | [检查是否可以发送图片] |
|
||||||
| /can_send_record | [检查是否可以发送语音] |
|
| /can_send_record | [检查是否可以发送语音] |
|
||||||
| /get_version_info | [获取版本信息] |
|
| /get_version_info | [获取版本信息] |
|
||||||
| /set_restart | [重启go-cqhttp] |
|
| /set_restart | [重启 go-cqhttp] |
|
||||||
| /.handle_quick_operation | [对事件执行快速操作] |
|
| /.handle_quick_operation | [对事件执行快速操作] |
|
||||||
|
|
||||||
|
|
||||||
[发送私聊消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
|
[发送私聊消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
|
||||||
[发送群消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
|
[发送群消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
|
||||||
[发送消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF
|
[发送消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF
|
||||||
@ -135,11 +176,12 @@
|
|||||||
[检查是否可以发送图片]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87
|
[检查是否可以发送图片]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87
|
||||||
[检查是否可以发送语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3
|
[检查是否可以发送语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3
|
||||||
[获取版本信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF
|
[获取版本信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF
|
||||||
[重启go-cqhttp]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0
|
[重启 go-cqhttp]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0
|
||||||
[对事件执行快速操作]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/hidden.md#handle_quick_operation-%E5%AF%B9%E4%BA%8B%E4%BB%B6%E6%89%A7%E8%A1%8C%E5%BF%AB%E9%80%9F%E6%93%8D%E4%BD%9C
|
[对事件执行快速操作]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/hidden.md#handle_quick_operation-%E5%AF%B9%E4%BA%8B%E4%BB%B6%E6%89%A7%E8%A1%8C%E5%BF%AB%E9%80%9F%E6%93%8D%E4%BD%9C
|
||||||
|
|
||||||
##### 拓展API及与Onebot标准有略微差异的API
|
#### 拓展 API 及与 Onebot 标准有略微差异的 API
|
||||||
| 拓展API | 功能 |
|
|
||||||
|
| 拓展 API | 功能 |
|
||||||
| --------------------------- | ---------------------- |
|
| --------------------------- | ---------------------- |
|
||||||
| /set_group_portrait | [设置群头像] |
|
| /set_group_portrait | [设置群头像] |
|
||||||
| /get_image | [获取图片信息] |
|
| /get_image | [获取图片信息] |
|
||||||
@ -147,7 +189,7 @@
|
|||||||
| /get_forward_msg | [获取合并转发内容] |
|
| /get_forward_msg | [获取合并转发内容] |
|
||||||
| /send_group_forward_msg | [发送合并转发(群)] |
|
| /send_group_forward_msg | [发送合并转发(群)] |
|
||||||
| /.get_word_slices | [获取中文分词] |
|
| /.get_word_slices | [获取中文分词] |
|
||||||
| /.ocr_image | [图片OCR] |
|
| /.ocr_image | [图片 OCR] |
|
||||||
| /get_group_system_msg | [获取群系统消息] |
|
| /get_group_system_msg | [获取群系统消息] |
|
||||||
| /get_group_file_system_info | [获取群文件系统信息] |
|
| /get_group_file_system_info | [获取群文件系统信息] |
|
||||||
| /get_group_root_files | [获取群根目录文件列表] |
|
| /get_group_root_files | [获取群根目录文件列表] |
|
||||||
@ -161,7 +203,7 @@
|
|||||||
[获取合并转发内容]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E5%86%85%E5%AE%B9
|
[获取合并转发内容]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E5%86%85%E5%AE%B9
|
||||||
[发送合并转发(群)]: docs/cqhttp.md#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E7%BE%A4
|
[发送合并转发(群)]: docs/cqhttp.md#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E7%BE%A4
|
||||||
[获取中文分词]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D
|
[获取中文分词]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D
|
||||||
[图片OCR]: docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr
|
[图片 ocr]: docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr
|
||||||
[获取群系统消息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
|
[获取群系统消息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
|
||||||
[获取群文件系统信息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF
|
[获取群文件系统信息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF
|
||||||
[获取群根目录文件列表]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%A0%B9%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8
|
[获取群根目录文件列表]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%A0%B9%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8
|
||||||
@ -174,7 +216,8 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>已实现Event</summary>
|
<summary>已实现Event</summary>
|
||||||
|
|
||||||
##### 符合Onebot标准的Event(部分Event比Onebot标准多上报几个字段,不影响使用)
|
#### 符合 Onebot 标准的 Event(部分 Event 比 Onebot 标准多上报几个字段,不影响使用)
|
||||||
|
|
||||||
| 事件类型 | Event |
|
| 事件类型 | Event |
|
||||||
| -------- | ---------------- |
|
| -------- | ---------------- |
|
||||||
| 消息事件 | [私聊信息] |
|
| 消息事件 | [私聊信息] |
|
||||||
@ -209,8 +252,9 @@
|
|||||||
[加好友请求]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
[加好友请求]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
||||||
[加群请求/邀请]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7
|
[加群请求/邀请]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7
|
||||||
|
|
||||||
##### 拓展Event
|
#### 拓展 Event
|
||||||
| 事件类型 | 拓展Event |
|
|
||||||
|
| 事件类型 | 拓展 Event |
|
||||||
| -------- | ---------------- |
|
| -------- | ---------------- |
|
||||||
| 通知事件 | [好友戳一戳] |
|
| 通知事件 | [好友戳一戳] |
|
||||||
| 通知事件 | [群成员名片更新] |
|
| 通知事件 | [群成员名片更新] |
|
||||||
@ -222,16 +266,17 @@
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
# 关于ISSUE
|
## 关于 ISSUE
|
||||||
|
|
||||||
以下ISSUE会被直接关闭
|
以下 ISSUE 会被直接关闭
|
||||||
- 提交BUG不使用Template
|
|
||||||
|
- 提交 BUG 不使用 Template
|
||||||
- 询问已知问题
|
- 询问已知问题
|
||||||
- 提问找不到重点
|
- 提问找不到重点
|
||||||
- 重复提问
|
- 重复提问
|
||||||
|
|
||||||
> 请注意, 开发者并没有义务回复您的问题. 您应该具备基本的提问技巧。
|
> 请注意, 开发者并没有义务回复您的问题. 您应该具备基本的提问技巧。
|
||||||
|
|
||||||
# 性能
|
## 性能
|
||||||
|
|
||||||
在关闭数据库的情况下, 加载25个好友128个群运行24小时后内存使用为10MB左右. 开启数据库后内存使用将根据消息量增加10-20MB, 如果系统内存小于128M建议关闭数据库使用.
|
在关闭数据库的情况下, 加载 25 个好友 128 个群运行 24 小时后内存使用为 10MB 左右. 开启数据库后内存使用将根据消息量增加 10-20MB, 如果系统内存小于 128M 建议关闭数据库使用.
|
||||||
|
108
coolq/api.go
108
coolq/api.go
@ -1,9 +1,12 @@
|
|||||||
package coolq
|
package coolq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -232,7 +235,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
|
|||||||
if m.Type != gjson.JSON {
|
if m.Type != gjson.JSON {
|
||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
var nodes []*message.ForwardNode
|
var sendNodes []*message.ForwardNode
|
||||||
ts := time.Now().Add(-time.Minute * 5)
|
ts := time.Now().Add(-time.Minute * 5)
|
||||||
hasCustom := func() bool {
|
hasCustom := func() bool {
|
||||||
for _, item := range m.Array() {
|
for _, item := range m.Array() {
|
||||||
@ -242,13 +245,14 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}()
|
}()
|
||||||
convert := func(e gjson.Result) {
|
var convert func(e gjson.Result) []*message.ForwardNode
|
||||||
|
convert = func(e gjson.Result) (nodes []*message.ForwardNode) {
|
||||||
if e.Get("type").Str != "node" {
|
if e.Get("type").Str != "node" {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
ts.Add(time.Second)
|
ts.Add(time.Second)
|
||||||
if e.Get("data.id").Exists() {
|
if e.Get("data.id").Exists() {
|
||||||
i, _ := strconv.Atoi(e.Get("data.id").Str)
|
i, _ := strconv.Atoi(e.Get("data.id").String())
|
||||||
m := bot.GetMessage(int32(i))
|
m := bot.GetMessage(int32(i))
|
||||||
if m != nil {
|
if m != nil {
|
||||||
sender := m["sender"].(message.Sender)
|
sender := m["sender"].(message.Sender)
|
||||||
@ -270,12 +274,36 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
|
|||||||
}
|
}
|
||||||
uin, _ := strconv.ParseInt(e.Get("data.uin").Str, 10, 64)
|
uin, _ := strconv.ParseInt(e.Get("data.uin").Str, 10, 64)
|
||||||
name := e.Get("data.name").Str
|
name := e.Get("data.name").Str
|
||||||
|
c := e.Get("data.content")
|
||||||
|
if c.IsArray() {
|
||||||
|
flag := false
|
||||||
|
c.ForEach(func(_, value gjson.Result) bool {
|
||||||
|
if value.Get("type").String() == "node" {
|
||||||
|
flag = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
if flag {
|
||||||
|
var taowa []*message.ForwardNode
|
||||||
|
for _, item := range c.Array() {
|
||||||
|
taowa = append(taowa, convert(item)...)
|
||||||
|
}
|
||||||
|
nodes = append(nodes, &message.ForwardNode{
|
||||||
|
SenderId: uin,
|
||||||
|
SenderName: name,
|
||||||
|
Time: int32(ts.Unix()),
|
||||||
|
Message: []message.IMessageElement{bot.Client.UploadGroupForwardMessage(groupId, &message.ForwardMessage{Nodes: taowa})},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
content := bot.ConvertObjectMessage(e.Get("data.content"), true)
|
content := bot.ConvertObjectMessage(e.Get("data.content"), true)
|
||||||
if uin != 0 && name != "" && len(content) > 0 {
|
if uin != 0 && name != "" && len(content) > 0 {
|
||||||
var newElem []message.IMessageElement
|
var newElem []message.IMessageElement
|
||||||
for _, elem := range content {
|
for _, elem := range content {
|
||||||
if img, ok := elem.(*message.ImageElement); ok {
|
if img, ok := elem.(*LocalImageElement); ok {
|
||||||
gm, err := bot.Client.UploadGroupImage(groupId, img.Data)
|
gm, err := bot.Client.UploadGroupImage(groupId, img.Stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告:群 %v 图片上传失败: %v", groupId, err)
|
log.Warnf("警告:群 %v 图片上传失败: %v", groupId, err)
|
||||||
continue
|
continue
|
||||||
@ -294,16 +322,17 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Warnf("警告: 非法 Forward node 将跳过")
|
log.Warnf("警告: 非法 Forward node 将跳过")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if m.IsArray() {
|
if m.IsArray() {
|
||||||
for _, item := range m.Array() {
|
for _, item := range m.Array() {
|
||||||
convert(item)
|
sendNodes = append(sendNodes, convert(item)...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
convert(m)
|
sendNodes = convert(m)
|
||||||
}
|
}
|
||||||
if len(nodes) > 0 {
|
if len(sendNodes) > 0 {
|
||||||
gm := bot.Client.SendGroupForwardMessage(groupId, &message.ForwardMessage{Nodes: nodes})
|
gm := bot.Client.SendGroupForwardMessage(groupId, &message.ForwardMessage{Nodes: sendNodes})
|
||||||
return OK(MSG{
|
return OK(MSG{
|
||||||
"message_id": ToGlobalId(groupId, gm.Id),
|
"message_id": ToGlobalId(groupId, gm.Id),
|
||||||
})
|
})
|
||||||
@ -428,6 +457,17 @@ func (bot *CQBot) CQSetGroupLeave(groupId int64) MSG {
|
|||||||
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) CQGetAtAllRemain(groupId int64) MSG {
|
||||||
|
if g := bot.Client.FindGroup(groupId); g != nil {
|
||||||
|
i, err := bot.Client.GetAtAllRemain(groupId)
|
||||||
|
if err != nil {
|
||||||
|
return Failed(100, "GROUP_REMAIN_API_ERROR", err.Error())
|
||||||
|
}
|
||||||
|
return OK(i)
|
||||||
|
}
|
||||||
|
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
||||||
|
}
|
||||||
|
|
||||||
// https://cqhttp.cc/docs/4.15/#/API?id=set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
// https://cqhttp.cc/docs/4.15/#/API?id=set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
|
||||||
func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG {
|
func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG {
|
||||||
req, ok := bot.friendReqCache.Load(flag)
|
req, ok := bot.friendReqCache.Load(flag)
|
||||||
@ -704,6 +744,25 @@ func (bot *CQBot) CQGetImage(file string) MSG {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) CQDownloadFile(url string, headers map[string]string, threadCount int) MSG {
|
||||||
|
hash := md5.Sum([]byte(url))
|
||||||
|
file := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache")
|
||||||
|
if global.PathExists(file) {
|
||||||
|
if err := os.Remove(file); err != nil {
|
||||||
|
log.Warnf("删除缓存文件 %v 时出现错误: %v", file, err)
|
||||||
|
return Failed(100, "DELETE_FILE_ERROR", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := global.DownloadFileMultiThreading(url, file, 0, threadCount, headers); err != nil {
|
||||||
|
log.Warnf("下载链接 %v 时出现错误: %v", url, err)
|
||||||
|
return Failed(100, "DOWNLOAD_FILE_ERROR", err.Error())
|
||||||
|
}
|
||||||
|
abs, _ := filepath.Abs(file)
|
||||||
|
return OK(MSG{
|
||||||
|
"file": abs,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (bot *CQBot) CQGetForwardMessage(resId string) MSG {
|
func (bot *CQBot) CQGetForwardMessage(resId string) MSG {
|
||||||
m := bot.Client.GetForwardMessage(resId)
|
m := bot.Client.GetForwardMessage(resId)
|
||||||
if m == nil {
|
if m == nil {
|
||||||
@ -739,11 +798,18 @@ func (bot *CQBot) CQGetMessage(messageId int32) MSG {
|
|||||||
"real_id": msg["message-id"],
|
"real_id": msg["message-id"],
|
||||||
"group": isGroup,
|
"group": isGroup,
|
||||||
"group_id": gid,
|
"group_id": gid,
|
||||||
|
"message_type": func() string {
|
||||||
|
if isGroup {
|
||||||
|
return "group"
|
||||||
|
}
|
||||||
|
return "private"
|
||||||
|
}(),
|
||||||
"sender": MSG{
|
"sender": MSG{
|
||||||
"user_id": sender.Uin,
|
"user_id": sender.Uin,
|
||||||
"nickname": sender.Nickname,
|
"nickname": sender.Nickname,
|
||||||
},
|
},
|
||||||
"time": msg["time"],
|
"time": msg["time"],
|
||||||
|
"raw_message": raw,
|
||||||
"message": ToFormattedMessage(bot.ConvertStringMessage(raw, isGroup), func() int64 {
|
"message": ToFormattedMessage(bot.ConvertStringMessage(raw, isGroup), func() int64 {
|
||||||
if isGroup {
|
if isGroup {
|
||||||
return gid.(int64)
|
return gid.(int64)
|
||||||
@ -802,6 +868,26 @@ func (bot *CQBot) CQSetGroupPortrait(groupId int64, file, cache string) MSG {
|
|||||||
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) CQSetGroupAnonymousBan(groupId int64, flag string, duration int32) MSG {
|
||||||
|
if flag == "" {
|
||||||
|
return Failed(100, "INVALID_FLAG", "无效的flag")
|
||||||
|
}
|
||||||
|
if g := bot.Client.FindGroup(groupId); g != nil {
|
||||||
|
s := strings.SplitN(flag, "|", 2)
|
||||||
|
if len(s) != 2 {
|
||||||
|
return Failed(100, "INVALID_FLAG", "无效的flag")
|
||||||
|
}
|
||||||
|
id := s[0]
|
||||||
|
nick := s[1]
|
||||||
|
if err := g.MuteAnonymous(id, nick, duration); err != nil {
|
||||||
|
log.Warnf("anonymous ban error: %v", err)
|
||||||
|
return Failed(100, "CALL_API_ERROR", err.Error())
|
||||||
|
}
|
||||||
|
return OK(nil)
|
||||||
|
}
|
||||||
|
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
|
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
|
||||||
func (bot *CQBot) CQGetStatus() MSG {
|
func (bot *CQBot) CQGetStatus() MSG {
|
||||||
return OK(MSG{
|
return OK(MSG{
|
||||||
|
32
coolq/bot.go
32
coolq/bot.go
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sync"
|
"sync"
|
||||||
@ -88,7 +89,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot {
|
|||||||
"self_id": bot.Client.Uin,
|
"self_id": bot.Client.Uin,
|
||||||
"post_type": "meta_event",
|
"post_type": "meta_event",
|
||||||
"meta_event_type": "heartbeat",
|
"meta_event_type": "heartbeat",
|
||||||
"status": nil,
|
"status": bot.CQGetStatus()["data"],
|
||||||
"interval": 1000 * i,
|
"interval": 1000 * i,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -117,11 +118,30 @@ func (bot *CQBot) GetMessage(mid int32) MSG {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error) {
|
||||||
|
if img.Stream != nil {
|
||||||
|
return bot.Client.UploadGroupImage(groupCode, img.Stream)
|
||||||
|
}
|
||||||
|
return bot.Client.UploadGroupImageByFile(groupCode, img.File)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) UploadLocalImageAsPrivate(userId int64, img *LocalImageElement) (*message.FriendImageElement, error) {
|
||||||
|
if img.Stream != nil {
|
||||||
|
return bot.Client.UploadPrivateImage(userId, img.Stream)
|
||||||
|
}
|
||||||
|
// need update.
|
||||||
|
f, err := os.Open(img.File)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bot.Client.UploadPrivateImage(userId, f)
|
||||||
|
}
|
||||||
|
|
||||||
func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int32 {
|
func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int32 {
|
||||||
var newElem []message.IMessageElement
|
var newElem []message.IMessageElement
|
||||||
for _, elem := range m.Elements {
|
for _, elem := range m.Elements {
|
||||||
if i, ok := elem.(*message.ImageElement); ok {
|
if i, ok := elem.(*LocalImageElement); ok {
|
||||||
gm, err := bot.Client.UploadGroupImage(groupId, i.Data)
|
gm, err := bot.UploadLocalImageAsGroup(groupId, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告: 群 %v 消息图片上传失败: %v", groupId, err)
|
log.Warnf("警告: 群 %v 消息图片上传失败: %v", groupId, err)
|
||||||
continue
|
continue
|
||||||
@ -130,7 +150,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if i, ok := elem.(*message.VoiceElement); ok {
|
if i, ok := elem.(*message.VoiceElement); ok {
|
||||||
gv, err := bot.Client.UploadGroupPtt(groupId, i.Data)
|
gv, err := bot.Client.UploadGroupPtt(groupId, bytes.NewReader(i.Data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告: 群 %v 消息语音上传失败: %v", groupId, err)
|
log.Warnf("警告: 群 %v 消息语音上传失败: %v", groupId, err)
|
||||||
continue
|
continue
|
||||||
@ -236,8 +256,8 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
|
|||||||
func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) int32 {
|
func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) int32 {
|
||||||
var newElem []message.IMessageElement
|
var newElem []message.IMessageElement
|
||||||
for _, elem := range m.Elements {
|
for _, elem := range m.Elements {
|
||||||
if i, ok := elem.(*message.ImageElement); ok {
|
if i, ok := elem.(*LocalImageElement); ok {
|
||||||
fm, err := bot.Client.UploadPrivateImage(target, i.Data)
|
fm, err := bot.UploadLocalImageAsPrivate(target, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告: 私聊 %v 消息图片上传失败.", target)
|
log.Warnf("警告: 私聊 %v 消息图片上传失败.", target)
|
||||||
continue
|
continue
|
||||||
|
@ -8,9 +8,12 @@ import (
|
|||||||
xml2 "encoding/xml"
|
xml2 "encoding/xml"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -30,6 +33,9 @@ var paramReg = regexp.MustCompile(`,([\w\-.]+?)=([^,\]]+)`)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var IgnoreInvalidCQCode = false
|
var IgnoreInvalidCQCode = false
|
||||||
|
var SplitUrl = false
|
||||||
|
|
||||||
|
const maxImageSize = 1024 * 1024 * 30 // 30MB
|
||||||
|
|
||||||
type PokeElement struct {
|
type PokeElement struct {
|
||||||
Target int64
|
Target int64
|
||||||
@ -60,6 +66,17 @@ type MiguMusicElement struct {
|
|||||||
MusicElement
|
MusicElement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LocalImageElement struct {
|
||||||
|
message.ImageElement
|
||||||
|
Stream io.ReadSeeker
|
||||||
|
File string
|
||||||
|
}
|
||||||
|
|
||||||
|
type LocalVoiceElement struct {
|
||||||
|
message.VoiceElement
|
||||||
|
Stream io.ReadSeeker
|
||||||
|
}
|
||||||
|
|
||||||
func (e *GiftElement) Type() message.ElementType {
|
func (e *GiftElement) Type() message.ElementType {
|
||||||
return message.At
|
return message.At
|
||||||
}
|
}
|
||||||
@ -90,6 +107,7 @@ func (e *PokeElement) Type() message.ElementType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []MSG) {
|
func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []MSG) {
|
||||||
|
r = []MSG{}
|
||||||
ur := false
|
ur := false
|
||||||
if len(raw) != 0 {
|
if len(raw) != 0 {
|
||||||
ur = raw[0]
|
ur = raw[0]
|
||||||
@ -342,7 +360,13 @@ func (bot *CQBot) ConvertStringMessage(msg string, group bool) (r []message.IMes
|
|||||||
}
|
}
|
||||||
saveTempText := func() {
|
saveTempText := func() {
|
||||||
if len(tempText) != 0 {
|
if len(tempText) != 0 {
|
||||||
r = append(r, message.NewText(CQCodeUnescapeValue(string(tempText))))
|
if SplitUrl {
|
||||||
|
for _, t := range global.SplitUrl(CQCodeUnescapeValue(string(tempText))) {
|
||||||
|
r = append(r, message.NewText(t))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r = append(r, message.NewText(CQCodeUnescapeValue(string(tempText))))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tempText = []rune{}
|
tempText = []rune{}
|
||||||
cqCode = []rune{}
|
cqCode = []rune{}
|
||||||
@ -394,6 +418,12 @@ func (bot *CQBot) ConvertStringMessage(msg string, group bool) (r []message.IMes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if t == "forward" { // 单独处理转发
|
||||||
|
if id, ok := params["id"]; ok {
|
||||||
|
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(id)}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
elem, err := bot.ToElement(t, params, group)
|
elem, err := bot.ToElement(t, params, group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
org := "[" + string(cqCode) + "]"
|
org := "[" + string(cqCode) + "]"
|
||||||
@ -467,6 +497,10 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if t == "forward" {
|
||||||
|
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(e.Get("data.id").String())}
|
||||||
|
return
|
||||||
|
}
|
||||||
d := make(map[string]string)
|
d := make(map[string]string)
|
||||||
e.Get("data").ForEach(func(key, value gjson.Result) bool {
|
e.Get("data").ForEach(func(key, value gjson.Result) bool {
|
||||||
d[key.Str] = value.String()
|
d[key.Str] = value.String()
|
||||||
@ -483,7 +517,6 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.
|
|||||||
case []message.IMessageElement:
|
case []message.IMessageElement:
|
||||||
r = append(r, i...)
|
r = append(r, i...)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if m.Type == gjson.String {
|
if m.Type == gjson.String {
|
||||||
return bot.ConvertStringMessage(m.Str, group)
|
return bot.ConvertStringMessage(m.Str, group)
|
||||||
@ -505,6 +538,13 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.
|
|||||||
func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interface{}, err error) {
|
func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interface{}, err error) {
|
||||||
switch t {
|
switch t {
|
||||||
case "text":
|
case "text":
|
||||||
|
if SplitUrl {
|
||||||
|
var ret []message.IMessageElement
|
||||||
|
for _, text := range global.SplitUrl(d["text"]) {
|
||||||
|
ret = append(ret, message.NewText(text))
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
return message.NewText(d["text"]), nil
|
return message.NewText(d["text"]), nil
|
||||||
case "image":
|
case "image":
|
||||||
img, err := bot.makeImageElem(d, group)
|
img, err := bot.makeImageElem(d, group)
|
||||||
@ -515,11 +555,11 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
|
|||||||
if tp != "show" && tp != "flash" {
|
if tp != "show" && tp != "flash" {
|
||||||
return img, nil
|
return img, nil
|
||||||
}
|
}
|
||||||
if i, ok := img.(*message.ImageElement); ok { // 秀图,闪照什么的就直接传了吧
|
if i, ok := img.(*LocalImageElement); ok { // 秀图,闪照什么的就直接传了吧
|
||||||
if group {
|
if group {
|
||||||
img, err = bot.Client.UploadGroupImage(1, i.Data)
|
img, err = bot.UploadLocalImageAsGroup(1, i)
|
||||||
} else {
|
} else {
|
||||||
img, err = bot.Client.UploadPrivateImage(1, i.Data)
|
img, err = bot.UploadLocalImageAsPrivate(1, i)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -573,6 +613,9 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
|
|||||||
case "record":
|
case "record":
|
||||||
f := d["file"]
|
f := d["file"]
|
||||||
data, err := global.FindFile(f, d["cache"], global.VOICE_PATH)
|
data, err := global.FindFile(f, d["cache"], global.VOICE_PATH)
|
||||||
|
if err == global.ErrSyntax {
|
||||||
|
data, err = global.FindFile(f, d["cache"], global.VOICE_PATH_OLD)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -777,30 +820,30 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
f := d["file"]
|
f := d["file"]
|
||||||
if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") {
|
if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") {
|
||||||
cache := d["cache"]
|
cache := d["cache"]
|
||||||
|
c := d["c"]
|
||||||
if cache == "" {
|
if cache == "" {
|
||||||
cache = "1"
|
cache = "1"
|
||||||
}
|
}
|
||||||
hash := md5.Sum([]byte(f))
|
hash := md5.Sum([]byte(f))
|
||||||
cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache")
|
cacheFile := path.Join(global.CACHE_PATH, hex.EncodeToString(hash[:])+".cache")
|
||||||
if global.PathExists(cacheFile) && cache == "1" {
|
if global.PathExists(cacheFile) && cache == "1" {
|
||||||
b, err := ioutil.ReadFile(cacheFile)
|
return &LocalImageElement{File: cacheFile}, nil
|
||||||
if err == nil {
|
|
||||||
return message.NewImage(b), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b, err := global.GetBytes(f)
|
if global.PathExists(cacheFile) {
|
||||||
if err != nil {
|
_ = os.Remove(cacheFile)
|
||||||
|
}
|
||||||
|
thread, _ := strconv.Atoi(c)
|
||||||
|
if err := global.DownloadFileMultiThreading(f, cacheFile, maxImageSize, thread, nil); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
_ = ioutil.WriteFile(cacheFile, b, 0644)
|
return &LocalImageElement{File: cacheFile}, nil
|
||||||
return message.NewImage(b), nil
|
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(f, "base64") {
|
if strings.HasPrefix(f, "base64") {
|
||||||
b, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(f, "base64://", ""))
|
b, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(f, "base64://", ""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return message.NewImage(b), nil
|
return &LocalImageElement{Stream: bytes.NewReader(b)}, nil
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(f, "file") {
|
if strings.HasPrefix(f, "file") {
|
||||||
fu, err := url.Parse(f)
|
fu, err := url.Parse(f)
|
||||||
@ -810,13 +853,19 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
if strings.HasPrefix(fu.Path, "/") && runtime.GOOS == `windows` {
|
if strings.HasPrefix(fu.Path, "/") && runtime.GOOS == `windows` {
|
||||||
fu.Path = fu.Path[1:]
|
fu.Path = fu.Path[1:]
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadFile(fu.Path)
|
info, err := os.Stat(fu.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return message.NewImage(b), nil
|
if info.Size() == 0 || info.Size() >= maxImageSize {
|
||||||
|
return nil, errors.New("invalid image size")
|
||||||
|
}
|
||||||
|
return &LocalImageElement{File: fu.Path}, nil
|
||||||
}
|
}
|
||||||
rawPath := path.Join(global.IMAGE_PATH, f)
|
rawPath := path.Join(global.IMAGE_PATH, f)
|
||||||
|
if !global.PathExists(rawPath) && global.PathExists(path.Join(global.IMAGE_PATH_OLD, f)) {
|
||||||
|
rawPath = path.Join(global.IMAGE_PATH_OLD, f)
|
||||||
|
}
|
||||||
if !global.PathExists(rawPath) && global.PathExists(rawPath+".cqimg") {
|
if !global.PathExists(rawPath) && global.PathExists(rawPath+".cqimg") {
|
||||||
rawPath += ".cqimg"
|
rawPath += ".cqimg"
|
||||||
}
|
}
|
||||||
@ -824,12 +873,16 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
return bot.makeImageElem(map[string]string{"file": d["url"]}, group)
|
return bot.makeImageElem(map[string]string{"file": d["url"]}, group)
|
||||||
}
|
}
|
||||||
if global.PathExists(rawPath) {
|
if global.PathExists(rawPath) {
|
||||||
b, err := ioutil.ReadFile(rawPath)
|
file, err := os.Open(rawPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" {
|
if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" {
|
||||||
return message.NewImage(b), nil
|
return &LocalImageElement{Stream: file}, nil
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(b) < 20 {
|
if len(b) < 20 {
|
||||||
return nil, errors.New("invalid local file")
|
return nil, errors.New("invalid local file")
|
||||||
@ -865,7 +918,7 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
return nil, errors.New("invalid hash")
|
return nil, errors.New("invalid hash")
|
||||||
}
|
}
|
||||||
if group {
|
if group {
|
||||||
rsp, err := bot.Client.QueryGroupImage(1, hash, size)
|
rsp, err := bot.Client.QueryGroupImage(int64(rand.Uint32()), hash, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if url != "" {
|
if url != "" {
|
||||||
return bot.makeImageElem(map[string]string{"file": url}, group)
|
return bot.makeImageElem(map[string]string{"file": url}, group)
|
||||||
@ -874,7 +927,7 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
}
|
}
|
||||||
rsp, err := bot.Client.QueryFriendImage(1, hash, size)
|
rsp, err := bot.Client.QueryFriendImage(int64(rand.Uint32()), hash, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if url != "" {
|
if url != "" {
|
||||||
return bot.makeImageElem(map[string]string{"file": url}, group)
|
return bot.makeImageElem(map[string]string{"file": url}, group)
|
||||||
@ -890,9 +943,9 @@ func (bot *CQBot) makeImageElem(d map[string]string, group bool) (message.IMessa
|
|||||||
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
||||||
xml := ""
|
xml := ""
|
||||||
var suf message.IMessageElement
|
var suf message.IMessageElement
|
||||||
if i, ok := elem.(*message.ImageElement); ok {
|
if i, ok := elem.(*LocalImageElement); ok {
|
||||||
if group == false {
|
if group == false {
|
||||||
gm, err := bot.Client.UploadPrivateImage(1, i.Data)
|
gm, err := bot.Client.UploadPrivateImage(1, i.Stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告: 好友消息 %v 消息图片上传失败: %v", 1, err)
|
log.Warnf("警告: 好友消息 %v 消息图片上传失败: %v", 1, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -900,7 +953,7 @@ func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, icon
|
|||||||
suf = gm
|
suf = gm
|
||||||
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
xml = fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="5" templateID="12345" action="" brief="[分享]我看到一张很赞的图片,分享给你,快来看!" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="0" advertiser_id="0" aid="0"><image uuid="%x" md5="%x" GroupFiledid="0" filesize="%d" local_path="%s" minWidth="%d" minHeight="%d" maxWidth="%d" maxHeight="%d" /></item><source name="%s" icon="%s" action="" appid="-1" /></msg>`, "", gm.Md5, gm.Md5, len(i.Data), "", minWidth, minHeight, maxWidth, maxHeight, source, icon)
|
||||||
} else {
|
} else {
|
||||||
gm, err := bot.Client.UploadGroupImage(1, i.Data)
|
gm, err := bot.Client.UploadGroupImage(1, i.Stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err)
|
log.Warnf("警告: 群 %v 消息图片上传失败: %v", 1, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -114,9 +114,9 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage)
|
|||||||
}
|
}
|
||||||
if m.Sender.IsAnonymous() {
|
if m.Sender.IsAnonymous() {
|
||||||
gm["anonymous"] = MSG{
|
gm["anonymous"] = MSG{
|
||||||
"flag": "",
|
"flag": m.Sender.AnonymousInfo.AnonymousId + "|" + m.Sender.AnonymousInfo.AnonymousNick,
|
||||||
"id": 0,
|
"id": m.Sender.Uin,
|
||||||
"name": m.Sender.Nickname,
|
"name": m.Sender.AnonymousInfo.AnonymousNick,
|
||||||
}
|
}
|
||||||
gm["sender"].(MSG)["nickname"] = "匿名消息"
|
gm["sender"].(MSG)["nickname"] = "匿名消息"
|
||||||
gm["sub_type"] = "anonymous"
|
gm["sub_type"] = "anonymous"
|
||||||
|
@ -78,6 +78,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
|
|||||||
| post_message_format | string | 上报信息类型 |
|
| post_message_format | string | 上报信息类型 |
|
||||||
| ignore_invalid_cqcode | bool | 是否忽略错误的CQ码 |
|
| ignore_invalid_cqcode | bool | 是否忽略错误的CQ码 |
|
||||||
| force_fragmented | bool | 是否强制分片发送群长消息 |
|
| force_fragmented | bool | 是否强制分片发送群长消息 |
|
||||||
|
| fix_url | bool | 是否对链接的发送进行预处理, 可缓解链接信息被风控导致无法发送的情况, 但可能影响客户端着色(不影响内容)|
|
||||||
| use_sso_address | bool | 是否使用服务器下发的地址 |
|
| use_sso_address | bool | 是否使用服务器下发的地址 |
|
||||||
| heartbeat_interval | int64 | 心跳间隔时间,单位秒。小于0则关闭心跳,等于0使用默认值(5秒) |
|
| heartbeat_interval | int64 | 心跳间隔时间,单位秒。小于0则关闭心跳,等于0使用默认值(5秒) |
|
||||||
| http_config | object | HTTP API配置 |
|
| http_config | object | HTTP API配置 |
|
||||||
@ -112,10 +113,10 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
|
|||||||
|
|
||||||
| 值 | 类型 | 限制 |
|
| 值 | 类型 | 限制 |
|
||||||
| --- | ------------- | ---------------------------------------------------------------- |
|
| --- | ------------- | ---------------------------------------------------------------- |
|
||||||
| 0 | iPad | 无 |
|
| 0 | iPad | 无 |
|
||||||
| 1 | Android Phone | 无法接收新版表情如 `/吃瓜 /汪汪`, 会自动转换为字符串 |
|
| 1 | Android Phone | 无 |
|
||||||
| 2 | Android Watch | 除`Android Phone`的限制外, 无法接收 `notify` 事件、无法接收口令红包、无法接收撤回消息 |
|
| 2 | Android Watch | 无法接收 `notify` 事件、无法接收口令红包、无法接收撤回消息 |
|
||||||
| 3 | MacOS | 无 |
|
| 3 | MacOS | 无 |
|
||||||
|
|
||||||
> 注意, 根据协议的不同, 各类消息有所限制
|
> 注意, 根据协议的不同, 各类消息有所限制
|
||||||
|
|
||||||
|
125
docs/cqhttp.md
125
docs/cqhttp.md
@ -37,10 +37,14 @@
|
|||||||
- [获取群文件资源链接](#获取群文件资源链接)
|
- [获取群文件资源链接](#获取群文件资源链接)
|
||||||
- [获取状态](#获取状态)
|
- [获取状态](#获取状态)
|
||||||
- [获取群子目录文件列表](#设置群名)
|
- [获取群子目录文件列表](#设置群名)
|
||||||
|
- [获取用户VIP信息](#获取用户VIP信息)
|
||||||
|
- [发送群公告](#发送群公告)
|
||||||
|
- [重载事件过滤器](#重载事件过滤器)
|
||||||
|
|
||||||
##### 事件
|
##### 事件
|
||||||
- [群消息撤回](#群消息撤回)
|
- [群消息撤回](#群消息撤回)
|
||||||
- [好友消息撤回](#好友消息撤回)
|
- [好友消息撤回](#好友消息撤回)
|
||||||
|
- [好友戳一戳](#好友戳一戳)
|
||||||
- [群内戳一戳](#群内戳一戳)
|
- [群内戳一戳](#群内戳一戳)
|
||||||
- [群红包运气王提示](#群红包运气王提示)
|
- [群红包运气王提示](#群红包运气王提示)
|
||||||
- [群成员荣誉变更提示](#群成员荣誉变更提示)
|
- [群成员荣誉变更提示](#群成员荣誉变更提示)
|
||||||
@ -67,6 +71,7 @@ Type : `image`
|
|||||||
| `url` | - | 图片 URL |
|
| `url` | - | 图片 URL |
|
||||||
| `cache` | `0` `1` | 只在通过网络 URL 发送时有效,表示是否使用已缓存的文件,默认 `1` |
|
| `cache` | `0` `1` | 只在通过网络 URL 发送时有效,表示是否使用已缓存的文件,默认 `1` |
|
||||||
| `id` | - | 发送秀图时的特效id,默认为40000 |
|
| `id` | - | 发送秀图时的特效id,默认为40000 |
|
||||||
|
| `c` | `2` `3` | 通过网络下载图片时的线程数, 默认单线程. (在资源不支持并发时会自动处理)|
|
||||||
|
|
||||||
可用的特效ID:
|
可用的特效ID:
|
||||||
|
|
||||||
@ -81,6 +86,7 @@ Type : `image`
|
|||||||
|
|
||||||
示例: `[CQ:image,file=http://baidu.com/1.jpg,type=show,id=40004]`
|
示例: `[CQ:image,file=http://baidu.com/1.jpg,type=show,id=40004]`
|
||||||
|
|
||||||
|
> 注意:图片总大小不能超过30MB,gif总帧数不能超过300帧
|
||||||
|
|
||||||
### 回复
|
### 回复
|
||||||
|
|
||||||
@ -191,7 +197,7 @@ Type: `node`
|
|||||||
| `id` | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** |
|
| `id` | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** |
|
||||||
| `name` | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) |
|
| `name` | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) |
|
||||||
| `uin` | int64 | 发送者QQ号 | 用于自定义消息 |
|
| `uin` | int64 | 发送者QQ号 | 用于自定义消息 |
|
||||||
| `content` | message | 具体消息 | 用于自定义消息 **不支持转发套娃,不支持引用回复** |
|
| `content` | message | 具体消息 | 用于自定义消息 **不支持引用回复** |
|
||||||
|
|
||||||
特殊说明: **需要使用单独的API `/send_group_forward_msg` 发送,并且由于消息段较为复杂,仅支持Array形式入参。 如果引用消息和自定义消息同时出现,实际查看顺序将取消息段顺序. 另外按 [CQHTTP](https://cqhttp.cc/docs/4.15/#/Message?id=格式) 文档说明, `data` 应全为字符串, 但由于需要接收`message` 类型的消息, 所以 *仅限此Type的content字段* 支持Array套娃**
|
特殊说明: **需要使用单独的API `/send_group_forward_msg` 发送,并且由于消息段较为复杂,仅支持Array形式入参。 如果引用消息和自定义消息同时出现,实际查看顺序将取消息段顺序. 另外按 [CQHTTP](https://cqhttp.cc/docs/4.15/#/Message?id=格式) 文档说明, `data` 应全为字符串, 但由于需要接收`message` 类型的消息, 所以 *仅限此Type的content字段* 支持Array套娃**
|
||||||
|
|
||||||
@ -718,7 +724,7 @@ Type: `tts`
|
|||||||
| `plugins_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
| `plugins_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
| `app_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
| `app_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
| `online` | bool | 表示BOT是否在线 |
|
| `online` | bool | 表示BOT是否在线 |
|
||||||
| `goold` | bool | 同 `online` |
|
| `good` | bool | 同 `online` |
|
||||||
| `stat` | Statistics | 运行统计 |
|
| `stat` | Statistics | 运行统计 |
|
||||||
|
|
||||||
**Statistics**
|
**Statistics**
|
||||||
@ -736,6 +742,106 @@ Type: `tts`
|
|||||||
|
|
||||||
> 注意: 所有统计信息都将在重启后重制
|
> 注意: 所有统计信息都将在重启后重制
|
||||||
|
|
||||||
|
### 获取群@全体成员剩余次数
|
||||||
|
|
||||||
|
终结点: `/get_group_at_all_remain`
|
||||||
|
|
||||||
|
**参数**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ---------- | ------ | ------------------------- |
|
||||||
|
| `group_id` | int64 | 群号 |
|
||||||
|
|
||||||
|
**响应数据**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ------------------------------- | ---------- | ------------------------------- |
|
||||||
|
| `can_at_all` | bool | 是否可以@全体成员 |
|
||||||
|
| `remain_at_all_count_for_group` | int16 | 群内所有管理当天剩余@全体成员次数 |
|
||||||
|
| `remain_at_all_count_for_uin` | int16 | BOT当天剩余@全体成员次数 |
|
||||||
|
|
||||||
|
### 下载文件到缓存目录
|
||||||
|
|
||||||
|
终结点: `/download_file`
|
||||||
|
|
||||||
|
**参数**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ---------- | ------ | ------------------------- |
|
||||||
|
| `url` | string | 链接地址 |
|
||||||
|
| `thread_count` | int32 | 下载线程数 |
|
||||||
|
| `headers` | string or array | 自定义请求头 |
|
||||||
|
|
||||||
|
**`headers`格式:**
|
||||||
|
|
||||||
|
字符串:
|
||||||
|
|
||||||
|
```
|
||||||
|
User-Agent=YOUR_UA[\r\n]Referer=https://www.baidu.com
|
||||||
|
```
|
||||||
|
|
||||||
|
> `[\r\n]` 为换行符, 使用http请求时请注意编码
|
||||||
|
|
||||||
|
JSON数组:
|
||||||
|
|
||||||
|
```
|
||||||
|
[
|
||||||
|
"User-Agent=YOUR_UA",
|
||||||
|
"Referer=https://www.baidu.com",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应数据**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ---------- | ---------- | ------------ |
|
||||||
|
| `file` | string | 下载文件的*绝对路径* |
|
||||||
|
|
||||||
|
> 通过这个API下载的文件能直接放入CQ码作为图片或语音发送
|
||||||
|
> 调用后会阻塞直到下载完成后才会返回数据,请注意下载大文件时的超时
|
||||||
|
|
||||||
|
### 获取用户VIP信息
|
||||||
|
|
||||||
|
终结点:`/_get_vip_info`
|
||||||
|
|
||||||
|
**参数**
|
||||||
|
|
||||||
|
| 字段名 | 数据类型 | 默认值 | 说明 |
|
||||||
|
| ----- | ------- | ----- | --- |
|
||||||
|
| `user_id` | int64 | | QQ 号 |
|
||||||
|
|
||||||
|
**响应数据**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ------------------ | ------- | ---------- |
|
||||||
|
| `user_id` | int64 | QQ 号 |
|
||||||
|
| `nickname` | string | 用户昵称 |
|
||||||
|
| `level` | int64 | QQ 等级 |
|
||||||
|
| `level_speed` | float64 | 等级加速度 |
|
||||||
|
| `vip_level` | string | 会员等级 |
|
||||||
|
| `vip_growth_speed` | int64 | 会员成长速度 |
|
||||||
|
| `vip_growth_total` | int64 | 会员成长总值 |
|
||||||
|
|
||||||
|
### 发送群公告
|
||||||
|
|
||||||
|
终结点: `/_send_group_notice`
|
||||||
|
|
||||||
|
**参数**
|
||||||
|
|
||||||
|
| 字段名 | 数据类型 | 默认值 | 说明 |
|
||||||
|
| ---------- | ------- | ----- | ------ |
|
||||||
|
| `group_id` | int64 | | 群号 |
|
||||||
|
| `content` | string | | 公告内容 |
|
||||||
|
|
||||||
|
`该 API 没有响应数据`
|
||||||
|
|
||||||
|
### 重载事件过滤器
|
||||||
|
|
||||||
|
终结点:`/reload_event_filter`
|
||||||
|
|
||||||
|
`该 API 无需参数也没有响应数据`
|
||||||
|
|
||||||
|
|
||||||
## 事件
|
## 事件
|
||||||
|
|
||||||
### 群消息撤回
|
### 群消息撤回
|
||||||
@ -762,6 +868,21 @@ Type: `tts`
|
|||||||
| `user_id` | int64 | | 好友id |
|
| `user_id` | int64 | | 好友id |
|
||||||
| `message_id` | int64 | | 被撤回的消息id |
|
| `message_id` | int64 | | 被撤回的消息id |
|
||||||
|
|
||||||
|
## 好友戳一戳
|
||||||
|
|
||||||
|
**事件数据**
|
||||||
|
|
||||||
|
| 字段名 | 数据类型 | 可能的值 | 说明 |
|
||||||
|
| ------------- | ------ | -------- | --- |
|
||||||
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
|
| `notice_type` | string | `notify` | 消息类型 |
|
||||||
|
| `sub_type` | string | `poke` | 提示类型 |
|
||||||
|
| `self_id` | int64 | | BOT QQ 号 |
|
||||||
|
| `sender_id` | int64 | | 发送者 QQ 号 |
|
||||||
|
| `user_id` | int64 | | 发送者 QQ 号 |
|
||||||
|
| `target_id` | int64 | | 被戳者 QQ 号 |
|
||||||
|
| `time` | int64 | | 时间 |
|
||||||
|
|
||||||
### 群内戳一戳
|
### 群内戳一戳
|
||||||
|
|
||||||
> 注意:此事件无法在平板和手表协议上触发
|
> 注意:此事件无法在平板和手表协议上触发
|
||||||
|
@ -107,6 +107,14 @@ enable ws?(Y/n)
|
|||||||
|
|
||||||
# 进阶指南
|
# 进阶指南
|
||||||
|
|
||||||
|
## 跳过启动的五秒延时
|
||||||
|
|
||||||
|
使用命令行参数 `faststart`即可跳过启动的五秒钟延时,例如
|
||||||
|
|
||||||
|
```
|
||||||
|
.\go-cqhttp.exe faststart
|
||||||
|
```
|
||||||
|
|
||||||
## 如何自己构建
|
## 如何自己构建
|
||||||
|
|
||||||
1. [下载源码](https://github.com/Mrs4s/go-cqhttp/archive/master.zip)并解压 || 使用`git clone https://github.com/Mrs4s/go-cqhttp.git`来拉取
|
1. [下载源码](https://github.com/Mrs4s/go-cqhttp/archive/master.zip)并解压 || 使用`git clone https://github.com/Mrs4s/go-cqhttp.git`来拉取
|
||||||
|
74
docs/slider.md
Normal file
74
docs/slider.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# 滑块验证码
|
||||||
|
|
||||||
|
由于TX最新的限制, 所有协议在陌生设备/IP登录时都有可能被要求通过滑块验证码, 否则将会出现 `当前上网环境异常` 的错误. 目前我们准备了两个临时方案应对该验证码.
|
||||||
|
|
||||||
|
> 如果您有一台运行Windows的PC/Server 并且不会抓包操作, 我们建议直接使用方案B
|
||||||
|
|
||||||
|
## 方案A: 自行抓包
|
||||||
|
|
||||||
|
由于滑块验证码和QQ本体的协议独立, 我们无法直接处理并提交. 需要在浏览器通过后抓包并获取 `Ticket` 提交.
|
||||||
|
|
||||||
|
该方案为具体的抓包教程, 如果您已经知道如何在浏览器中抓包. 可以略过接下来的文档并直接抓取 `cap_union_new_verify` 的返回值, 提取 `Ticket` 并在命令行提交.
|
||||||
|
|
||||||
|
首先获取滑块验证码的地址, 并在浏览器中打开. 这里以 *Microsoft Edge* 浏览器为例, *Chrome* 同理.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
首先选择 `1` 并提取链接在浏览器中打开
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
此时不要滑动验证码, 首先按下 `F12` (键盘右上角退格键上方) 打开 *开发者工具*
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击 `Network` 选项卡 (在某些浏览器它可能叫做 `网络`)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点开 `Filter` (箭头) 按钮以确定您能看到下面的工具栏, 勾选 `Preserve log`(红框)
|
||||||
|
|
||||||
|
此时可以滑动并通过验证码
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
回到 *开发者工具*, 我们可以看到已经有了一个请求.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
此时如果有多个请求, 请不要慌张. 看到上面的 `Filter` 没? 此时在 `Filter` 输入框中输入 `cap_union_new`, 就应该只剩一个请求了.
|
||||||
|
|
||||||
|
然后点击该请求. 点开 `Preview` 选项卡 (箭头):
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
此时就能看到一个标准的 `JSON`, 复制 `ticket` 字段并回到 `go-cqhttp` 粘贴. 即可通过滑块验证.
|
||||||
|
|
||||||
|
如果您看到这里还是不会如何操作, 没关系! 我们还准备了方案B.
|
||||||
|
|
||||||
|
## 方案B: 使用专用工具
|
||||||
|
|
||||||
|
此方案需要您有一台可以操作的 `Windows` 电脑.
|
||||||
|
|
||||||
|
首先下载工具: [蓝奏云](https://wws.lanzous.com/i2vn0jrofte) [Google Drive](https://drive.google.com/file/d/1peMDHqgP8AgWBVp5vP-cfhcGrb2ksSrE/view?usp=sharing)
|
||||||
|
|
||||||
|
解压并打开工具:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
打开 `go-cqhttp` 并选择 `2`:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
复制 `ID` 并前往工具粘贴:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击 `OK` 并处理滑块, 完成即可登录成功. (OK可能反应稍微慢点, 请不要多次点击)
|
||||||
|
|
||||||
|

|
||||||
|
|
@ -153,6 +153,7 @@ type JsonConfig struct {
|
|||||||
} `json:"_rate_limit"`
|
} `json:"_rate_limit"`
|
||||||
IgnoreInvalidCQCode bool `json:"ignore_invalid_cqcode"`
|
IgnoreInvalidCQCode bool `json:"ignore_invalid_cqcode"`
|
||||||
ForceFragmented bool `json:"force_fragmented"`
|
ForceFragmented bool `json:"force_fragmented"`
|
||||||
|
FixUrl bool `json:"fix_url"`
|
||||||
ProxyRewrite string `json:"proxy_rewrite"`
|
ProxyRewrite string `json:"proxy_rewrite"`
|
||||||
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
|
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
|
||||||
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
type MSG map[string]interface{}
|
type MSG map[string]interface{}
|
||||||
|
|
||||||
func (m MSG) Get(s string) MSG {
|
func (m MSG) Get(s string) MSG {
|
||||||
if v,ok := m[s];ok {
|
if v, ok := m[s]; ok {
|
||||||
if msg,ok := v.(MSG);ok {
|
if msg, ok := v.(MSG); ok {
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
return MSG{"__str__": v} // 用这个名字应该没问题吧
|
return MSG{"__str__": v} // 用这个名字应该没问题吧
|
||||||
@ -23,7 +23,7 @@ func (m MSG) Get(s string) MSG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m MSG) String() string {
|
func (m MSG) String() string {
|
||||||
if str,ok:=m["__str__"];ok {
|
if str, ok := m["__str__"]; ok {
|
||||||
return fmt.Sprint(str)
|
return fmt.Sprint(str)
|
||||||
}
|
}
|
||||||
str, _ := json.MarshalToString(m)
|
str, _ := json.MarshalToString(m)
|
||||||
|
92
global/fs.go
92
global/fs.go
@ -1,17 +1,22 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/bzip2"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/kardianos/osext"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -21,13 +26,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
IMAGE_PATH = path.Join("data", "images")
|
IMAGE_PATH = path.Join("data", "images")
|
||||||
VOICE_PATH = path.Join("data", "voices")
|
IMAGE_PATH_OLD = path.Join("data", "image")
|
||||||
VIDEO_PATH = path.Join("data", "videos")
|
VOICE_PATH = path.Join("data", "voices")
|
||||||
CACHE_PATH = path.Join("data", "cache")
|
VOICE_PATH_OLD = path.Join("data", "record")
|
||||||
|
VIDEO_PATH = path.Join("data", "videos")
|
||||||
|
CACHE_PATH = path.Join("data", "cache")
|
||||||
|
|
||||||
HEADER_AMR = []byte("#!AMR")
|
HEADER_AMR = []byte("#!AMR")
|
||||||
HEADER_SILK = []byte("\x02#!SILK_V3")
|
HEADER_SILK = []byte("\x02#!SILK_V3")
|
||||||
|
|
||||||
|
ErrSyntax = errors.New("syntax error")
|
||||||
)
|
)
|
||||||
|
|
||||||
func PathExists(path string) bool {
|
func PathExists(path string) bool {
|
||||||
@ -58,7 +67,7 @@ func IsAMRorSILK(b []byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FindFile(f, cache, PATH string) (data []byte, err error) {
|
func FindFile(f, cache, PATH string) (data []byte, err error) {
|
||||||
data, err = nil, errors.New("syntax error")
|
data, err = nil, ErrSyntax
|
||||||
if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") {
|
if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") {
|
||||||
if cache == "" {
|
if cache == "" {
|
||||||
cache = "1"
|
cache = "1"
|
||||||
@ -146,3 +155,76 @@ func (wc WriteCounter) PrintProgress() {
|
|||||||
fmt.Printf("\r%s", strings.Repeat(" ", 35))
|
fmt.Printf("\r%s", strings.Repeat(" ", 35))
|
||||||
fmt.Printf("\rDownloading... %s complete", humanize.Bytes(wc.Total))
|
fmt.Printf("\rDownloading... %s complete", humanize.Bytes(wc.Total))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateFromStream copy form getlantern/go-update
|
||||||
|
func UpdateFromStream(updateWith io.Reader) (err error, errRecover error) {
|
||||||
|
updatePath, err := osext.Executable()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var newBytes []byte
|
||||||
|
// no patch to apply, go on through
|
||||||
|
var fileHeader []byte
|
||||||
|
bufBytes := bufio.NewReader(updateWith)
|
||||||
|
fileHeader, err = bufBytes.Peek(2)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// The content is always bzip2 compressed except when running test, in
|
||||||
|
// which case is not prefixed with the magic byte sequence for sure.
|
||||||
|
if bytes.Equal([]byte{0x42, 0x5a}, fileHeader) {
|
||||||
|
// Identifying bzip2 files.
|
||||||
|
updateWith = bzip2.NewReader(bufBytes)
|
||||||
|
} else {
|
||||||
|
updateWith = io.Reader(bufBytes)
|
||||||
|
}
|
||||||
|
newBytes, err = ioutil.ReadAll(updateWith)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// get the directory the executable exists in
|
||||||
|
updateDir := filepath.Dir(updatePath)
|
||||||
|
filename := filepath.Base(updatePath)
|
||||||
|
// Copy the contents of of newbinary to a the new executable file
|
||||||
|
newPath := filepath.Join(updateDir, fmt.Sprintf(".%s.new", filename))
|
||||||
|
fp, err := os.OpenFile(newPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// We won't log this error, because it's always going to happen.
|
||||||
|
defer func() { _ = fp.Close() }()
|
||||||
|
if _, err = io.Copy(fp, bytes.NewReader(newBytes)); err != nil {
|
||||||
|
log.Errorf("Unable to copy data: %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we don't call fp.Close(), windows won't let us move the new executable
|
||||||
|
// because the file will still be "in use"
|
||||||
|
if err := fp.Close(); err != nil {
|
||||||
|
log.Errorf("Unable to close file: %v\n", err)
|
||||||
|
}
|
||||||
|
// this is where we'll move the executable to so that we can swap in the updated replacement
|
||||||
|
oldPath := filepath.Join(updateDir, fmt.Sprintf(".%s.old", filename))
|
||||||
|
|
||||||
|
// delete any existing old exec file - this is necessary on Windows for two reasons:
|
||||||
|
// 1. after a successful update, Windows can't remove the .old file because the process is still running
|
||||||
|
// 2. windows rename operations fail if the destination file already exists
|
||||||
|
_ = os.Remove(oldPath)
|
||||||
|
|
||||||
|
// move the existing executable to a new file in the same directory
|
||||||
|
err = os.Rename(updatePath, oldPath)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// move the new exectuable in to become the new program
|
||||||
|
err = os.Rename(newPath, updatePath)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
// copy unsuccessful
|
||||||
|
errRecover = os.Rename(oldPath, updatePath)
|
||||||
|
} else {
|
||||||
|
// copy successful, remove the old binary
|
||||||
|
_ = os.Remove(oldPath)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
244
global/net.go
244
global/net.go
@ -1,42 +1,53 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/guonaihong/gout"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client = &http.Client{
|
var (
|
||||||
Timeout: time.Second * 15,
|
client = &http.Client{
|
||||||
Transport: &http.Transport{
|
Timeout: time.Second * 30,
|
||||||
Proxy: func(request *http.Request) (u *url.URL, e error) {
|
Transport: &http.Transport{
|
||||||
if Proxy == "" {
|
Proxy: func(request *http.Request) (u *url.URL, e error) {
|
||||||
return http.ProxyFromEnvironment(request)
|
if Proxy == "" {
|
||||||
}
|
return http.ProxyFromEnvironment(request)
|
||||||
return url.Parse(Proxy)
|
}
|
||||||
|
return url.Parse(Proxy)
|
||||||
|
},
|
||||||
|
DialContext: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).DialContext,
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
MaxConnsPerHost: 0,
|
||||||
|
MaxIdleConns: 0,
|
||||||
|
MaxIdleConnsPerHost: 999,
|
||||||
},
|
},
|
||||||
DialContext: (&net.Dialer{
|
}
|
||||||
Timeout: 30 * time.Second,
|
Proxy string
|
||||||
KeepAlive: 30 * time.Second,
|
|
||||||
DualStack: true,
|
|
||||||
}).DialContext,
|
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
MaxIdleConns: 100,
|
|
||||||
IdleConnTimeout: 90 * time.Second,
|
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var Proxy string
|
ErrOverSize = errors.New("oversize")
|
||||||
|
)
|
||||||
|
|
||||||
func GetBytes(url string) ([]byte, error) {
|
func GetBytes(url string) ([]byte, error) {
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
@ -63,6 +74,197 @@ func GetBytes(url string) ([]byte, error) {
|
|||||||
return body, nil
|
return body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DownloadFile(url, path string, limit int64) error {
|
||||||
|
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if limit > 0 && resp.ContentLength > limit {
|
||||||
|
return ErrOverSize
|
||||||
|
}
|
||||||
|
_, err = io.Copy(file, resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DownloadFileMultiThreading(url, path string, limit int64, threadCount int, headers map[string]string) error {
|
||||||
|
if threadCount < 2 {
|
||||||
|
return DownloadFile(url, path, limit)
|
||||||
|
}
|
||||||
|
type BlockMetaData struct {
|
||||||
|
BeginOffset int64
|
||||||
|
EndOffset int64
|
||||||
|
DownloadedSize int64
|
||||||
|
}
|
||||||
|
var blocks []*BlockMetaData
|
||||||
|
var contentLength int64
|
||||||
|
errUnsupportedMultiThreading := errors.New("unsupported multi-threading")
|
||||||
|
// 初始化分块或直接下载
|
||||||
|
initOrDownload := func() error {
|
||||||
|
copyStream := func(s io.ReadCloser) error {
|
||||||
|
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
if _, err = io.Copy(file, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return errUnsupportedMultiThreading
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if headers != nil {
|
||||||
|
for k, v := range headers {
|
||||||
|
req.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.Header.Set("range", "bytes=0-")
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||||
|
return errors.New("response status unsuccessful: " + strconv.FormatInt(int64(resp.StatusCode), 10))
|
||||||
|
}
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
if limit > 0 && resp.ContentLength > limit {
|
||||||
|
return ErrOverSize
|
||||||
|
}
|
||||||
|
return copyStream(resp.Body)
|
||||||
|
}
|
||||||
|
if resp.StatusCode == 206 {
|
||||||
|
contentLength = resp.ContentLength
|
||||||
|
if limit > 0 && resp.ContentLength > limit {
|
||||||
|
return ErrOverSize
|
||||||
|
}
|
||||||
|
blockSize := func() int64 {
|
||||||
|
if contentLength > 1024*1024 {
|
||||||
|
return (contentLength / int64(threadCount)) - 10
|
||||||
|
} else {
|
||||||
|
return contentLength
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if blockSize == contentLength {
|
||||||
|
return copyStream(resp.Body)
|
||||||
|
}
|
||||||
|
var tmp int64
|
||||||
|
for tmp+blockSize < contentLength {
|
||||||
|
blocks = append(blocks, &BlockMetaData{
|
||||||
|
BeginOffset: tmp,
|
||||||
|
EndOffset: tmp + blockSize - 1,
|
||||||
|
})
|
||||||
|
tmp += blockSize
|
||||||
|
}
|
||||||
|
blocks = append(blocks, &BlockMetaData{
|
||||||
|
BeginOffset: tmp,
|
||||||
|
EndOffset: contentLength - 1,
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("unknown status code.")
|
||||||
|
}
|
||||||
|
// 下载分块
|
||||||
|
downloadBlock := func(block *BlockMetaData) error {
|
||||||
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
|
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
_, _ = file.Seek(block.BeginOffset, io.SeekStart)
|
||||||
|
writer := bufio.NewWriter(file)
|
||||||
|
defer writer.Flush()
|
||||||
|
if headers != nil {
|
||||||
|
for k, v := range headers {
|
||||||
|
req.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.Header.Set("range", "bytes="+strconv.FormatInt(block.BeginOffset, 10)+"-"+strconv.FormatInt(block.EndOffset, 10))
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||||
|
return errors.New("response status unsuccessful: " + strconv.FormatInt(int64(resp.StatusCode), 10))
|
||||||
|
}
|
||||||
|
var buffer = make([]byte, 1024)
|
||||||
|
i, err := resp.Body.Read(buffer)
|
||||||
|
for {
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
i64 := int64(len(buffer[:i]))
|
||||||
|
needSize := block.EndOffset + 1 - block.BeginOffset
|
||||||
|
if i64 > needSize {
|
||||||
|
i64 = needSize
|
||||||
|
err = io.EOF
|
||||||
|
}
|
||||||
|
_, e := writer.Write(buffer[:i64])
|
||||||
|
if e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
block.BeginOffset += i64
|
||||||
|
block.DownloadedSize += i64
|
||||||
|
if err == io.EOF || block.BeginOffset > block.EndOffset {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i, err = resp.Body.Read(buffer)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := initOrDownload(); err != nil {
|
||||||
|
if err == errUnsupportedMultiThreading {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(len(blocks))
|
||||||
|
var lastErr error
|
||||||
|
for i := range blocks {
|
||||||
|
go func(b *BlockMetaData) {
|
||||||
|
defer wg.Done()
|
||||||
|
if err := downloadBlock(b); err != nil {
|
||||||
|
lastErr = err
|
||||||
|
}
|
||||||
|
}(blocks[i])
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
return lastErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSliderTicket(raw, id string) (string, error) {
|
||||||
|
var rsp string
|
||||||
|
if err := gout.POST("https://api.shkong.com/gocqhttpapi/task").SetJSON(gout.H{
|
||||||
|
"id": id,
|
||||||
|
"url": raw,
|
||||||
|
}).SetTimeout(time.Second * 35).BindBody(&rsp).Do(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
g := gjson.Parse(rsp)
|
||||||
|
if g.Get("error").Str != "" {
|
||||||
|
return "", errors.New(g.Get("error").Str)
|
||||||
|
}
|
||||||
|
return g.Get("ticket").Str, nil
|
||||||
|
}
|
||||||
|
|
||||||
func QQMusicSongInfo(id string) (gjson.Result, error) {
|
func QQMusicSongInfo(id string) (gjson.Result, error) {
|
||||||
d, err := GetBytes(`https://u.y.qq.com/cgi-bin/musicu.fcg?format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&data={%22comm%22:{%22ct%22:24,%22cv%22:0},%22songinfo%22:{%22method%22:%22get_song_detail_yqq%22,%22param%22:{%22song_type%22:0,%22song_mid%22:%22%22,%22song_id%22:` + id + `},%22module%22:%22music.pf_song_detail_svr%22}}`)
|
d, err := GetBytes(`https://u.y.qq.com/cgi-bin/musicu.fcg?format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&data={%22comm%22:{%22ct%22:24,%22cv%22:0},%22songinfo%22:{%22method%22:%22get_song_detail_yqq%22,%22param%22:{%22song_type%22:0,%22song_mid%22:%22%22,%22song_id%22:` + id + `},%22module%22:%22music.pf_song_detail_svr%22}}`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -71,3 +71,23 @@ func VersionNameCompare(current, remote string) bool {
|
|||||||
}
|
}
|
||||||
return len(cur) < len(re)
|
return len(cur) < len(re)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SplitUrl(s string) []string {
|
||||||
|
reg := regexp.MustCompile(`[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?`)
|
||||||
|
idx := reg.FindAllStringIndex(s, -1)
|
||||||
|
if len(idx) == 0 {
|
||||||
|
return []string{s}
|
||||||
|
}
|
||||||
|
var result []string
|
||||||
|
last := 0
|
||||||
|
for i := 0; i < len(idx); i++ {
|
||||||
|
if len(idx[i]) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
m := int(math.Abs(float64(idx[i][0]-idx[i][1]))/1.5) + idx[i][0]
|
||||||
|
result = append(result, s[last:m])
|
||||||
|
last = m
|
||||||
|
}
|
||||||
|
result = append(result, s[last:])
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
17
go.mod
17
go.mod
@ -3,26 +3,25 @@ module github.com/Mrs4s/go-cqhttp
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201209180326-c07a8a9c8a83
|
github.com/Mrs4s/MiraiGo v0.0.0-20210105173234-72521dec9b56
|
||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c
|
|
||||||
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect
|
|
||||||
github.com/gin-contrib/pprof v1.3.0
|
github.com/gin-contrib/pprof v1.3.0
|
||||||
github.com/gin-gonic/gin v1.6.3
|
github.com/gin-gonic/gin v1.6.3
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/guonaihong/gout v0.1.3
|
github.com/guonaihong/gout v0.1.4
|
||||||
github.com/hjson/hjson-go v3.1.0+incompatible
|
github.com/hjson/hjson-go v3.1.0+incompatible
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10
|
||||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
|
||||||
github.com/kr/binarydist v0.1.0 // indirect
|
|
||||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||||
github.com/lestrrat-go/strftime v1.0.3 // indirect
|
github.com/lestrrat-go/strftime v1.0.3 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||||
github.com/sirupsen/logrus v1.7.0
|
github.com/sirupsen/logrus v1.7.0
|
||||||
github.com/syndtr/goleveldb v1.0.0
|
github.com/syndtr/goleveldb v1.0.0
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
||||||
github.com/tidwall/gjson v1.6.3
|
github.com/tidwall/gjson v1.6.7
|
||||||
github.com/wdvxdr1123/go-silk v0.0.0-20201203155442-67728040c843
|
github.com/wdvxdr1123/go-silk v0.0.0-20201210140933-bcdbcb2f1093
|
||||||
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189
|
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189
|
||||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
|
||||||
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
|
||||||
)
|
)
|
||||||
|
58
go.sum
58
go.sum
@ -1,7 +1,7 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201209180326-c07a8a9c8a83 h1:9mCmMOTDlQ5reudlum8JAjmrsqSdG0692/BgOIuPIhs=
|
github.com/Mrs4s/MiraiGo v0.0.0-20210105173234-72521dec9b56 h1:U7kObHDk3RfaD81+1hA29gxHf3PfRGpX7dqR2UPNO0c=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201209180326-c07a8a9c8a83/go.mod h1:J1zaJWyeX7hQIPpOobqb8opxTNPbguotudPPrHJMoDM=
|
github.com/Mrs4s/MiraiGo v0.0.0-20210105173234-72521dec9b56/go.mod h1:HW2e375lCQiRwtuA/LV6ZVTsi7co1TRfBn+L5Ow77Bo=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -11,39 +11,21 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
|
|
||||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
|
|
||||||
github.com/getlantern/errors v1.0.1 h1:XukU2whlh7OdpxnkXhNH9VTLVz0EVPGKDV5K0oWhvzw=
|
|
||||||
github.com/getlantern/errors v1.0.1/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A=
|
|
||||||
github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c h1:mP9bsvdddRSMwqO+lmNuSrsH7nD2nBIz7af+e/4je4c=
|
|
||||||
github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c/go.mod h1:goroSTghTcnjKaR2C8ovKWy1lEvRNfqHrW/kRJNMek0=
|
|
||||||
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 h1:8MYJU90rB1bsavemKSAuDKBjtAKo5xq95bEPOnzV7CE=
|
|
||||||
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9/go.mod h1:ZyIjgH/1wTCl+B+7yH1DqrWp6MPJqESmwmEQ89ZfhvA=
|
|
||||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0=
|
|
||||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o=
|
|
||||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc=
|
|
||||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA=
|
|
||||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA=
|
|
||||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
|
|
||||||
github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0=
|
github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0=
|
||||||
github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0=
|
github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
|
github.com/gin-gonic/gin v1.6.0/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||||
github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
|
|
||||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||||
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
|
|
||||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||||
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
||||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@ -68,21 +50,17 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
|
|||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/guonaihong/gout v0.1.3 h1:BIiV6nnsA+R6dIB1P33uhCM8+TVAG3zHrXGZad7hDc8=
|
github.com/guonaihong/gout v0.1.4 h1:uBBoyztMX9okC27OQxqhn6bZ0ROkGyvnEIHwtp3TM4g=
|
||||||
github.com/guonaihong/gout v0.1.3/go.mod h1:vXvv5Kxr70eM5wrp4F0+t9lnLWmq+YPW2GByll2f/EA=
|
github.com/guonaihong/gout v0.1.4/go.mod h1:0rFYAYyzbcxEg11eY2qUbffJs7hHRPeugAnlVYSp8Ic=
|
||||||
github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw=
|
github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw=
|
||||||
github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
|
github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
|
||||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/kr/binarydist v0.1.0 h1:6kAoLA9FMMnNGSehX0s1PdjbEaACznAv/W219j2uvyo=
|
|
||||||
github.com/kr/binarydist v0.1.0/go.mod h1:DY7S//GCoz1BCd0B0EVrinCKAZN3pXe+MDaIZbXQVgM=
|
|
||||||
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
|
|
||||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
||||||
@ -90,7 +68,6 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkL
|
|||||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||||
github.com/lestrrat-go/strftime v1.0.3 h1:qqOPU7y+TM8Y803I8fG9c/DyKG3xH/xkng6keC1015Q=
|
github.com/lestrrat-go/strftime v1.0.3 h1:qqOPU7y+TM8Y803I8fG9c/DyKG3xH/xkng6keC1015Q=
|
||||||
github.com/lestrrat-go/strftime v1.0.3/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
|
github.com/lestrrat-go/strftime v1.0.3/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
|
||||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
|
||||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
@ -102,8 +79,6 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S
|
|||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
|
||||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
@ -123,21 +98,25 @@ github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFd
|
|||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
||||||
github.com/tidwall/gjson v1.6.3 h1:aHoiiem0dr7GHkW001T1SMTJ7X5PvyekH5WX0whWGnI=
|
|
||||||
github.com/tidwall/gjson v1.6.3/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0=
|
github.com/tidwall/gjson v1.6.3/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0=
|
||||||
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
|
github.com/tidwall/gjson v1.6.7 h1:Mb1M9HZCRWEcXQ8ieJo7auYyyiSux6w9XN3AdTpxJrE=
|
||||||
|
github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
|
||||||
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
|
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
|
||||||
|
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
||||||
|
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
|
github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
|
||||||
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||||
github.com/wdvxdr1123/go-silk v0.0.0-20201203155442-67728040c843 h1:PRhoPwoTPcB9IDtAj7bEqeGS3SCxZ4xs7/IH35P24jQ=
|
github.com/wdvxdr1123/go-silk v0.0.0-20201210140933-bcdbcb2f1093 h1:t38EBwI2hFJz1sQJ402VqzdA3eMidkY1c3w/8z0SftA=
|
||||||
github.com/wdvxdr1123/go-silk v0.0.0-20201203155442-67728040c843/go.mod h1:5q9LFlBr+yX/J8Jd/9wHdXwkkjFkNyQIS7kX2Lgx/Zs=
|
github.com/wdvxdr1123/go-silk v0.0.0-20201210140933-bcdbcb2f1093/go.mod h1:5q9LFlBr+yX/J8Jd/9wHdXwkkjFkNyQIS7kX2Lgx/Zs=
|
||||||
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 h1:4UJw9if55Fu3HOwbfcaQlJ27p3oeJU2JZqoeT3ITJQk=
|
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 h1:4UJw9if55Fu3HOwbfcaQlJ27p3oeJU2JZqoeT3ITJQk=
|
||||||
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189/go.mod h1:rIrm5geMiBhPQkdfUm8gDFi/WiHneOp1i9KjmJqc+9I=
|
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189/go.mod h1:rIrm5geMiBhPQkdfUm8gDFi/WiHneOp1i9KjmJqc+9I=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
|
||||||
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
@ -147,6 +126,7 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r
|
|||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
@ -157,20 +137,22 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s=
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
|
||||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
@ -191,8 +173,6 @@ google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4
|
|||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
|
||||||
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
25
main.go
25
main.go
@ -21,12 +21,12 @@ import (
|
|||||||
"github.com/Mrs4s/go-cqhttp/server"
|
"github.com/Mrs4s/go-cqhttp/server"
|
||||||
"github.com/guonaihong/gout"
|
"github.com/guonaihong/gout"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/client"
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
"github.com/getlantern/go-update"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/rifflock/lfshook"
|
"github.com/rifflock/lfshook"
|
||||||
@ -97,9 +97,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
console := bufio.NewReader(os.Stdin)
|
var byteKey []byte
|
||||||
var strKey string
|
var isFastStart = false
|
||||||
var isFastStart bool = false
|
|
||||||
arg := os.Args
|
arg := os.Args
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
for i := range arg {
|
for i := range arg {
|
||||||
@ -113,8 +112,7 @@ func main() {
|
|||||||
case "key":
|
case "key":
|
||||||
if len(arg) > i+1 {
|
if len(arg) > i+1 {
|
||||||
b := []byte(arg[i+1])
|
b := []byte(arg[i+1])
|
||||||
b = append(b, 13, 10)
|
byteKey = b
|
||||||
strKey = string(b[:])
|
|
||||||
}
|
}
|
||||||
case "faststart":
|
case "faststart":
|
||||||
isFastStart = true
|
isFastStart = true
|
||||||
@ -219,6 +217,7 @@ func main() {
|
|||||||
log.Warnf("警告: 在Debug模式下未启用WebUi服务, 将无法进行性能分析.")
|
log.Warnf("警告: 在Debug模式下未启用WebUi服务, 将无法进行性能分析.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Info("用户交流群: 721829413")
|
||||||
if !global.PathExists("device.json") {
|
if !global.PathExists("device.json") {
|
||||||
log.Warn("虚拟设备信息不存在, 将自动生成随机设备.")
|
log.Warn("虚拟设备信息不存在, 将自动生成随机设备.")
|
||||||
client.GenRandomDevice()
|
client.GenRandomDevice()
|
||||||
@ -232,8 +231,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
if conf.EncryptPassword && conf.PasswordEncrypted == "" {
|
if conf.EncryptPassword && conf.PasswordEncrypted == "" {
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行加密: (Enter 提交)")
|
log.Infof("密码加密已启用, 请输入Key对密码进行加密: (Enter 提交)")
|
||||||
strKey, _ := console.ReadString('\n')
|
byteKey, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||||
key := md5.Sum([]byte(strKey))
|
key := md5.Sum(byteKey)
|
||||||
if encrypted := EncryptPwd(conf.Password, key[:]); encrypted != "" {
|
if encrypted := EncryptPwd(conf.Password, key[:]); encrypted != "" {
|
||||||
conf.Password = ""
|
conf.Password = ""
|
||||||
conf.PasswordEncrypted = encrypted
|
conf.PasswordEncrypted = encrypted
|
||||||
@ -243,7 +242,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.PasswordEncrypted != "" {
|
if conf.PasswordEncrypted != "" {
|
||||||
if strKey == "" {
|
if len(byteKey) == 0 {
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
||||||
cancel := make(chan struct{}, 1)
|
cancel := make(chan struct{}, 1)
|
||||||
go func() {
|
go func() {
|
||||||
@ -256,12 +255,12 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
strKey, _ = console.ReadString('\n')
|
byteKey, _ = terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||||
cancel <- struct{}{}
|
cancel <- struct{}{}
|
||||||
} else {
|
} else {
|
||||||
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
|
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
|
||||||
}
|
}
|
||||||
key := md5.Sum([]byte(strKey))
|
key := md5.Sum(byteKey)
|
||||||
conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:])
|
conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:])
|
||||||
}
|
}
|
||||||
if !isFastStart {
|
if !isFastStart {
|
||||||
@ -436,7 +435,7 @@ func selfUpdate(imageUrl string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
wc := global.WriteCounter{}
|
wc := global.WriteCounter{}
|
||||||
err, _ = update.New().FromStream(io.TeeReader(resp.Body, &wc))
|
err, _ = global.UpdateFromStream(io.TeeReader(resp.Body, &wc))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("更新失败!")
|
log.Error("更新失败!")
|
||||||
@ -450,6 +449,8 @@ func selfUpdate(imageUrl string) {
|
|||||||
} else {
|
} else {
|
||||||
log.Warn("已取消更新!")
|
log.Warn("已取消更新!")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Info("当前版本已经是最新版本!")
|
||||||
}
|
}
|
||||||
log.Info("按 Enter 继续....")
|
log.Info("按 Enter 继续....")
|
||||||
readLine()
|
readLine()
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Mrs4s/MiraiGo/utils"
|
||||||
"github.com/gin-contrib/pprof"
|
"github.com/gin-contrib/pprof"
|
||||||
"image"
|
"image"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -112,6 +113,7 @@ func (s *webServer) Dologin() {
|
|||||||
s.Console = bufio.NewReader(os.Stdin)
|
s.Console = bufio.NewReader(os.Stdin)
|
||||||
readLine := func() (str string) {
|
readLine := func() (str string) {
|
||||||
str, _ = s.Console.ReadString('\n')
|
str, _ = s.Console.ReadString('\n')
|
||||||
|
str = strings.TrimSpace(str)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conf := GetConf()
|
conf := GetConf()
|
||||||
@ -125,15 +127,34 @@ func (s *webServer) Dologin() {
|
|||||||
if !rsp.Success {
|
if !rsp.Success {
|
||||||
switch rsp.Error {
|
switch rsp.Error {
|
||||||
case client.SliderNeededError:
|
case client.SliderNeededError:
|
||||||
if client.SystemDeviceInfo.Protocol == client.AndroidPhone {
|
log.Warnf("登录需要滑条验证码, 请选择解决方案: ")
|
||||||
log.Warnf("警告: Android Phone 强制要求暂不支持的滑条验证码, 请开启设备锁或切换到Watch协议验证通过后再使用.")
|
log.Warnf("1. 自行抓包. (推荐)")
|
||||||
log.Infof("按 Enter 继续....")
|
log.Warnf("2. 使用Cef自动处理.")
|
||||||
readLine()
|
log.Warnf("3. 不提交滑块并继续.(可能会导致上网环境异常错误)")
|
||||||
|
log.Warnf("详细信息请参考文档 -> https://github.com/Mrs4s/go-cqhttp/blob/master/docs/slider.md <-")
|
||||||
|
log.Warn("请输入(1 - 3): ")
|
||||||
|
text = readLine()
|
||||||
|
if strings.Contains(text, "1") {
|
||||||
|
log.Warnf("请用浏览器打开 -> %v <- 并获取Ticket.", rsp.VerifyUrl)
|
||||||
|
log.Warn("请输入Ticket: (Enter 提交)")
|
||||||
|
text = readLine()
|
||||||
|
rsp, err = cli.SubmitTicket(strings.TrimSpace(text))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(text, "3") {
|
||||||
|
cli.AllowSlider = false
|
||||||
|
cli.Disconnect()
|
||||||
|
rsp, err = cli.Login()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
id := utils.RandomStringRange(6, "0123456789")
|
||||||
|
log.Warnf("滑块ID为 %v 请在30S内处理.", id)
|
||||||
|
ticket, err := global.GetSliderTicket(rsp.VerifyUrl, id)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("错误: " + err.Error())
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
cli.AllowSlider = false
|
rsp, err = cli.SubmitTicket(ticket)
|
||||||
cli.Disconnect()
|
|
||||||
rsp, err = cli.Login()
|
|
||||||
continue
|
continue
|
||||||
case client.NeedCaptcha:
|
case client.NeedCaptcha:
|
||||||
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644)
|
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644)
|
||||||
@ -204,7 +225,7 @@ func (s *webServer) Dologin() {
|
|||||||
cli.Disconnect()
|
cli.Disconnect()
|
||||||
rsp, err = cli.Login()
|
rsp, err = cli.Login()
|
||||||
count++
|
count++
|
||||||
log.Warnf("错误: 当前上网环境异常. 将更换服务器并重试. 如果频繁遇到此问题请打开设备锁.")
|
log.Warnf("错误: 当前上网环境异常. 将更换服务器并重试.")
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -239,11 +260,14 @@ func (s *webServer) Dologin() {
|
|||||||
global.BootFilter()
|
global.BootFilter()
|
||||||
global.InitCodec()
|
global.InitCodec()
|
||||||
coolq.IgnoreInvalidCQCode = conf.IgnoreInvalidCQCode
|
coolq.IgnoreInvalidCQCode = conf.IgnoreInvalidCQCode
|
||||||
|
coolq.SplitUrl = conf.FixUrl
|
||||||
coolq.ForceFragmented = conf.ForceFragmented
|
coolq.ForceFragmented = conf.ForceFragmented
|
||||||
log.Info("资源初始化完成, 开始处理信息.")
|
log.Info("资源初始化完成, 开始处理信息.")
|
||||||
log.Info("アトリは、高性能ですから!")
|
log.Info("アトリは、高性能ですから!")
|
||||||
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
|
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
|
||||||
if conf.ReLogin.Enabled {
|
if conf.ReLogin.Enabled {
|
||||||
|
conf.ReLogin.Enabled = false
|
||||||
|
defer func() { conf.ReLogin.Enabled = true }()
|
||||||
var times uint = 1
|
var times uint = 1
|
||||||
for {
|
for {
|
||||||
if cli.Online {
|
if cli.Online {
|
||||||
@ -271,6 +295,9 @@ func (s *webServer) Dologin() {
|
|||||||
log.Fatalf("重连失败: 设备锁")
|
log.Fatalf("重连失败: 设备锁")
|
||||||
default:
|
default:
|
||||||
log.Errorf("重连失败: %v", rsp.ErrorMessage)
|
log.Errorf("重连失败: %v", rsp.ErrorMessage)
|
||||||
|
if strings.Contains(rsp.ErrorMessage, "冻结") {
|
||||||
|
log.Fatalf("账号被冻结, 放弃重连")
|
||||||
|
}
|
||||||
cli.Disconnect()
|
cli.Disconnect()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
|
|||||||
}
|
}
|
||||||
if err := s.Http.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := s.Http.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
log.Infof("请检查端口是否被占用.")
|
log.Infof("HTTP 服务启动失败, 请检查端口是否被占用.")
|
||||||
|
log.Warnf("将在五秒后退出.")
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -352,6 +353,9 @@ func SetRestart(s *httpServer, c *gin.Context) {
|
|||||||
|
|
||||||
func GetForwardMessage(s *httpServer, c *gin.Context) {
|
func GetForwardMessage(s *httpServer, c *gin.Context) {
|
||||||
resId := getParam(c, "message_id")
|
resId := getParam(c, "message_id")
|
||||||
|
if resId == "" {
|
||||||
|
resId = getParam(c, "id")
|
||||||
|
}
|
||||||
c.JSON(200, s.bot.CQGetForwardMessage(resId))
|
c.JSON(200, s.bot.CQGetForwardMessage(resId))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +398,25 @@ func GetStrangerInfo(s *httpServer, c *gin.Context) {
|
|||||||
c.JSON(200, s.bot.CQGetStrangerInfo(uid))
|
c.JSON(200, s.bot.CQGetStrangerInfo(uid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetGroupAtAllRemain(s *httpServer, c *gin.Context) {
|
||||||
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
|
c.JSON(200, s.bot.CQGetAtAllRemain(gid))
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetGroupAnonymousBan(s *httpServer, c *gin.Context) {
|
||||||
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
|
d, _ := strconv.ParseInt(getParam(c, "duration"), 10, 64)
|
||||||
|
flag := getParam(c, "flag")
|
||||||
|
if flag == "" {
|
||||||
|
flag = getParam(c, "anonymous_flag")
|
||||||
|
}
|
||||||
|
if flag == "" {
|
||||||
|
o := gjson.Parse(getParam(c, "anonymous"))
|
||||||
|
flag = o.Get("flag").String()
|
||||||
|
}
|
||||||
|
c.JSON(200, s.bot.CQSetGroupAnonymousBan(gid, flag, int32(d)))
|
||||||
|
}
|
||||||
|
|
||||||
func HandleQuickOperation(s *httpServer, c *gin.Context) {
|
func HandleQuickOperation(s *httpServer, c *gin.Context) {
|
||||||
if c.Request.Method != "POST" {
|
if c.Request.Method != "POST" {
|
||||||
c.AbortWithStatus(404)
|
c.AbortWithStatus(404)
|
||||||
@ -405,6 +428,33 @@ func HandleQuickOperation(s *httpServer, c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DownloadFile(s *httpServer, c *gin.Context) {
|
||||||
|
url := getParam(c, "url")
|
||||||
|
tc, _ := strconv.Atoi(getParam(c, "thread_count"))
|
||||||
|
h, t := getParamWithType(c, "headers")
|
||||||
|
headers := map[string]string{}
|
||||||
|
if t == gjson.Null || t == gjson.String {
|
||||||
|
lines := strings.Split(h, "\r\n")
|
||||||
|
for _, sub := range lines {
|
||||||
|
str := strings.SplitN(sub, "=", 2)
|
||||||
|
if len(str) == 2 {
|
||||||
|
headers[str[0]] = str[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if t == gjson.JSON {
|
||||||
|
arr := gjson.Parse(h)
|
||||||
|
for _, sub := range arr.Array() {
|
||||||
|
str := strings.SplitN(sub.String(), "=", 2)
|
||||||
|
if len(str) == 2 {
|
||||||
|
headers[str[0]] = str[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println(url, tc, h, t)
|
||||||
|
c.JSON(200, s.bot.CQDownloadFile(url, headers, tc))
|
||||||
|
}
|
||||||
|
|
||||||
func OcrImage(s *httpServer, c *gin.Context) {
|
func OcrImage(s *httpServer, c *gin.Context) {
|
||||||
img := getParam(c, "image")
|
img := getParam(c, "image")
|
||||||
c.JSON(200, s.bot.CQOcrImage(img))
|
c.JSON(200, s.bot.CQOcrImage(img))
|
||||||
@ -511,9 +561,12 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
|
|||||||
"get_stranger_info": GetStrangerInfo,
|
"get_stranger_info": GetStrangerInfo,
|
||||||
"reload_event_filter": ReloadEventFilter,
|
"reload_event_filter": ReloadEventFilter,
|
||||||
"set_group_portrait": SetGroupPortrait,
|
"set_group_portrait": SetGroupPortrait,
|
||||||
|
"set_group_anonymous_ban": SetGroupAnonymousBan,
|
||||||
|
"download_file": DownloadFile,
|
||||||
".handle_quick_operation": HandleQuickOperation,
|
".handle_quick_operation": HandleQuickOperation,
|
||||||
".ocr_image": OcrImage,
|
".ocr_image": OcrImage,
|
||||||
"ocr_image": OcrImage,
|
"ocr_image": OcrImage,
|
||||||
|
"get_group_at_all_remain": GetGroupAtAllRemain,
|
||||||
".get_word_slices": GetWordSlices,
|
".get_word_slices": GetWordSlices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +333,14 @@ func (c *websocketConn) handleRequest(bot *coolq.CQBot, payload []byte) {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
_ = c.WriteJSON(ret)
|
_ = c.WriteJSON(ret)
|
||||||
|
} else {
|
||||||
|
ret := coolq.Failed(1404, "API_NOT_FOUND", "API不存在")
|
||||||
|
if j.Get("echo").Exists() {
|
||||||
|
ret["echo"] = j.Get("echo").Value()
|
||||||
|
}
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
_ = c.WriteJSON(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,11 +481,37 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
|||||||
return bot.CQGetImage(p.Get("file").Str)
|
return bot.CQGetImage(p.Get("file").Str)
|
||||||
},
|
},
|
||||||
"get_forward_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"get_forward_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetForwardMessage(p.Get("message_id").Str)
|
id := p.Get("message_id").Str
|
||||||
|
if id == "" {
|
||||||
|
id = p.Get("id").Str
|
||||||
|
}
|
||||||
|
return bot.CQGetForwardMessage(id)
|
||||||
},
|
},
|
||||||
"get_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"get_msg": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetMessage(int32(p.Get("message_id").Int()))
|
return bot.CQGetMessage(int32(p.Get("message_id").Int()))
|
||||||
},
|
},
|
||||||
|
"download_file": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
|
headers := map[string]string{}
|
||||||
|
headersToken := p.Get("headers")
|
||||||
|
if headersToken.IsArray() {
|
||||||
|
for _, sub := range headersToken.Array() {
|
||||||
|
str := strings.SplitN(sub.String(), "=", 2)
|
||||||
|
if len(str) == 2 {
|
||||||
|
headers[str[0]] = str[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if headersToken.Type == gjson.String {
|
||||||
|
lines := strings.Split(headersToken.String(), "\r\n")
|
||||||
|
for _, sub := range lines {
|
||||||
|
str := strings.SplitN(sub, "=", 2)
|
||||||
|
if len(str) == 2 {
|
||||||
|
headers[str[0]] = str[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bot.CQDownloadFile(p.Get("url").Str, headers, int(p.Get("thread_count").Int()))
|
||||||
|
},
|
||||||
"get_group_honor_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"get_group_honor_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetGroupHonorInfo(p.Get("group_id").Int(), p.Get("type").Str)
|
return bot.CQGetGroupHonorInfo(p.Get("group_id").Int(), p.Get("type").Str)
|
||||||
},
|
},
|
||||||
@ -536,12 +570,29 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
|||||||
"ocr_image": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"ocr_image": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQOcrImage(p.Get("image").Str)
|
return bot.CQOcrImage(p.Get("image").Str)
|
||||||
},
|
},
|
||||||
|
"get_group_at_all_remain": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
|
return bot.CQGetAtAllRemain(p.Get("group_id").Int())
|
||||||
|
},
|
||||||
".get_word_slices": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
".get_word_slices": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQGetWordSlices(p.Get("content").Str)
|
return bot.CQGetWordSlices(p.Get("content").Str)
|
||||||
},
|
},
|
||||||
"set_group_portrait": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"set_group_portrait": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQSetGroupPortrait(p.Get("group_id").Int(), p.Get("file").String(), p.Get("cache").String())
|
return bot.CQSetGroupPortrait(p.Get("group_id").Int(), p.Get("file").String(), p.Get("cache").String())
|
||||||
},
|
},
|
||||||
|
"set_group_anonymous_ban": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
|
obj := p.Get("anonymous")
|
||||||
|
flag := p.Get("anonymous_flag")
|
||||||
|
if !flag.Exists() {
|
||||||
|
flag = p.Get("flag")
|
||||||
|
}
|
||||||
|
if !flag.Exists() && !obj.Exists() {
|
||||||
|
return coolq.Failed(100, "FLAG_NOT_FOUND", "flag未找到")
|
||||||
|
}
|
||||||
|
if !flag.Exists() {
|
||||||
|
flag = obj.Get("flag")
|
||||||
|
}
|
||||||
|
return bot.CQSetGroupAnonymousBan(p.Get("group_id").Int(), flag.String(), int32(p.Get("duration").Int()))
|
||||||
|
},
|
||||||
".handle_quick_operation": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
".handle_quick_operation": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user