mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-06-30 11:53:25 +00:00
Compare commits
47 Commits
v0.9.30-fi
...
v0.9.31-fi
Author | SHA1 | Date | |
---|---|---|---|
8f76558317 | |||
d94d389843 | |||
df0d5af07a | |||
277629e784 | |||
d66a99c5a3 | |||
55895e0de1 | |||
39da163641 | |||
1dbd72c138 | |||
31756e9e1d | |||
5ab713e7d3 | |||
b6eb559172 | |||
da2e34aaa5 | |||
beb1a2883a | |||
8f34003c6f | |||
7f3e58f97a | |||
0fc004077b | |||
e9a03b68b5 | |||
e9b39f3379 | |||
e053da62e1 | |||
f87b5c8215 | |||
28f1594539 | |||
990e7744a3 | |||
8900839018 | |||
4a3288cb8d | |||
0f0f74ece8 | |||
79ba9474a3 | |||
cb9d872071 | |||
4c3105fa24 | |||
a8176e69e6 | |||
afa356e551 | |||
a52ae1c828 | |||
b8ec05e1c1 | |||
2cbf23bceb | |||
3e5c2bc8e3 | |||
69a2360d02 | |||
5b0ede5346 | |||
80af002668 | |||
b3152bb514 | |||
9a018e2a47 | |||
998b8cb146 | |||
7e3f94ad2e | |||
f9dc22f2e5 | |||
0ce54ac21b | |||
06ac2fcb0c | |||
30f1f3199a | |||
f9c0b94af6 | |||
4c9f60da09 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup Go environment
|
- name: Setup Go environment
|
||||||
uses: actions/setup-go@v2.1.1
|
uses: actions/setup-go@v2.1.3
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.15
|
||||||
|
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set RELEASE_VERSION env
|
- name: Set RELEASE_VERSION env
|
||||||
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
|
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
|
||||||
- uses: pcrbot/go-release-action@master
|
- uses: pcrbot/go-release-action@master
|
||||||
env:
|
env:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.14.7-alpine AS builder
|
FROM golang:1.15.5-alpine AS builder
|
||||||
|
|
||||||
RUN go env -w GO111MODULE=auto \
|
RUN go env -w GO111MODULE=auto \
|
||||||
&& go env -w CGO_ENABLED=0 \
|
&& go env -w CGO_ENABLED=0 \
|
||||||
|
73
README.md
73
README.md
@ -47,32 +47,33 @@
|
|||||||
|
|
||||||
##### 注意: 部分API实现与CQHTTP原版略有差异,请参考文档
|
##### 注意: 部分API实现与CQHTTP原版略有差异,请参考文档
|
||||||
| API | 功能 |
|
| API | 功能 |
|
||||||
| ------------------------ | ------------------------------------------------------------ |
|
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| /get_login_info | [获取登录号信息](https://cqhttp.cc/docs/4.15/#/API?id=get_login_info-获取登录号信息) |
|
| /get_login_info | [获取登录号信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF) |
|
||||||
| /get_friend_list | [获取好友列表](https://cqhttp.cc/docs/4.15/#/API?id=get_friend_list-获取好友列表) |
|
| /get_friend_list | [获取好友列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8) |
|
||||||
| /get_group_list | [获取群列表](https://cqhttp.cc/docs/4.15/#/API?id=get_group_list-获取群列表) |
|
| /get_group_list | [获取群列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8) |
|
||||||
| /get_group_info | [获取群信息](https://cqhttp.cc/docs/4.15/#/API?id=get_group_info-获取群信息) |
|
| /get_group_info | [获取群信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF) |
|
||||||
| /get_group_member_list | [获取群成员列表](https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_list-获取群成员列表) |
|
| /get_group_member_list | [获取群成员列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8) |
|
||||||
| /get_group_member_info | [获取群成员信息](https://cqhttp.cc/docs/4.15/#/API?id=get_group_member_info-获取群成员信息) |
|
| /get_group_member_info | [获取群成员信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF) |
|
||||||
| /send_msg | [发送消息](https://cqhttp.cc/docs/4.15/#/API?id=send_msg-发送消息) |
|
| /send_msg | [发送消息](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) |
|
||||||
| /send_group_msg | [发送群消息](https://cqhttp.cc/docs/4.15/#/API?id=send_group_msg-发送群消息) |
|
| /send_group_msg | [发送群消息](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) |
|
||||||
| /send_private_msg | [发送私聊消息](https://cqhttp.cc/docs/4.15/#/API?id=send_private_msg-发送私聊消息) |
|
| /send_private_msg | [发送私聊消息](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) |
|
||||||
| /delete_msg | [撤回信息](https://cqhttp.cc/docs/4.15/#/API?id=delete_msg-撤回消息) |
|
| /delete_msg | [撤回信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF) |
|
||||||
| /set_friend_add_request | [处理加好友请求](https://cqhttp.cc/docs/4.15/#/API?id=set_friend_add_request-处理加好友请求) |
|
| /set_friend_add_request | [处理加好友请求](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#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) |
|
||||||
| /set_group_add_request | [处理加群请求/邀请](https://cqhttp.cc/docs/4.15/#/API?id=set_group_add_request-处理加群请求/邀请) |
|
| /set_group_add_request | [处理加群请求/邀请](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7) |
|
||||||
| /set_group_card | [设置群名片(群备注)](https://cqhttp.cc/docs/4.15/#/API?id=set_group_card-设置群名片(群备注)) |
|
| /set_group_card | [设置群名片(群备注)](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8) |
|
||||||
| /set_group_special_title | [设置群组专属头衔](https://cqhttp.cc/docs/4.15/#/API?id=set_group_special_title-设置群组专属头衔) |
|
| /set_group_special_title | [设置群组专属头衔](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94) |
|
||||||
| /set_group_kick | [群组T人](https://cqhttp.cc/docs/4.15/#/API?id=set_group_kick-群组踢人) |
|
| /set_group_kick | [群组T人](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA) |
|
||||||
| /set_group_ban | [群组单人禁言](https://cqhttp.cc/docs/4.15/#/API?id=set_group_ban-群组单人禁言) |
|
| /set_group_ban | [群组单人禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80) |
|
||||||
| /set_group_whole_ban | [群组全员禁言](https://cqhttp.cc/docs/4.15/#/API?id=set_group_whole_ban-群组全员禁言) |
|
| /set_group_whole_ban | [群组全员禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80) |
|
||||||
| /set_group_leave | [退出群组](https://cqhttp.cc/docs/4.15/#/API?id=set_group_leave-退出群组) |
|
| /set_group_leave | [退出群组](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84) |
|
||||||
| /set_group_name | 设置群组名(拓展API) |
|
| /set_group_name | [设置群组名](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D) |
|
||||||
| /get_image | 获取图片信息(拓展API) |
|
| /set_restart | [重启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) |
|
||||||
| /get_msg | [获取消息]() | <!-- TODO 来人补个链接-->
|
| /get_image | [获取图片信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_image-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87) |
|
||||||
| /can_send_image | [检查是否可以发送图片](https://cqhttp.cc/docs/4.15/#/API?id=can_send_image-检查是否可以发送图片) |
|
| /get_msg | [获取消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_msg-%E8%8E%B7%E5%8F%96%E6%B6%88%E6%81%AF) |
|
||||||
| /can_send_record | [检查是否可以发送语音](https://cqhttp.cc/docs/4.15/#/API?id=can_send_record-检查是否可以发送语音) |
|
| /can_send_image | [检查是否可以发送图片](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) |
|
||||||
| /get_status | [获取插件运行状态](https://cqhttp.cc/docs/4.15/#/API?id=get_status-获取插件运行状态) |
|
| /can_send_record | [检查是否可以发送语音](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) |
|
||||||
| /get_version_info | [获取 酷Q 及 CQHTTP插件的版本信息](https://cqhttp.cc/docs/4.15/#/API?id=get_version_info-获取-酷q-及-cqhttp-插件的版本信息) |
|
| /get_status | [获取插件运行状态](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) |
|
||||||
|
| /get_version_info | [获取 酷Q 及 CQHTTP插件的版本信息](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) |
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@ -81,19 +82,19 @@
|
|||||||
|
|
||||||
##### 注意: 部分Event数据与CQHTTP原版略有差异,请参考文档
|
##### 注意: 部分Event数据与CQHTTP原版略有差异,请参考文档
|
||||||
| Event |
|
| Event |
|
||||||
| ------------------------------------------------------------ |
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [私聊信息](https://cqhttp.cc/docs/4.15/#/Post?id=私聊消息) |
|
| [私聊信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF) |
|
||||||
| [群消息](https://cqhttp.cc/docs/4.15/#/Post?id=群消息) |
|
| [群消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%BE%A4%E6%B6%88%E6%81%AF) |
|
||||||
| [群消息撤回(拓展Event)](docs/cqhttp.md#群消息撤回) |
|
| [群消息撤回(拓展Event)](docs/cqhttp.md#群消息撤回) |
|
||||||
| [好友消息撤回(拓展Event)](docs/cqhttp.md#好友消息撤回) |
|
| [好友消息撤回(拓展Event)](docs/cqhttp.md#好友消息撤回) |
|
||||||
| [群内提示事件(拓展Event)(龙王等事件)](docs/cqhttp.md#群内戳一戳) |
|
| [群内提示事件(拓展Event)(龙王等事件)](docs/cqhttp.md#群内戳一戳) |
|
||||||
| [群管理员变动](https://cqhttp.cc/docs/4.15/#/Post?id=群管理员变动) |
|
| [群管理员变动](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%8F%98%E5%8A%A8) |
|
||||||
| [群成员减少](https://cqhttp.cc/docs/4.15/#/Post?id=群成员减少) |
|
| [群成员减少](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%87%8F%E5%B0%91) |
|
||||||
| [群成员增加](https://cqhttp.cc/docs/4.15/#/Post?id=群成员增加) |
|
| [群成员增加](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%A2%9E%E5%8A%A0) |
|
||||||
| [群禁言](https://cqhttp.cc/docs/4.15/#/Post?id=群禁言) |
|
| [群禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%A6%81%E8%A8%80) |
|
||||||
| [群文件上传](https://cqhttp.cc/docs/4.15/#/Post?id=群文件上传) |
|
| [群文件上传](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0) |
|
||||||
| [加好友请求](https://cqhttp.cc/docs/4.15/#/Post?id=加好友请求) |
|
| [加好友请求](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://cqhttp.cc/docs/4.15/#/Post?id=加群请求/邀请) |
|
| [加群请求/邀请](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) |
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
@ -516,12 +516,11 @@ func (bot *CQBot) CQSetGroupAdmin(groupId, userId int64, enable bool) MSG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) CQGetVipInfo(userId int64) MSG {
|
func (bot *CQBot) CQGetVipInfo(userId int64) MSG {
|
||||||
msg := MSG{}
|
|
||||||
vip, err := bot.Client.GetVipInfo(userId)
|
vip, err := bot.Client.GetVipInfo(userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
msg = MSG{
|
msg := MSG{
|
||||||
"user_id": vip.Uin,
|
"user_id": vip.Uin,
|
||||||
"nickname": vip.Name,
|
"nickname": vip.Name,
|
||||||
"level": vip.Level,
|
"level": vip.Level,
|
||||||
@ -807,7 +806,7 @@ func (bot *CQBot) CQGetVersionInfo() MSG {
|
|||||||
"version": Version,
|
"version": Version,
|
||||||
"protocol": func() int {
|
"protocol": func() int {
|
||||||
switch client.SystemDeviceInfo.Protocol {
|
switch client.SystemDeviceInfo.Protocol {
|
||||||
case client.AndroidPad:
|
case client.IPad:
|
||||||
return 0
|
return 0
|
||||||
case client.AndroidPhone:
|
case client.AndroidPhone:
|
||||||
return 1
|
return 1
|
||||||
|
@ -5,12 +5,13 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/client"
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
@ -56,6 +57,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot {
|
|||||||
bot.Client.OnGroupMuted(bot.groupMutedEvent)
|
bot.Client.OnGroupMuted(bot.groupMutedEvent)
|
||||||
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)
|
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)
|
||||||
bot.Client.OnGroupNotify(bot.groupNotifyEvent)
|
bot.Client.OnGroupNotify(bot.groupNotifyEvent)
|
||||||
|
bot.Client.OnFriendNotify(bot.friendNotifyEvent)
|
||||||
bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent)
|
bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent)
|
||||||
bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent)
|
bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent)
|
||||||
bot.Client.OnJoinGroup(bot.joinGroupEvent)
|
bot.Client.OnJoinGroup(bot.joinGroupEvent)
|
||||||
@ -235,6 +237,10 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
|
|||||||
newElem = append(newElem, fm)
|
newElem = append(newElem, fm)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if i, ok := elem.(*PokeElement); ok {
|
||||||
|
bot.Client.SendFriendPoke(i.Target)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
if i, ok := elem.(*message.VoiceElement); ok {
|
if i, ok := elem.(*message.VoiceElement); ok {
|
||||||
fv, err := bot.Client.UploadPrivatePtt(target, i.Data)
|
fv, err := bot.Client.UploadPrivatePtt(target, i.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -8,11 +8,6 @@ import (
|
|||||||
xml2 "encoding/xml"
|
xml2 "encoding/xml"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
@ -20,6 +15,12 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
var matchReg = regexp.MustCompile(`\[CQ:\w+?.*?]`)
|
var matchReg = regexp.MustCompile(`\[CQ:\w+?.*?]`)
|
||||||
@ -65,7 +66,7 @@ func (e *MusicElement) Type() message.ElementType {
|
|||||||
return message.Service
|
return message.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
var GiftId = []message.GroupGift{
|
var GiftId = [...]message.GroupGift{
|
||||||
message.SweetWink,
|
message.SweetWink,
|
||||||
message.HappyCola,
|
message.HappyCola,
|
||||||
message.LuckyBracelet,
|
message.LuckyBracelet,
|
||||||
@ -75,6 +76,11 @@ var GiftId = []message.GroupGift{
|
|||||||
message.RainbowCandy,
|
message.RainbowCandy,
|
||||||
message.Stronger,
|
message.Stronger,
|
||||||
message.LoveMicrophone,
|
message.LoveMicrophone,
|
||||||
|
message.HoldingYourHand,
|
||||||
|
message.CuteCat,
|
||||||
|
message.MysteryMask,
|
||||||
|
message.ImBusy,
|
||||||
|
message.LoveMask,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *PokeElement) Type() message.ElementType {
|
func (e *PokeElement) Type() message.ElementType {
|
||||||
@ -177,6 +183,16 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
|
|||||||
"data": map[string]string{"file": o.Filename, "url": o.Url},
|
"data": map[string]string{"file": o.Filename, "url": o.Url},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case *message.GroupFlashImgElement:
|
||||||
|
return []MSG{MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": o.Filename, "type": "flash"},
|
||||||
|
}}
|
||||||
|
case *message.FriendFlashImgElement:
|
||||||
|
return []MSG{MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": o.Filename, "type": "flash"},
|
||||||
|
}}
|
||||||
case *message.ServiceElement:
|
case *message.ServiceElement:
|
||||||
if isOk := strings.Contains(o.Content, "<?xml"); isOk {
|
if isOk := strings.Contains(o.Content, "<?xml"); isOk {
|
||||||
m = MSG{
|
m = MSG{
|
||||||
@ -249,6 +265,10 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
|
|||||||
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
||||||
case *message.FriendImageElement:
|
case *message.FriendImageElement:
|
||||||
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
||||||
|
case *message.GroupFlashImgElement:
|
||||||
|
return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename)
|
||||||
|
case *message.FriendFlashImgElement:
|
||||||
|
return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename)
|
||||||
case *message.ServiceElement:
|
case *message.ServiceElement:
|
||||||
if isOk := strings.Contains(o.Content, "<?xml"); isOk {
|
if isOk := strings.Contains(o.Content, "<?xml"); isOk {
|
||||||
r += fmt.Sprintf(`[CQ:xml,data=%s,resid=%d]`, CQCodeEscapeValue(o.Content), o.Id)
|
r += fmt.Sprintf(`[CQ:xml,data=%s,resid=%d]`, CQCodeEscapeValue(o.Content), o.Id)
|
||||||
@ -429,9 +449,6 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "poke":
|
case "poke":
|
||||||
if !group {
|
|
||||||
return nil, errors.New("todo") // TODO: private poke
|
|
||||||
}
|
|
||||||
t, _ := strconv.ParseInt(d["qq"], 10, 64)
|
t, _ := strconv.ParseInt(d["qq"], 10, 64)
|
||||||
return &PokeElement{Target: t}, nil
|
return &PokeElement{Target: t}, nil
|
||||||
case "gift":
|
case "gift":
|
||||||
@ -440,7 +457,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
|
|||||||
}
|
}
|
||||||
t, _ := strconv.ParseInt(d["qq"], 10, 64)
|
t, _ := strconv.ParseInt(d["qq"], 10, 64)
|
||||||
id, _ := strconv.Atoi(d["id"])
|
id, _ := strconv.Atoi(d["id"])
|
||||||
if id < 0 || id >= 9 {
|
if id < 0 || id >= 14 {
|
||||||
return nil, errors.New("invalid gift id")
|
return nil, errors.New("invalid gift id")
|
||||||
}
|
}
|
||||||
return &GiftElement{Target: t, GiftId: GiftId[id]}, nil
|
return &GiftElement{Target: t, GiftId: GiftId[id]}, nil
|
||||||
|
@ -2,16 +2,17 @@ package coolq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client"
|
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var format = "string"
|
var format = "string"
|
||||||
@ -220,7 +221,7 @@ func (bot *CQBot) groupRecallEvent(c *client.QQClient, e *client.GroupMessageRec
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.IGroupNotifyEvent) {
|
func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.INotifyEvent) {
|
||||||
group := c.FindGroup(e.From())
|
group := c.FindGroup(e.From())
|
||||||
switch notify := e.(type) {
|
switch notify := e.(type) {
|
||||||
case *client.GroupPokeNotifyEvent:
|
case *client.GroupPokeNotifyEvent:
|
||||||
@ -279,6 +280,24 @@ func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.IGroupNotifyEven
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bot *CQBot) friendNotifyEvent(c *client.QQClient, e client.INotifyEvent) {
|
||||||
|
friend := c.FindFriend(e.From())
|
||||||
|
switch notify := e.(type) {
|
||||||
|
case *client.FriendPokeNotifyEvent:
|
||||||
|
log.Infof("好友 %v 戳了戳你.", friend.Nickname)
|
||||||
|
bot.dispatchEventMessage(MSG{
|
||||||
|
"post_type": "notice",
|
||||||
|
"notice_type": "notify",
|
||||||
|
"sub_type": "poke",
|
||||||
|
"self_id": c.Uin,
|
||||||
|
"user_id": notify.Sender,
|
||||||
|
"sender_id": notify.Sender,
|
||||||
|
"target_id": notify.Receiver,
|
||||||
|
"time": time.Now().Unix(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageRecalledEvent) {
|
func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageRecalledEvent) {
|
||||||
f := c.FindFriend(e.FriendUin)
|
f := c.FindFriend(e.FriendUin)
|
||||||
gid := ToGlobalId(e.FriendUin, e.MessageId)
|
gid := ToGlobalId(e.FriendUin, e.MessageId)
|
||||||
@ -509,6 +528,28 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
|
|||||||
w.WriteString(i.Url)
|
w.WriteString(i.Url)
|
||||||
}), 0644)
|
}), 0644)
|
||||||
}
|
}
|
||||||
|
case *message.GroupFlashImgElement:
|
||||||
|
filename := hex.EncodeToString(i.Md5) + ".image"
|
||||||
|
if !global.PathExists(path.Join(global.IMAGE_PATH, filename)) {
|
||||||
|
_ = ioutil.WriteFile(path.Join(global.IMAGE_PATH, filename), binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
w.Write(i.Md5)
|
||||||
|
w.WriteUInt32(uint32(i.Size))
|
||||||
|
w.WriteString(i.Filename)
|
||||||
|
w.WriteString("")
|
||||||
|
}), 0644)
|
||||||
|
}
|
||||||
|
i.Filename = filename
|
||||||
|
case *message.FriendFlashImgElement:
|
||||||
|
filename := hex.EncodeToString(i.Md5) + ".image"
|
||||||
|
if !global.PathExists(path.Join(global.IMAGE_PATH, filename)) {
|
||||||
|
_ = ioutil.WriteFile(path.Join(global.IMAGE_PATH, filename), binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
w.Write(i.Md5)
|
||||||
|
w.WriteUInt32(uint32(i.Size))
|
||||||
|
w.WriteString(i.Filename)
|
||||||
|
w.WriteString("")
|
||||||
|
}), 0644)
|
||||||
|
}
|
||||||
|
i.Filename = filename
|
||||||
case *message.VoiceElement:
|
case *message.VoiceElement:
|
||||||
i.Name = strings.ReplaceAll(i.Name, "{", "")
|
i.Name = strings.ReplaceAll(i.Name, "{", "")
|
||||||
i.Name = strings.ReplaceAll(i.Name, "}", "")
|
i.Name = strings.ReplaceAll(i.Name, "}", "")
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
下面列出所有运算符(「要求的参数类型」是指运算符的键所对应的值的类型,「可作用于的类型」是指在过滤时事件对象相应值的类型):
|
下面列出所有运算符(「要求的参数类型」是指运算符的键所对应的值的类型,「可作用于的类型」是指在过滤时事件对象相应值的类型):
|
||||||
|
|
||||||
| 运算符 | 要求的参数类型 | 可作用于的类型 |
|
| 运算符 | 要求的参数类型 | 可作用于的类型 |
|
||||||
| ----- | ------------ | ----------- |
|
| ----------- | -------------------------- | ----------------------------------------------------- |
|
||||||
| `.not` | object | 任何 |
|
| `.not` | object | 任何 |
|
||||||
| `.and` | object | 若参数中全为运算符,则任何;若不全为运算符,则 object |
|
| `.and` | object | 若参数中全为运算符,则任何;若不全为运算符,则 object |
|
||||||
| `.or` | array(数组元素为 object) | 任何 |
|
| `.or` | array(数组元素为 object) | 任何 |
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| ------------ | ------ | --------------------------- |
|
||||||
| access_token | string | 校验口令,config.json中配置 |
|
| access_token | string | 校验口令,config.json中配置 |
|
||||||
|
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ method:`POST/GET`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ---- | ------------------------------------- |
|
| ------ | ---- | ---- |
|
||||||
| 无|||
|
| 无 | | |
|
||||||
|
|
||||||
返回:
|
返回:
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ method: `GET`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| ------ | ---- | ---- |
|
||||||
| 无|||
|
| 无 | | |
|
||||||
|
|
||||||
返回:
|
返回:
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ method: `GET`
|
|||||||
{"data": {"ispic": true,"picbase64":"xxxxx"}, "retcode": 0, "status": "ok"}
|
{"data": {"ispic": true,"picbase64":"xxxxx"}, "retcode": 0, "status": "ok"}
|
||||||
```
|
```
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| -------- | ------ | --------------------------------------------------- |
|
||||||
| ispic| bool| 是否是验证码类型 true是,false为不是(比如设备锁|
|
| ispic | bool | 是否是验证码类型 true是,false为不是(比如设备锁 |
|
||||||
|picbas64| string| 验证码的base64编码内容,加上头,放入img标签即可显示|
|
| picbas64 | string | 验证码的base64编码内容,加上头,放入img标签即可显示 |
|
||||||
|
|
||||||
### admin/do_web_write
|
### admin/do_web_write
|
||||||
|
|
||||||
@ -68,8 +68,8 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| ------ | ------ | ---------- |
|
||||||
| input | string | 输入的类容 |
|
| input | string | 输入的内容 |
|
||||||
|
|
||||||
返回:
|
返回:
|
||||||
|
|
||||||
@ -89,8 +89,27 @@ method: `POST`
|
|||||||
|
|
||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 |类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | -----------|
|
| ------ | ---- | ---- |
|
||||||
|
| 无 | | |
|
||||||
|
|
||||||
|
返回:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"data": {}, "retcode": 0, "status": "ok"}
|
||||||
|
```
|
||||||
|
|
||||||
|
### admin/do_process_restart
|
||||||
|
|
||||||
|
> 冷重启
|
||||||
|
|
||||||
|
method: `POST`
|
||||||
|
|
||||||
|
|
||||||
|
参数:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 说明 |
|
||||||
|
| ------ | ---- | ---- |
|
||||||
| 无 | | |
|
| 无 | | |
|
||||||
|
|
||||||
返回:
|
返回:
|
||||||
@ -109,7 +128,7 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------------ | ------ | ------------------------------------- |
|
||||||
| uin | string | qq号 |
|
| uin | string | qq号 |
|
||||||
| password | string | qq密码 |
|
| password | string | qq密码 |
|
||||||
| enable_db | string | 是否启动数据库,填 'true' 或者 'false' |
|
| enable_db | string | 是否启动数据库,填 'true' 或者 'false' |
|
||||||
@ -131,12 +150,12 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ----------- | ------ | --------------------------------------------- |
|
||||||
| port | string | 服务端口 |
|
| port | string | 服务端口 |
|
||||||
| host | string | 服务监听地址 |
|
| host | string | 服务监听地址 |
|
||||||
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
||||||
| timeout | string | http请求超时时间 |
|
| timeout | string | http请求超时时间 |
|
||||||
| post_url | string | post上报地址 不需要就填空字符串,或者不填|
|
| post_url | string | post上报地址 不需要就填空字符串,或者不填 |
|
||||||
| post_secret | string | post上报的secret 不需要就填空字符串,或者不填 |
|
| post_secret | string | post上报的secret 不需要就填空字符串,或者不填 |
|
||||||
|
|
||||||
返回:
|
返回:
|
||||||
@ -155,7 +174,7 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | -------------------------------- |
|
||||||
| port | string | 服务端口 |
|
| port | string | 服务端口 |
|
||||||
| host | string | 服务监听地址 |
|
| host | string | 服务监听地址 |
|
||||||
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
||||||
@ -176,7 +195,7 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | -------------------------------- |
|
||||||
| port | string | 服务端口 |
|
| port | string | 服务端口 |
|
||||||
| host | string | 服务监听地址 |
|
| host | string | 服务监听地址 |
|
||||||
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
| enable | string | 是否启用 ,填 'true' 或者 'false' |
|
||||||
@ -197,7 +216,7 @@ method: `POST` formdata
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | ----------------------------------- |
|
||||||
| json | string | 完整的config.json的配合,json字符串 |
|
| json | string | 完整的config.json的配合,json字符串 |
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +235,7 @@ method: `GET`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ---- | ---- |
|
||||||
| 无 | | |
|
| 无 | | |
|
||||||
|
|
||||||
|
|
||||||
@ -227,6 +246,6 @@ method: `GET`
|
|||||||
```
|
```
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | ----------------------------------- |
|
||||||
| config | string | 完整的config.json的配合,json字符串 |
|
| config | string | 完整的config.json的配合,json字符串 |
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
|
|||||||
````
|
````
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------------ | -------- | ------------------------------------------------------------------- |
|
| --------------------- | -------- | ---------------------------------------------------------------------------------------- |
|
||||||
| uin | int64 | 登录用QQ号 |
|
| uin | int64 | 登录用QQ号 |
|
||||||
| password | string | 登录用密码 |
|
| password | string | 登录用密码 |
|
||||||
| encrypt_password | bool | 是否对密码进行加密. |
|
| encrypt_password | bool | 是否对密码进行加密. |
|
||||||
@ -76,14 +76,14 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
|
|||||||
| frequency | float64 | 1s内能调用API的次数 |
|
| frequency | float64 | 1s内能调用API的次数 |
|
||||||
| bucket_size | int | 令牌桶的大小,默认为1,修改此值可允许一定程度内连续调用api |
|
| bucket_size | int | 令牌桶的大小,默认为1,修改此值可允许一定程度内连续调用api |
|
||||||
| post_message_format | string | 上报信息类型 |
|
| post_message_format | string | 上报信息类型 |
|
||||||
| ignore_invalid_cqcode| bool | 是否忽略错误的CQ码 |
|
| ignore_invalid_cqcode | bool | 是否忽略错误的CQ码 |
|
||||||
| force_fragmented | bool | 是否强制分片发送群长消息 |
|
| force_fragmented | 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配置 |
|
||||||
| ws_config | object | Websocket API 配置 |
|
| ws_config | object | Websocket API 配置 |
|
||||||
| ws_reverse_servers | object[] | 反向 Websocket API 配置 |
|
| ws_reverse_servers | object[] | 反向 Websocket API 配置 |
|
||||||
| log_level | string | 指定日志收集级别,将收集的日志单独存放到固定文件中,便于查看日志线索 当前支持 warn,error|
|
| log_level | string | 指定日志收集级别,将收集的日志单独存放到固定文件中,便于查看日志线索 当前支持 warn,error |
|
||||||
|
|
||||||
> 注: 开启密码加密后程序将在每次启动时要求输入解密密钥, 密钥错误会导致登录时提示密码错误.
|
> 注: 开启密码加密后程序将在每次启动时要求输入解密密钥, 密钥错误会导致登录时提示密码错误.
|
||||||
> 解密后密码将储存在内存中,用于自动重连等功能. 所以此加密并不能防止内存读取.
|
> 解密后密码将储存在内存中,用于自动重连等功能. 所以此加密并不能防止内存读取.
|
||||||
@ -111,9 +111,22 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
|
|||||||
在大部分情况下 我们只需要关心 `protocol` 字段:
|
在大部分情况下 我们只需要关心 `protocol` 字段:
|
||||||
|
|
||||||
| 值 | 类型 | 限制 |
|
| 值 | 类型 | 限制 |
|
||||||
| ---- | ------------- | ----------------------------------------------------- |
|
| --- | ------------- | ---------------------------------------------------------------- |
|
||||||
| 0 | Android Pad | 无法接收 `group_notify` 事件、无法接收口令红包 |
|
| 0 | iPad | 无 |
|
||||||
| 1 | Android Phone | 无 |
|
| 1 | Android Phone | 无法接收新版表情如 `/吃瓜 /汪汪`, 会自动转换为字符串 |
|
||||||
| 2 | Android Watch | 除了 `Android Pad` 有的限制外还包括: 无法接收撤回消息 |
|
| 2 | Android Watch | 除`Android Phone`的限制外, 无法接收 `notify` 事件、无法接收口令红包、无法接收撤回消息 |
|
||||||
|
| 3 | MacOS | 无 |
|
||||||
|
|
||||||
> 注意, 根据协议的不同, 各类消息有所限制
|
> 注意, 根据协议的不同, 各类消息有所限制
|
||||||
|
|
||||||
|
## 自定义服务器IP
|
||||||
|
|
||||||
|
> 某些海外服务器使用默认地址可能会存在链路问题,此功能可以指定 go-cqhttp 连接哪些地址以达到最优化.
|
||||||
|
|
||||||
|
将文件 `address.txt` 创建到 `go-cqhttp` 工作目录, 并键入 `IP:PORT` 以换行符为分割即可.
|
||||||
|
|
||||||
|
示例:
|
||||||
|
````
|
||||||
|
1.1.1.1:53
|
||||||
|
1.1.2.2:8899
|
||||||
|
````
|
120
docs/cqhttp.md
120
docs/cqhttp.md
@ -7,7 +7,7 @@
|
|||||||
### 图片
|
### 图片
|
||||||
|
|
||||||
| 参数名 | 可能的值 | 说明 |
|
| 参数名 | 可能的值 | 说明 |
|
||||||
| --- | --- | --- |
|
| ------- | --------------- | --------------------------------------------------------------- |
|
||||||
| `file` | - | 图片文件名 |
|
| `file` | - | 图片文件名 |
|
||||||
| `type` | `flash`,`show` | 图片类型,`flash` 表示闪照,`show` 表示秀图,默认普通图片 |
|
| `type` | `flash`,`show` | 图片类型,`flash` 表示闪照,`show` 表示秀图,默认普通图片 |
|
||||||
| `url` | - | 图片 URL |
|
| `url` | - | 图片 URL |
|
||||||
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
可用的特效ID:
|
可用的特效ID:
|
||||||
|
|
||||||
| id |类型 |
|
| id | 类型 |
|
||||||
| --- |-------|
|
| ----- | ---- |
|
||||||
| 40000 | 普通 |
|
| 40000 | 普通 |
|
||||||
| 40001 | 幻影 |
|
| 40001 | 幻影 |
|
||||||
| 40002 | 抖动 |
|
| 40002 | 抖动 |
|
||||||
@ -65,7 +65,7 @@ Type: `poke`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| ------ | ----- | ------------ |
|
||||||
| qq | int64 | 需要戳的成员 |
|
| qq | int64 | 需要戳的成员 |
|
||||||
|
|
||||||
示例: `[CQ:poke,qq=123456]`
|
示例: `[CQ:poke,qq=123456]`
|
||||||
@ -80,17 +80,17 @@ Type: `gift`
|
|||||||
|
|
||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 |类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | -----------|
|
| ------ | ----- | -------------- |
|
||||||
| qq | int64 | 接收礼物的成员 |
|
| qq | int64 | 接收礼物的成员 |
|
||||||
| id | int | 礼物的类型 |
|
| id | int | 礼物的类型 |
|
||||||
|
|
||||||
目前支持的礼物ID:
|
目前支持的礼物ID:
|
||||||
|
|
||||||
| id |类型 |
|
| id | 类型 |
|
||||||
| ---| ---------|
|
| --- | ---------- |
|
||||||
| 0 | 甜Wink |
|
| 0 | 甜Wink |
|
||||||
| 1 | 快乐肥宅水|
|
| 1 | 快乐肥宅水 |
|
||||||
| 2 | 幸运手链 |
|
| 2 | 幸运手链 |
|
||||||
| 3 | 卡布奇诺 |
|
| 3 | 卡布奇诺 |
|
||||||
| 4 | 猫咪手表 |
|
| 4 | 猫咪手表 |
|
||||||
@ -98,6 +98,12 @@ Type: `gift`
|
|||||||
| 6 | 彩虹糖果 |
|
| 6 | 彩虹糖果 |
|
||||||
| 7 | 坚强 |
|
| 7 | 坚强 |
|
||||||
| 8 | 告白话筒 |
|
| 8 | 告白话筒 |
|
||||||
|
| 9 | 牵你的手 |
|
||||||
|
| 10 | 可爱猫咪 |
|
||||||
|
| 11 | 神秘面具 |
|
||||||
|
| 12 | 我超忙的 |
|
||||||
|
| 13 | 爱心口罩 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
示例: `[CQ:gift,qq=123456,id=8]`
|
示例: `[CQ:gift,qq=123456,id=8]`
|
||||||
@ -111,7 +117,7 @@ Type: `forward`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | ------------------------------------------------------------- |
|
||||||
| id | string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 |
|
| id | string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 |
|
||||||
|
|
||||||
示例: `[CQ:forward,id=xxxx]`
|
示例: `[CQ:forward,id=xxxx]`
|
||||||
@ -125,7 +131,7 @@ Type: `node`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 | 特殊说明 |
|
| 参数名 | 类型 | 说明 | 特殊说明 |
|
||||||
| ------- | ------- | -------------- | ------------------------------------------------------------ |
|
| ------- | ------- | -------------- | -------------------------------------------------------------------------------------- |
|
||||||
| id | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** |
|
| id | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** |
|
||||||
| name | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) |
|
| name | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) |
|
||||||
| uin | int64 | 发送者QQ号 | 用于自定义消息 |
|
| uin | int64 | 发送者QQ号 | 用于自定义消息 |
|
||||||
@ -212,9 +218,9 @@ Type: `xml`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | ----------------------------------------- |
|
||||||
| data | string | xml内容,xml中的value部分,记得实体化处理|
|
| data | string | xml内容,xml中的value部分,记得实体化处理 |
|
||||||
| resid | int32 | 可以不填|
|
| resid | int32 | 可以不填 |
|
||||||
|
|
||||||
示例: `[CQ:xml,data=xxxx]`
|
示例: `[CQ:xml,data=xxxx]`
|
||||||
|
|
||||||
@ -261,9 +267,9 @@ Type: `json`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| ------ | ------ | ----------------------------------------------- |
|
||||||
| data | string | json内容,json的所有字符串记得实体化处理|
|
| data | string | json内容,json的所有字符串记得实体化处理 |
|
||||||
| resid | int32 | 默认不填为0,走小程序通道,填了走富文本通道发送|
|
| resid | int32 | 默认不填为0,走小程序通道,填了走富文本通道发送 |
|
||||||
|
|
||||||
json中的字符串需要进行转义:
|
json中的字符串需要进行转义:
|
||||||
|
|
||||||
@ -294,14 +300,14 @@ Type: `cardimage`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ------------------------------------------------------------ |
|
| --------- | ------ | ------------------------------------- |
|
||||||
| file | string | 和image的file字段对齐,支持也是一样的|
|
| file | string | 和image的file字段对齐,支持也是一样的 |
|
||||||
| minwidth | int64 | 默认不填为400,最小width|
|
| minwidth | int64 | 默认不填为400,最小width |
|
||||||
| minheight | int64 | 默认不填为400,最小height|
|
| minheight | int64 | 默认不填为400,最小height |
|
||||||
| maxwidth | int64 | 默认不填为500,最大width|
|
| maxwidth | int64 | 默认不填为500,最大width |
|
||||||
| maxheight | int64 | 默认不填为1000,最大height|
|
| maxheight | int64 | 默认不填为1000,最大height |
|
||||||
| source | string | 分享来源的名称,可以留空|
|
| source | string | 分享来源的名称,可以留空 |
|
||||||
| icon | string | 分享来源的icon图标url,可以留空|
|
| icon | string | 分享来源的icon图标url,可以留空 |
|
||||||
|
|
||||||
|
|
||||||
示例cardimage 的cq码:
|
示例cardimage 的cq码:
|
||||||
@ -320,7 +326,7 @@ Type: `tts`
|
|||||||
参数:
|
参数:
|
||||||
|
|
||||||
| 参数名 | 类型 | 说明 |
|
| 参数名 | 类型 | 说明 |
|
||||||
| ------ | ------ | ----------- |
|
| ------ | ------ | ---- |
|
||||||
| text | string | 内容 |
|
| text | string | 内容 |
|
||||||
|
|
||||||
示例: `[CQ:tts,text=这是一条测试消息]`
|
示例: `[CQ:tts,text=这是一条测试消息]`
|
||||||
@ -334,7 +340,7 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| -------- | ------ | ---- |
|
| ---------- | ------ | ---- |
|
||||||
| group_id | int64 | 群号 |
|
| group_id | int64 | 群号 |
|
||||||
| group_name | string | 新名 |
|
| group_name | string | 新名 |
|
||||||
|
|
||||||
@ -345,7 +351,7 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| -------- | ------ | ---- |
|
| -------- | ------ | ------------------------ |
|
||||||
| group_id | int64 | 群号 |
|
| group_id | int64 | 群号 |
|
||||||
| file | string | 图片文件名 |
|
| file | string | 图片文件名 |
|
||||||
| cache | int | 表示是否使用已缓存的文件 |
|
| cache | int | 表示是否使用已缓存的文件 |
|
||||||
@ -463,13 +469,13 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| --------- | ------ | ---- |
|
||||||
| `content` | string | 内容 |
|
| `content` | string | 内容 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| -------- | -------- | ---- |
|
||||||
| `slices` | string[] | 词组 |
|
| `slices` | string[] | 词组 |
|
||||||
|
|
||||||
### 图片OCR
|
### 图片OCR
|
||||||
@ -481,22 +487,22 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| ------- | ------ | ------ |
|
||||||
| `image` | string | 图片ID |
|
| `image` | string | 图片ID |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ---------- | --------------- | ------- |
|
||||||
| `texts` | TextDetection[] | OCR结果 |
|
| `texts` | TextDetection[] | OCR结果 |
|
||||||
| `language` | string | 语言 |
|
| `language` | string | 语言 |
|
||||||
|
|
||||||
**TextDetection**
|
**TextDetection**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ------------- | ------- | ------ |
|
||||||
| `text` | string | 文本 |
|
| `text` | string | 文本 |
|
||||||
| `confidence`| int32 | 置信度 |
|
| `confidence` | int32 | 置信度 |
|
||||||
| `coordinates` | vector2 | 坐标 |
|
| `coordinates` | vector2 | 坐标 |
|
||||||
|
|
||||||
|
|
||||||
@ -507,7 +513,7 @@ Type: `tts`
|
|||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ------------------ | ---------------- | ------------ |
|
||||||
| `invited_requests` | InvitedRequest[] | 邀请消息列表 |
|
| `invited_requests` | InvitedRequest[] | 邀请消息列表 |
|
||||||
| `join_requests` | JoinRequest[] | 进群消息列表 |
|
| `join_requests` | JoinRequest[] | 进群消息列表 |
|
||||||
|
|
||||||
@ -516,26 +522,26 @@ Type: `tts`
|
|||||||
**InvitedRequest**
|
**InvitedRequest**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| -------------- | ------ | ----------------- |
|
||||||
| `request_id` | int64 | 请求ID |
|
| `request_id` | int64 | 请求ID |
|
||||||
| `invitor_uin` | int64 | 邀请者 |
|
| `invitor_uin` | int64 | 邀请者 |
|
||||||
| `invitor_nick` | string | 邀请者昵称 |
|
| `invitor_nick` | string | 邀请者昵称 |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `group_name` | string | 群名 |
|
| `group_name` | string | 群名 |
|
||||||
| `checked` | bool | 是否已被处理|
|
| `checked` | bool | 是否已被处理 |
|
||||||
| `actor` | int64 | 处理者, 未处理为0 |
|
| `actor` | int64 | 处理者, 未处理为0 |
|
||||||
|
|
||||||
**JoinRequest**
|
**JoinRequest**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ---------------- | ------ | ----------------- |
|
||||||
| `request_id` | int64 | 请求ID |
|
| `request_id` | int64 | 请求ID |
|
||||||
| `requester_uin` | int64 | 请求者ID |
|
| `requester_uin` | int64 | 请求者ID |
|
||||||
| `requester_nick` | string | 请求者昵称 |
|
| `requester_nick` | string | 请求者昵称 |
|
||||||
| `message` | string | 验证消息 |
|
| `message` | string | 验证消息 |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `group_name` | string | 群名 |
|
| `group_name` | string | 群名 |
|
||||||
| `checked` | bool | 是否已被处理|
|
| `checked` | bool | 是否已被处理 |
|
||||||
| `actor` | int64 | 处理者, 未处理为0 |
|
| `actor` | int64 | 处理者, 未处理为0 |
|
||||||
|
|
||||||
### 获取群文件系统信息
|
### 获取群文件系统信息
|
||||||
@ -545,13 +551,13 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| ---------- | ----- | ---- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ------------- | ----- | ---------- |
|
||||||
| `file_count` | int32 | 文件总数 |
|
| `file_count` | int32 | 文件总数 |
|
||||||
| `limit_count` | int32 | 文件上限 |
|
| `limit_count` | int32 | 文件上限 |
|
||||||
| `used_space` | int64 | 已使用空间 |
|
| `used_space` | int64 | 已使用空间 |
|
||||||
@ -566,13 +572,13 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| ---------- | ----- | ---- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| --------- | -------- | ---------- |
|
||||||
| `files` | File[] | 文件列表 |
|
| `files` | File[] | 文件列表 |
|
||||||
| `folders` | Folder[] | 文件夹列表 |
|
| `folders` | Folder[] | 文件夹列表 |
|
||||||
|
|
||||||
@ -585,14 +591,14 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| ----------- | ------ | --------------------------- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `folder_id` | string | 文件夹ID 参考 `Folder` 对象 |
|
| `folder_id` | string | 文件夹ID 参考 `Folder` 对象 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| --------- | -------- | ---------- |
|
||||||
| `files` | File[] | 文件列表 |
|
| `files` | File[] | 文件列表 |
|
||||||
| `folders` | Folder[] | 文件夹列表 |
|
| `folders` | Folder[] | 文件夹列表 |
|
||||||
|
|
||||||
@ -605,7 +611,7 @@ Type: `tts`
|
|||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------ | ------ | ------ |
|
| ---------- | ------ | ------------------------- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `file_id` | string | 文件ID 参考 `File` 对象 |
|
| `file_id` | string | 文件ID 参考 `File` 对象 |
|
||||||
| `busid` | int32 | 文件类型 参考 `File` 对象 |
|
| `busid` | int32 | 文件类型 参考 `File` 对象 |
|
||||||
@ -613,13 +619,13 @@ Type: `tts`
|
|||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ----- | ------ | ------------ |
|
||||||
| `url` | string | 文件下载链接 |
|
| `url` | string | 文件下载链接 |
|
||||||
|
|
||||||
**File**
|
**File**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ---------------- | ------ | ---------------------- |
|
||||||
| `file_id` | string | 文件ID |
|
| `file_id` | string | 文件ID |
|
||||||
| `file_name` | string | 文件名 |
|
| `file_name` | string | 文件名 |
|
||||||
| `busid` | int32 | 文件类型 |
|
| `busid` | int32 | 文件类型 |
|
||||||
@ -634,7 +640,7 @@ Type: `tts`
|
|||||||
**Folder**
|
**Folder**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----------------- | -------- |
|
| ------------------ | ------ | ---------- |
|
||||||
| `folder_id` | string | 文件夹ID |
|
| `folder_id` | string | 文件夹ID |
|
||||||
| `folder_name` | string | 文件名 |
|
| `folder_name` | string | 文件名 |
|
||||||
| `create_time` | int64 | 创建时间 |
|
| `create_time` | int64 | 创建时间 |
|
||||||
@ -662,9 +668,9 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | --------------- | -------------- |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `friend_recall`| 消息类型 |
|
| `notice_type` | string | `friend_recall` | 消息类型 |
|
||||||
| `user_id` | int64 | | 好友id |
|
| `user_id` | int64 | | 好友id |
|
||||||
| `message_id` | int64 | | 被撤回的消息id |
|
| `message_id` | int64 | | 被撤回的消息id |
|
||||||
|
|
||||||
@ -675,7 +681,7 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | -------- | -------- |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `notify` | 消息类型 |
|
| `notice_type` | string | `notify` | 消息类型 |
|
||||||
| `group_id` | int64 | | 群号 |
|
| `group_id` | int64 | | 群号 |
|
||||||
@ -690,7 +696,7 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | ------------ | ------------ |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `notify` | 消息类型 |
|
| `notice_type` | string | `notify` | 消息类型 |
|
||||||
| `group_id` | int64 | | 群号 |
|
| `group_id` | int64 | | 群号 |
|
||||||
@ -705,7 +711,7 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | -------------------------------------------------------- | -------- |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `notify` | 消息类型 |
|
| `notice_type` | string | `notify` | 消息类型 |
|
||||||
| `group_id` | int64 | | 群号 |
|
| `group_id` | int64 | | 群号 |
|
||||||
@ -720,7 +726,7 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | ------------ | -------- |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `group_card` | 消息类型 |
|
| `notice_type` | string | `group_card` | 消息类型 |
|
||||||
| `group_id` | int64 | | 群号 |
|
| `group_id` | int64 | | 群号 |
|
||||||
@ -735,7 +741,7 @@ Type: `tts`
|
|||||||
**上报数据**
|
**上报数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------------- | ------ | -------------- | -------- |
|
||||||
| `post_type` | string | `notice` | 上报类型 |
|
| `post_type` | string | `notice` | 上报类型 |
|
||||||
| `notice_type` | string | `offline_file` | 消息类型 |
|
| `notice_type` | string | `offline_file` | 消息类型 |
|
||||||
| `user_id` | int64 | | 发送者id |
|
| `user_id` | int64 | | 发送者id |
|
||||||
@ -744,7 +750,7 @@ Type: `tts`
|
|||||||
**file object**
|
**file object**
|
||||||
|
|
||||||
| 字段 | 类型 | 可能的值 | 说明 |
|
| 字段 | 类型 | 可能的值 | 说明 |
|
||||||
| ------------- | ------ | -------------- | -------------- |
|
| ------ | ------ | -------- | -------- |
|
||||||
| `name` | string | | 文件名 |
|
| `name` | string | | 文件名 |
|
||||||
| `size` | int64 | | 文件大小 |
|
| `size` | int64 | | 文件大小 |
|
||||||
| `url` | string | | 下载链接 |
|
| `url` | string | | 下载链接 |
|
@ -117,7 +117,31 @@ enable ws?(Y/n)
|
|||||||
|
|
||||||
*注:可以使用*`go env -w GOPROXY=https://goproxy.cn,direct`*来加速国内依赖安装速度*
|
*注:可以使用*`go env -w GOPROXY=https://goproxy.cn,direct`*来加速国内依赖安装速度*
|
||||||
|
|
||||||
*注:此时构建后的文件名为*`main`(Linux)或`main.exe`(Windows)
|
*注:此时构建后的文件名为*`go-cqhttp`(Linux)或`go-cqhttp.exe`(Windows)
|
||||||
|
|
||||||
|
## 更新
|
||||||
|
|
||||||
|
### 方法一
|
||||||
|
|
||||||
|
从[release] (https://github.com/Mrs4s/go-cqhttp/releases)界面下载最新版本的go-cqhttp
|
||||||
|
并替换之前的版本
|
||||||
|
|
||||||
|
### 方法二
|
||||||
|
|
||||||
|
使用更新参数,在命令行中打开go-cqhttp所在目录
|
||||||
|
#### windows
|
||||||
|
输入指令
|
||||||
|
`go-cqhttp.exe update`
|
||||||
|
|
||||||
|
如果在国内连接github下载速度可能很慢,可以使用镜像源下载
|
||||||
|
|
||||||
|
`go-cqhttp.exe update https://github.rc1844.workers.dev`
|
||||||
|
|
||||||
|
几个可用的镜像源
|
||||||
|
- `https://hub.fastgit.org`
|
||||||
|
- `https://github.com.cnpmjs.org`
|
||||||
|
- `https://github.bajins.com`
|
||||||
|
- `https://github.rc1844.workers.dev`
|
||||||
|
|
||||||
|
#### linux
|
||||||
|
方法与windows基本一致,将 `go-cqhttp.exe` 替换为 `./go-cqhttp`即可
|
@ -4,11 +4,12 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/wdvxdr1123/go-silk/silk"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/wdvxdr1123/go-silk/silk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var codec silk.Encoder
|
var codec silk.Encoder
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Filter interface {
|
type Filter interface {
|
||||||
|
25
global/fs.go
25
global/fs.go
@ -7,14 +7,17 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dustin/go-humanize"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -110,6 +113,24 @@ func DelFile(path string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReadAddrFile(path string) []*net.TCPAddr {
|
||||||
|
d, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
str := string(d)
|
||||||
|
lines := strings.Split(str, "\n")
|
||||||
|
var ret []*net.TCPAddr
|
||||||
|
for _, l := range lines {
|
||||||
|
ip := strings.Split(strings.TrimSpace(l), ":")
|
||||||
|
if len(ip) == 2 {
|
||||||
|
port, _ := strconv.Atoi(ip[1])
|
||||||
|
ret = append(ret, &net.TCPAddr{IP: net.ParseIP(ip[0]), Port: port})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
type WriteCounter struct {
|
type WriteCounter struct {
|
||||||
Total uint64
|
Total uint64
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client = &http.Client{
|
var client = &http.Client{
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"math"
|
"math"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trueSet = map[string]struct{}{
|
var trueSet = map[string]struct{}{
|
||||||
|
@ -2,6 +2,7 @@ package global
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
|
|||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201112150130-58e7c82fd2dd
|
github.com/Mrs4s/MiraiGo v0.0.0-20201117154121-989187125900
|
||||||
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/go-update v0.0.0-20190510022740-79c495ab728c
|
||||||
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect
|
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect
|
||||||
|
4
go.sum
4
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-20201112150130-58e7c82fd2dd h1:n1llMhWgT5s/dBWtbg0NwDzXFAKWfwr1ZXxaErZkLfc=
|
github.com/Mrs4s/MiraiGo v0.0.0-20201117154121-989187125900 h1:xnx3dH7hgZ/Z4k33EhKzBmQhwASJ5bvsorqPhO0DWbc=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201112150130-58e7c82fd2dd/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
|
github.com/Mrs4s/MiraiGo v0.0.0-20201117154121-989187125900/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
|
||||||
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=
|
||||||
|
111
main.go
111
main.go
@ -2,33 +2,37 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Mrs4s/go-cqhttp/server"
|
|
||||||
"github.com/guonaihong/gout"
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Mrs4s/go-cqhttp/server"
|
||||||
|
"github.com/guonaihong/gout"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
|
||||||
"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"
|
"github.com/getlantern/go-update"
|
||||||
"github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/rifflock/lfshook"
|
"github.com/rifflock/lfshook"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/t-tomalak/logrus-easy-formatter"
|
easy "github.com/t-tomalak/logrus-easy-formatter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -93,14 +97,28 @@ func init() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
console := bufio.NewReader(os.Stdin)
|
console := bufio.NewReader(os.Stdin)
|
||||||
|
var strKey string
|
||||||
|
var isFastStart bool = false
|
||||||
arg := os.Args
|
arg := os.Args
|
||||||
if len(arg) > 1 && arg[1] == "update" {
|
if len(arg) > 1 {
|
||||||
if len(arg) > 2 {
|
for i := range arg {
|
||||||
selfUpdate(arg[2])
|
switch arg[i] {
|
||||||
|
case "update":
|
||||||
|
if len(arg) > i+1 {
|
||||||
|
selfUpdate(arg[i+1])
|
||||||
} else {
|
} else {
|
||||||
selfUpdate("")
|
selfUpdate("")
|
||||||
}
|
}
|
||||||
|
case "key":
|
||||||
|
if len(arg) > i+1 {
|
||||||
|
b := []byte(arg[i+1])
|
||||||
|
b = append(b, 13, 10)
|
||||||
|
strKey = string(b[:])
|
||||||
|
}
|
||||||
|
case "faststart":
|
||||||
|
isFastStart = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var conf *global.JsonConfig
|
var conf *global.JsonConfig
|
||||||
@ -216,22 +234,42 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.PasswordEncrypted != "" {
|
if conf.PasswordEncrypted != "" {
|
||||||
|
if strKey == "" {
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
||||||
strKey, _ := console.ReadString('\n')
|
ctx := context.Background()
|
||||||
|
go func(ctx context.Context) {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case <-time.After(time.Second * 45):
|
||||||
|
log.Infof("解密key输入超时")
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}(ctx)
|
||||||
|
strKey, _ = console.ReadString('\n')
|
||||||
|
ctx.Done()
|
||||||
|
} else {
|
||||||
|
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
|
||||||
|
}
|
||||||
key := md5.Sum([]byte(strKey))
|
key := md5.Sum([]byte(strKey))
|
||||||
conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:])
|
conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:])
|
||||||
}
|
}
|
||||||
|
if !isFastStart {
|
||||||
log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.")
|
log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.")
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
|
}
|
||||||
log.Info("开始尝试登录并同步消息...")
|
log.Info("开始尝试登录并同步消息...")
|
||||||
log.Infof("使用协议: %v", func() string {
|
log.Infof("使用协议: %v", func() string {
|
||||||
switch client.SystemDeviceInfo.Protocol {
|
switch client.SystemDeviceInfo.Protocol {
|
||||||
case client.AndroidPad:
|
case client.IPad:
|
||||||
return "Android Pad"
|
return "iPad"
|
||||||
case client.AndroidPhone:
|
case client.AndroidPhone:
|
||||||
return "Android Phone"
|
return "Android Phone"
|
||||||
case client.AndroidWatch:
|
case client.AndroidWatch:
|
||||||
return "Android Watch"
|
return "Android Watch"
|
||||||
|
case client.MacOS:
|
||||||
|
return "MacOS"
|
||||||
}
|
}
|
||||||
return "未知"
|
return "未知"
|
||||||
}())
|
}())
|
||||||
@ -246,6 +284,14 @@ func main() {
|
|||||||
log.Debug("Protocol -> " + e.Message)
|
log.Debug("Protocol -> " + e.Message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if global.PathExists("address.txt") {
|
||||||
|
log.Infof("检测到 address.txt 文件. 将覆盖目标IP.")
|
||||||
|
addr := global.ReadAddrFile("address.txt")
|
||||||
|
if len(addr) > 0 {
|
||||||
|
cli.SetCustomServer(addr)
|
||||||
|
}
|
||||||
|
log.Infof("读取到 %v 个自定义地址.", len(addr))
|
||||||
|
}
|
||||||
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool {
|
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool {
|
||||||
if !conf.UseSSOAddress {
|
if !conf.UseSSOAddress {
|
||||||
log.Infof("收到服务器地址更新通知, 根据配置文件已忽略.")
|
log.Infof("收到服务器地址更新通知, 根据配置文件已忽略.")
|
||||||
@ -274,10 +320,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
b := server.WebServer.Run(fmt.Sprintf("%s:%d", conf.WebUi.Host, conf.WebUi.WebUiPort), cli)
|
b := server.WebServer.Run(fmt.Sprintf("%s:%d", conf.WebUi.Host, conf.WebUi.WebUiPort), cli)
|
||||||
c := server.Console
|
c := server.Console
|
||||||
|
r := server.Restart
|
||||||
go checkUpdate()
|
go checkUpdate()
|
||||||
signal.Notify(c, os.Interrupt, os.Kill)
|
signal.Notify(c, os.Interrupt, os.Kill)
|
||||||
<-c
|
select {
|
||||||
|
case <-c:
|
||||||
b.Release()
|
b.Release()
|
||||||
|
case <-r:
|
||||||
|
log.Info("正在重启中...")
|
||||||
|
server.HttpServer.ShutDown()
|
||||||
|
defer b.Release()
|
||||||
|
restart(arg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func EncryptPwd(pwd string, key []byte) string {
|
func EncryptPwd(pwd string, key []byte) string {
|
||||||
@ -396,3 +450,34 @@ func selfUpdate(imageUrl string) {
|
|||||||
readLine()
|
readLine()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func restart(Args []string) {
|
||||||
|
cmd := &exec.Cmd{}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
file, err := exec.LookPath(Args[0])
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("重启失败:%s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
path, err := filepath.Abs(file)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("重启失败:%s", err.Error())
|
||||||
|
}
|
||||||
|
Args = append([]string{"/c", "start ", path, "faststart"}, Args[1:]...)
|
||||||
|
cmd = &exec.Cmd{
|
||||||
|
Path: "cmd.exe",
|
||||||
|
Args: Args,
|
||||||
|
Stderr: os.Stderr,
|
||||||
|
Stdout: os.Stdout,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Args = append(Args, "faststart")
|
||||||
|
cmd = &exec.Cmd{
|
||||||
|
Path: Args[0],
|
||||||
|
Args: Args,
|
||||||
|
Stderr: os.Stderr,
|
||||||
|
Stdout: os.Stdout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd.Start()
|
||||||
|
}
|
||||||
|
@ -6,13 +6,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Mrs4s/MiraiGo/client"
|
|
||||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"github.com/yinghau76/go-ascii-art"
|
|
||||||
"image"
|
"image"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -21,12 +14,22 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
asciiart "github.com/yinghau76/go-ascii-art"
|
||||||
)
|
)
|
||||||
|
|
||||||
var WebInput = make(chan string, 1) //长度1,用于阻塞
|
var WebInput = make(chan string, 1) //长度1,用于阻塞
|
||||||
|
|
||||||
var Console = make(chan os.Signal, 1)
|
var Console = make(chan os.Signal, 1)
|
||||||
|
|
||||||
|
var Restart = make(chan struct{}, 1)
|
||||||
|
|
||||||
var JsonConfig *global.JsonConfig
|
var JsonConfig *global.JsonConfig
|
||||||
|
|
||||||
type webServer struct {
|
type webServer struct {
|
||||||
@ -42,6 +45,7 @@ var WebServer = &webServer{}
|
|||||||
// admin 子站的 路由映射
|
// admin 子站的 路由映射
|
||||||
var HttpuriAdmin = map[string]func(s *webServer, c *gin.Context){
|
var HttpuriAdmin = map[string]func(s *webServer, c *gin.Context){
|
||||||
"do_restart": AdminDoRestart, //热重启
|
"do_restart": AdminDoRestart, //热重启
|
||||||
|
"do_process_restart": AdminProcessRestart, //进程重启
|
||||||
"get_web_write": AdminWebWrite, //获取是否验证码输入
|
"get_web_write": AdminWebWrite, //获取是否验证码输入
|
||||||
"do_web_write": AdminDoWebWrite, //web上进行输入操作
|
"do_web_write": AdminDoWebWrite, //web上进行输入操作
|
||||||
"do_restart_docker": AdminDoRestartDocker, //直接停止(依赖supervisord/docker)重新拉起
|
"do_restart_docker": AdminDoRestartDocker, //直接停止(依赖supervisord/docker)重新拉起
|
||||||
@ -239,6 +243,7 @@ func (s *webServer) Dologin() {
|
|||||||
rsp, err := cli.Login()
|
rsp, err := cli.Login()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("重连失败: %v", err)
|
log.Errorf("重连失败: %v", err)
|
||||||
|
cli.Disconnect()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !rsp.Success {
|
if !rsp.Success {
|
||||||
@ -339,12 +344,14 @@ func (s *webServer) DoReLogin() { // TODO: 协议层的 ReLogin
|
|||||||
log.Info("开始尝试登录并同步消息...")
|
log.Info("开始尝试登录并同步消息...")
|
||||||
log.Infof("使用协议: %v", func() string {
|
log.Infof("使用协议: %v", func() string {
|
||||||
switch client.SystemDeviceInfo.Protocol {
|
switch client.SystemDeviceInfo.Protocol {
|
||||||
case client.AndroidPad:
|
case client.IPad:
|
||||||
return "Android Pad"
|
return "iPad"
|
||||||
case client.AndroidPhone:
|
case client.AndroidPhone:
|
||||||
return "Android Phone"
|
return "Android Phone"
|
||||||
case client.AndroidWatch:
|
case client.AndroidWatch:
|
||||||
return "Android Watch"
|
return "Android Watch"
|
||||||
|
case client.MacOS:
|
||||||
|
return "MacOS"
|
||||||
}
|
}
|
||||||
return "未知"
|
return "未知"
|
||||||
}())
|
}())
|
||||||
@ -420,6 +427,12 @@ func AdminDoRestart(s *webServer, c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 进程重启
|
||||||
|
func AdminProcessRestart(s *webServer, c *gin.Context) {
|
||||||
|
Restart <- struct{}{}
|
||||||
|
c.JSON(200, coolq.OK(coolq.MSG{}))
|
||||||
|
}
|
||||||
|
|
||||||
// 冷重启
|
// 冷重启
|
||||||
func AdminDoRestartDocker(s *webServer, c *gin.Context) {
|
func AdminDoRestartDocker(s *webServer, c *gin.Context) {
|
||||||
Console <- os.Kill
|
Console <- os.Kill
|
||||||
|
274
server/http.go
274
server/http.go
@ -5,13 +5,14 @@ import (
|
|||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"github.com/guonaihong/gout/dataflow"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/guonaihong/gout/dataflow"
|
||||||
|
|
||||||
"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/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -161,78 +162,78 @@ func (s *httpServer) HandleActions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetLoginInfo(c *gin.Context) {
|
func GetLoginInfo(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQGetLoginInfo())
|
c.JSON(200, s.bot.CQGetLoginInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetFriendList(c *gin.Context) {
|
func GetFriendList(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQGetFriendList())
|
c.JSON(200, s.bot.CQGetFriendList())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupList(c *gin.Context) {
|
func GetGroupList(s *httpServer, c *gin.Context) {
|
||||||
nc := getParamOrDefault(c, "no_cache", "false")
|
nc := getParamOrDefault(c, "no_cache", "false")
|
||||||
c.JSON(200, s.bot.CQGetGroupList(nc == "true"))
|
c.JSON(200, s.bot.CQGetGroupList(nc == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupInfo(c *gin.Context) {
|
func GetGroupInfo(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupInfo(gid))
|
c.JSON(200, s.bot.CQGetGroupInfo(gid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupMemberList(c *gin.Context) {
|
func GetGroupMemberList(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
nc := getParamOrDefault(c, "no_cache", "false")
|
nc := getParamOrDefault(c, "no_cache", "false")
|
||||||
c.JSON(200, s.bot.CQGetGroupMemberList(gid, nc == "true"))
|
c.JSON(200, s.bot.CQGetGroupMemberList(gid, nc == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupMemberInfo(c *gin.Context) {
|
func GetGroupMemberInfo(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupMemberInfo(gid, uid))
|
c.JSON(200, s.bot.CQGetGroupMemberInfo(gid, uid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupFileSystemInfo(c *gin.Context) {
|
func GetGroupFileSystemInfo(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupFileSystemInfo(gid))
|
c.JSON(200, s.bot.CQGetGroupFileSystemInfo(gid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupRootFiles(c *gin.Context) {
|
func GetGroupRootFiles(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupRootFiles(gid))
|
c.JSON(200, s.bot.CQGetGroupRootFiles(gid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupFilesByFolderId(c *gin.Context) {
|
func GetGroupFilesByFolderId(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
folderId := getParam(c, "folder_id")
|
folderId := getParam(c, "folder_id")
|
||||||
c.JSON(200, s.bot.CQGetGroupFilesByFolderId(gid, folderId))
|
c.JSON(200, s.bot.CQGetGroupFilesByFolderId(gid, folderId))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupFileUrl(c *gin.Context) {
|
func GetGroupFileUrl(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
fid := getParam(c, "file_id")
|
fid := getParam(c, "file_id")
|
||||||
busid, _ := strconv.ParseInt(getParam(c, "busid"), 10, 32)
|
busid, _ := strconv.ParseInt(getParam(c, "busid"), 10, 32)
|
||||||
c.JSON(200, s.bot.CQGetGroupFileUrl(gid, fid, int32(busid)))
|
c.JSON(200, s.bot.CQGetGroupFileUrl(gid, fid, int32(busid)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendMessage(c *gin.Context) {
|
func SendMessage(s *httpServer, c *gin.Context) {
|
||||||
if getParam(c, "message_type") == "private" {
|
if getParam(c, "message_type") == "private" {
|
||||||
s.SendPrivateMessage(c)
|
SendPrivateMessage(s, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if getParam(c, "message_type") == "group" {
|
if getParam(c, "message_type") == "group" {
|
||||||
s.SendGroupMessage(c)
|
SendGroupMessage(s, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if getParam(c, "group_id") != "" {
|
if getParam(c, "group_id") != "" {
|
||||||
s.SendGroupMessage(c)
|
SendGroupMessage(s, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if getParam(c, "user_id") != "" {
|
if getParam(c, "user_id") != "" {
|
||||||
s.SendPrivateMessage(c)
|
SendPrivateMessage(s, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendPrivateMessage(c *gin.Context) {
|
func SendPrivateMessage(s *httpServer, c *gin.Context) {
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
msg, t := getParamWithType(c, "message")
|
msg, t := getParamWithType(c, "message")
|
||||||
autoEscape := global.EnsureBool(getParam(c, "auto_escape"), false)
|
autoEscape := global.EnsureBool(getParam(c, "auto_escape"), false)
|
||||||
@ -243,7 +244,7 @@ func (s *httpServer) SendPrivateMessage(c *gin.Context) {
|
|||||||
c.JSON(200, s.bot.CQSendPrivateMessage(uid, msg, autoEscape))
|
c.JSON(200, s.bot.CQSendPrivateMessage(uid, msg, autoEscape))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendGroupMessage(c *gin.Context) {
|
func SendGroupMessage(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
msg, t := getParamWithType(c, "message")
|
msg, t := getParamWithType(c, "message")
|
||||||
autoEscape := global.EnsureBool(getParam(c, "auto_escape"), false)
|
autoEscape := global.EnsureBool(getParam(c, "auto_escape"), false)
|
||||||
@ -254,34 +255,34 @@ func (s *httpServer) SendGroupMessage(c *gin.Context) {
|
|||||||
c.JSON(200, s.bot.CQSendGroupMessage(gid, msg, autoEscape))
|
c.JSON(200, s.bot.CQSendGroupMessage(gid, msg, autoEscape))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendGroupForwardMessage(c *gin.Context) {
|
func SendGroupForwardMessage(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
msg := getParam(c, "messages")
|
msg := getParam(c, "messages")
|
||||||
c.JSON(200, s.bot.CQSendGroupForwardMessage(gid, gjson.Parse(msg)))
|
c.JSON(200, s.bot.CQSendGroupForwardMessage(gid, gjson.Parse(msg)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetImage(c *gin.Context) {
|
func GetImage(s *httpServer, c *gin.Context) {
|
||||||
file := getParam(c, "file")
|
file := getParam(c, "file")
|
||||||
c.JSON(200, s.bot.CQGetImage(file))
|
c.JSON(200, s.bot.CQGetImage(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetMessage(c *gin.Context) {
|
func GetMessage(s *httpServer, c *gin.Context) {
|
||||||
mid, _ := strconv.ParseInt(getParam(c, "message_id"), 10, 32)
|
mid, _ := strconv.ParseInt(getParam(c, "message_id"), 10, 32)
|
||||||
c.JSON(200, s.bot.CQGetMessage(int32(mid)))
|
c.JSON(200, s.bot.CQGetMessage(int32(mid)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupHonorInfo(c *gin.Context) {
|
func GetGroupHonorInfo(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetGroupHonorInfo(gid, getParam(c, "type")))
|
c.JSON(200, s.bot.CQGetGroupHonorInfo(gid, getParam(c, "type")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) ProcessFriendRequest(c *gin.Context) {
|
func ProcessFriendRequest(s *httpServer, c *gin.Context) {
|
||||||
flag := getParam(c, "flag")
|
flag := getParam(c, "flag")
|
||||||
approve := getParamOrDefault(c, "approve", "true")
|
approve := getParamOrDefault(c, "approve", "true")
|
||||||
c.JSON(200, s.bot.CQProcessFriendRequest(flag, approve == "true"))
|
c.JSON(200, s.bot.CQProcessFriendRequest(flag, approve == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) ProcessGroupRequest(c *gin.Context) {
|
func ProcessGroupRequest(s *httpServer, c *gin.Context) {
|
||||||
flag := getParam(c, "flag")
|
flag := getParam(c, "flag")
|
||||||
subType := getParam(c, "sub_type")
|
subType := getParam(c, "sub_type")
|
||||||
if subType == "" {
|
if subType == "" {
|
||||||
@ -291,103 +292,113 @@ func (s *httpServer) ProcessGroupRequest(c *gin.Context) {
|
|||||||
c.JSON(200, s.bot.CQProcessGroupRequest(flag, subType, getParam(c, "reason"), approve == "true"))
|
c.JSON(200, s.bot.CQProcessGroupRequest(flag, subType, getParam(c, "reason"), approve == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupCard(c *gin.Context) {
|
func SetGroupCard(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupCard(gid, uid, getParam(c, "card")))
|
c.JSON(200, s.bot.CQSetGroupCard(gid, uid, getParam(c, "card")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetSpecialTitle(c *gin.Context) {
|
func SetSpecialTitle(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupSpecialTitle(gid, uid, getParam(c, "special_title")))
|
c.JSON(200, s.bot.CQSetGroupSpecialTitle(gid, uid, getParam(c, "special_title")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupKick(c *gin.Context) {
|
func SetGroupKick(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
msg := getParam(c, "message")
|
msg := getParam(c, "message")
|
||||||
c.JSON(200, s.bot.CQSetGroupKick(gid, uid, msg))
|
c.JSON(200, s.bot.CQSetGroupKick(gid, uid, msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupBan(c *gin.Context) {
|
func SetGroupBan(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
i, _ := strconv.ParseInt(getParamOrDefault(c, "duration", "1800"), 10, 64)
|
i, _ := strconv.ParseInt(getParamOrDefault(c, "duration", "1800"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupBan(gid, uid, uint32(i)))
|
c.JSON(200, s.bot.CQSetGroupBan(gid, uid, uint32(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetWholeBan(c *gin.Context) {
|
func SetWholeBan(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupWholeBan(gid, getParamOrDefault(c, "enable", "true") == "true"))
|
c.JSON(200, s.bot.CQSetGroupWholeBan(gid, getParamOrDefault(c, "enable", "true") == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupName(c *gin.Context) {
|
func SetGroupName(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "group_name")))
|
c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "group_name")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupAdmin(c *gin.Context) {
|
func SetGroupAdmin(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupAdmin(gid, uid, getParamOrDefault(c, "enable", "true") == "true"))
|
c.JSON(200, s.bot.CQSetGroupAdmin(gid, uid, getParamOrDefault(c, "enable", "true") == "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SendGroupNotice(c *gin.Context) {
|
func SendGroupNotice(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupMemo(gid, getParam(c, "content")))
|
c.JSON(200, s.bot.CQSetGroupMemo(gid, getParam(c, "content")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupLeave(c *gin.Context) {
|
func SetGroupLeave(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupLeave(gid))
|
c.JSON(200, s.bot.CQSetGroupLeave(gid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetForwardMessage(c *gin.Context) {
|
func SetRestart(s *httpServer, c *gin.Context) {
|
||||||
|
delay, _ := strconv.ParseInt(getParam(c, "delay"), 10, 64)
|
||||||
|
c.JSON(200, coolq.MSG{"data": nil, "retcode": 0, "status": "async"})
|
||||||
|
go func(delay int64) {
|
||||||
|
time.Sleep(time.Duration(delay) * time.Millisecond)
|
||||||
|
Restart <- struct{}{}
|
||||||
|
}(delay)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetForwardMessage(s *httpServer, c *gin.Context) {
|
||||||
resId := getParam(c, "message_id")
|
resId := getParam(c, "message_id")
|
||||||
c.JSON(200, s.bot.CQGetForwardMessage(resId))
|
c.JSON(200, s.bot.CQGetForwardMessage(resId))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetGroupSystemMessage(c *gin.Context) {
|
func GetGroupSystemMessage(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQGetGroupSystemMessages())
|
c.JSON(200, s.bot.CQGetGroupSystemMessages())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) DeleteMessage(c *gin.Context) {
|
func DeleteMessage(s *httpServer, c *gin.Context) {
|
||||||
mid, _ := strconv.ParseInt(getParam(c, "message_id"), 10, 32)
|
mid, _ := strconv.ParseInt(getParam(c, "message_id"), 10, 32)
|
||||||
c.JSON(200, s.bot.CQDeleteMessage(int32(mid)))
|
c.JSON(200, s.bot.CQDeleteMessage(int32(mid)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) CanSendImage(c *gin.Context) {
|
func CanSendImage(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQCanSendImage())
|
c.JSON(200, s.bot.CQCanSendImage())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) CanSendRecord(c *gin.Context) {
|
func CanSendRecord(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQCanSendRecord())
|
c.JSON(200, s.bot.CQCanSendRecord())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetStatus(c *gin.Context) {
|
func GetStatus(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQGetStatus())
|
c.JSON(200, s.bot.CQGetStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetVersionInfo(c *gin.Context) {
|
func GetVersionInfo(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQGetVersionInfo())
|
c.JSON(200, s.bot.CQGetVersionInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) ReloadEventFilter(c *gin.Context) {
|
func ReloadEventFilter(s *httpServer, c *gin.Context) {
|
||||||
c.JSON(200, s.bot.CQReloadEventFilter())
|
c.JSON(200, s.bot.CQReloadEventFilter())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetVipInfo(c *gin.Context) {
|
func GetVipInfo(s *httpServer, c *gin.Context) {
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetVipInfo(uid))
|
c.JSON(200, s.bot.CQGetVipInfo(uid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetStrangerInfo(c *gin.Context) {
|
func GetStrangerInfo(s *httpServer, c *gin.Context) {
|
||||||
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQGetStrangerInfo(uid))
|
c.JSON(200, s.bot.CQGetStrangerInfo(uid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) HandleQuickOperation(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)
|
||||||
return
|
return
|
||||||
@ -398,17 +409,17 @@ func (s *httpServer) HandleQuickOperation(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) OcrImage(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))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) GetWordSlices(c *gin.Context) {
|
func GetWordSlices(s *httpServer, c *gin.Context) {
|
||||||
content := getParam(c, "content")
|
content := getParam(c, "content")
|
||||||
c.JSON(200, s.bot.CQGetWordSlices(content))
|
c.JSON(200, s.bot.CQGetWordSlices(content))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupPortrait(c *gin.Context) {
|
func SetGroupPortrait(s *httpServer, c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
file := getParam(c, "file")
|
file := getParam(c, "file")
|
||||||
cache := getParam(c, "cache")
|
cache := getParam(c, "cache")
|
||||||
@ -464,132 +475,49 @@ func getParamWithType(c *gin.Context, k string) (string, gjson.Type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var httpApi = map[string]func(s *httpServer, c *gin.Context){
|
var httpApi = map[string]func(s *httpServer, c *gin.Context){
|
||||||
"get_login_info": func(s *httpServer, c *gin.Context) {
|
"get_login_info": GetLoginInfo,
|
||||||
s.GetLoginInfo(c)
|
"get_friend_list": GetFriendList,
|
||||||
},
|
"get_group_list": GetGroupList,
|
||||||
"get_friend_list": func(s *httpServer, c *gin.Context) {
|
"get_group_info": GetGroupInfo,
|
||||||
s.GetFriendList(c)
|
"get_group_member_list": GetGroupMemberList,
|
||||||
},
|
"get_group_member_info": GetGroupMemberInfo,
|
||||||
"get_group_list": func(s *httpServer, c *gin.Context) {
|
"get_group_file_system_info": GetGroupFileSystemInfo,
|
||||||
s.GetGroupList(c)
|
"get_group_root_files": GetGroupRootFiles,
|
||||||
},
|
"get_group_files_by_folder": GetGroupFilesByFolderId,
|
||||||
"get_group_info": func(s *httpServer, c *gin.Context) {
|
"get_group_file_url": GetGroupFileUrl,
|
||||||
s.GetGroupInfo(c)
|
"send_msg": SendMessage,
|
||||||
},
|
"send_group_msg": SendGroupMessage,
|
||||||
"get_group_member_list": func(s *httpServer, c *gin.Context) {
|
"send_group_forward_msg": SendGroupForwardMessage,
|
||||||
s.GetGroupMemberList(c)
|
"send_private_msg": SendPrivateMessage,
|
||||||
},
|
"delete_msg": DeleteMessage,
|
||||||
"get_group_member_info": func(s *httpServer, c *gin.Context) {
|
"set_friend_add_request": ProcessFriendRequest,
|
||||||
s.GetGroupMemberInfo(c)
|
"set_group_add_request": ProcessGroupRequest,
|
||||||
},
|
"set_group_card": SetGroupCard,
|
||||||
"get_group_file_system_info": func(s *httpServer, c *gin.Context) {
|
"set_group_special_title": SetSpecialTitle,
|
||||||
s.GetGroupFileSystemInfo(c)
|
"set_group_kick": SetGroupKick,
|
||||||
},
|
"set_group_ban": SetGroupBan,
|
||||||
"get_group_root_files": func(s *httpServer, c *gin.Context) {
|
"set_group_whole_ban": SetWholeBan,
|
||||||
s.GetGroupRootFiles(c)
|
"set_group_name": SetGroupName,
|
||||||
},
|
"set_group_admin": SetGroupAdmin,
|
||||||
"get_group_files_by_folder": func(s *httpServer, c *gin.Context) {
|
"set_restart": SetRestart,
|
||||||
s.GetGroupFilesByFolderId(c)
|
"_send_group_notice": SendGroupNotice,
|
||||||
},
|
"set_group_leave": SetGroupLeave,
|
||||||
"get_group_file_url": func(s *httpServer, c *gin.Context) {
|
"get_image": GetImage,
|
||||||
s.GetGroupFileUrl(c)
|
"get_forward_msg": GetForwardMessage,
|
||||||
},
|
"get_msg": GetMessage,
|
||||||
"send_msg": func(s *httpServer, c *gin.Context) {
|
"get_group_system_msg": GetGroupSystemMessage,
|
||||||
s.SendMessage(c)
|
"get_group_honor_info": GetGroupHonorInfo,
|
||||||
},
|
"can_send_image": CanSendImage,
|
||||||
"send_group_msg": func(s *httpServer, c *gin.Context) {
|
"can_send_record": CanSendRecord,
|
||||||
s.SendGroupMessage(c)
|
"get_status": GetStatus,
|
||||||
},
|
"get_version_info": GetVersionInfo,
|
||||||
"send_group_forward_msg": func(s *httpServer, c *gin.Context) {
|
"_get_vip_info": GetVipInfo,
|
||||||
s.SendGroupForwardMessage(c)
|
"get_stranger_info": GetStrangerInfo,
|
||||||
},
|
"reload_event_filter": ReloadEventFilter,
|
||||||
"send_private_msg": func(s *httpServer, c *gin.Context) {
|
"set_group_portrait": SetGroupPortrait,
|
||||||
s.SendPrivateMessage(c)
|
".handle_quick_operation": HandleQuickOperation,
|
||||||
},
|
".ocr_image": OcrImage,
|
||||||
"delete_msg": func(s *httpServer, c *gin.Context) {
|
".get_word_slices": GetWordSlices,
|
||||||
s.DeleteMessage(c)
|
|
||||||
},
|
|
||||||
"set_friend_add_request": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.ProcessFriendRequest(c)
|
|
||||||
},
|
|
||||||
"set_group_add_request": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.ProcessGroupRequest(c)
|
|
||||||
},
|
|
||||||
"set_group_card": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupCard(c)
|
|
||||||
},
|
|
||||||
"set_group_special_title": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetSpecialTitle(c)
|
|
||||||
},
|
|
||||||
"set_group_kick": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupKick(c)
|
|
||||||
},
|
|
||||||
"set_group_ban": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupBan(c)
|
|
||||||
},
|
|
||||||
"set_group_whole_ban": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetWholeBan(c)
|
|
||||||
},
|
|
||||||
"set_group_name": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupName(c)
|
|
||||||
},
|
|
||||||
"set_group_admin": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupAdmin(c)
|
|
||||||
},
|
|
||||||
"_send_group_notice": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SendGroupNotice(c)
|
|
||||||
},
|
|
||||||
"set_group_leave": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupLeave(c)
|
|
||||||
},
|
|
||||||
"get_image": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetImage(c)
|
|
||||||
},
|
|
||||||
"get_forward_msg": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetForwardMessage(c)
|
|
||||||
},
|
|
||||||
"get_msg": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetMessage(c)
|
|
||||||
},
|
|
||||||
"get_group_system_msg": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetGroupSystemMessage(c)
|
|
||||||
},
|
|
||||||
"get_group_honor_info": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetGroupHonorInfo(c)
|
|
||||||
},
|
|
||||||
"can_send_image": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.CanSendImage(c)
|
|
||||||
},
|
|
||||||
"can_send_record": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.CanSendRecord(c)
|
|
||||||
},
|
|
||||||
"get_status": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetStatus(c)
|
|
||||||
},
|
|
||||||
"get_version_info": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetVersionInfo(c)
|
|
||||||
},
|
|
||||||
"_get_vip_info": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetVipInfo(c)
|
|
||||||
},
|
|
||||||
"get_stranger_info": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetStrangerInfo(c)
|
|
||||||
},
|
|
||||||
"reload_event_filter": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.ReloadEventFilter(c)
|
|
||||||
},
|
|
||||||
"set_group_portrait": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.SetGroupPortrait(c)
|
|
||||||
},
|
|
||||||
".handle_quick_operation": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.HandleQuickOperation(c)
|
|
||||||
},
|
|
||||||
".ocr_image": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.OcrImage(c)
|
|
||||||
},
|
|
||||||
".get_word_slices": func(s *httpServer, c *gin.Context) {
|
|
||||||
s.GetWordSlices(c)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) ShutDown() {
|
func (s *httpServer) ShutDown() {
|
||||||
|
@ -480,6 +480,19 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
|||||||
"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)
|
||||||
},
|
},
|
||||||
|
"set_restart": func(c *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
|
var delay int64 = 0
|
||||||
|
delay = p.Get("delay").Int()
|
||||||
|
if delay < 0 {
|
||||||
|
delay = 0
|
||||||
|
}
|
||||||
|
defer func(delay int64) {
|
||||||
|
time.Sleep(time.Duration(delay) * time.Millisecond)
|
||||||
|
Restart <- struct{}{}
|
||||||
|
}(delay)
|
||||||
|
return coolq.MSG{"data": nil, "retcode": 0, "status": "async"}
|
||||||
|
|
||||||
|
},
|
||||||
"can_send_image": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"can_send_image": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQCanSendImage()
|
return bot.CQCanSendImage()
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user