mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-07-01 04:03:24 +00:00
Compare commits
13 Commits
v0.9.31-fi
...
v0.9.32
Author | SHA1 | Date | |
---|---|---|---|
7f831cf856 | |||
7a713c9327 | |||
28d536a3af | |||
375fdc8dca | |||
d1c6053df8 | |||
143d5ef8ab | |||
439c3422fb | |||
2c7b56a79c | |||
1549ef4a32 | |||
4ad684061b | |||
c7e6457e9e | |||
9d5842f09b | |||
b6f3c300ab |
28
coolq/api.go
28
coolq/api.go
@ -484,13 +484,19 @@ func (bot *CQBot) CQDeleteMessage(messageId int32) MSG {
|
|||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
if _, ok := msg["group"]; ok {
|
if _, ok := msg["group"]; ok {
|
||||||
bot.Client.RecallGroupMessage(msg["group"].(int64), msg["message-id"].(int32), msg["internal-id"].(int32))
|
if err := bot.Client.RecallGroupMessage(msg["group"].(int64), msg["message-id"].(int32), msg["internal-id"].(int32)); err != nil {
|
||||||
|
log.Warnf("撤回 %v 失败: %v", messageId, err)
|
||||||
|
return Failed(100)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if msg["sender"].(message.Sender).Uin != bot.Client.Uin {
|
if msg["sender"].(message.Sender).Uin != bot.Client.Uin {
|
||||||
log.Warnf("撤回 %v 失败: 好友会话无法撤回对方消息.")
|
log.Warnf("撤回 %v 失败: 好友会话无法撤回对方消息.")
|
||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
bot.Client.RecallPrivateMessage(msg["target"].(int64), int64(msg["time"].(int32)), msg["message-id"].(int32), msg["internal-id"].(int32))
|
if err := bot.Client.RecallPrivateMessage(msg["target"].(int64), int64(msg["time"].(int32)), msg["message-id"].(int32), msg["internal-id"].(int32)); err != nil {
|
||||||
|
log.Warnf("撤回 %v 失败: %v", messageId, err)
|
||||||
|
return Failed(100)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return OK(nil)
|
return OK(nil)
|
||||||
}
|
}
|
||||||
@ -718,17 +724,24 @@ func (bot *CQBot) CQGetMessage(messageId int32) MSG {
|
|||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
sender := msg["sender"].(message.Sender)
|
sender := msg["sender"].(message.Sender)
|
||||||
_, group := msg["group"]
|
gid, isGroup := msg["group"]
|
||||||
|
raw := msg["message"].(string)
|
||||||
return OK(MSG{
|
return OK(MSG{
|
||||||
"message_id": messageId,
|
"message_id": messageId,
|
||||||
"real_id": msg["message-id"],
|
"real_id": msg["message-id"],
|
||||||
"group": group,
|
"group": isGroup,
|
||||||
|
"group_id": gid,
|
||||||
"sender": MSG{
|
"sender": MSG{
|
||||||
"user_id": sender.Uin,
|
"user_id": sender.Uin,
|
||||||
"nickname": sender.Nickname,
|
"nickname": sender.Nickname,
|
||||||
},
|
},
|
||||||
"time": msg["time"],
|
"time": msg["time"],
|
||||||
"message": msg["message"],
|
"message": ToFormattedMessage(bot.ConvertStringMessage(raw, isGroup), func() int64 {
|
||||||
|
if isGroup {
|
||||||
|
return gid.(int64)
|
||||||
|
}
|
||||||
|
return sender.Uin
|
||||||
|
}(), false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,6 +794,7 @@ func (bot *CQBot) CQSetGroupPortrait(groupId int64, file, cache string) MSG {
|
|||||||
return Failed(100)
|
return Failed(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
|
||||||
func (bot *CQBot) CQGetStatus() MSG {
|
func (bot *CQBot) CQGetStatus() MSG {
|
||||||
return OK(MSG{
|
return OK(MSG{
|
||||||
"app_initialized": true,
|
"app_initialized": true,
|
||||||
@ -788,7 +802,7 @@ func (bot *CQBot) CQGetStatus() MSG {
|
|||||||
"plugins_good": nil,
|
"plugins_good": nil,
|
||||||
"app_good": true,
|
"app_good": true,
|
||||||
"online": bot.Client.Online,
|
"online": bot.Client.Online,
|
||||||
"good": true,
|
"good": bot.Client.Online,
|
||||||
"stat": bot.Client.GetStatistics(),
|
"stat": bot.Client.GetStatistics(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,30 @@ 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.GroupImageElement:
|
||||||
|
if ur {
|
||||||
|
m = MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image"},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m = MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": CQCodeEscapeText(o.Url)},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case *message.FriendImageElement:
|
||||||
|
if ur {
|
||||||
|
m = MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image"},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m = MSG{
|
||||||
|
"type": "image",
|
||||||
|
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": CQCodeEscapeText(o.Url)},
|
||||||
|
}
|
||||||
|
}
|
||||||
case *message.GroupFlashImgElement:
|
case *message.GroupFlashImgElement:
|
||||||
return []MSG{{
|
return []MSG{{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
@ -262,9 +286,17 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
|
|||||||
r += fmt.Sprintf(`[CQ:image,file=%s,url=%s]`, o.Filename, CQCodeEscapeValue(o.Url))
|
r += fmt.Sprintf(`[CQ:image,file=%s,url=%s]`, o.Filename, CQCodeEscapeValue(o.Url))
|
||||||
}
|
}
|
||||||
case *message.GroupImageElement:
|
case *message.GroupImageElement:
|
||||||
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
if ur {
|
||||||
|
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
||||||
|
} else {
|
||||||
|
r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeText(o.Url))
|
||||||
|
}
|
||||||
case *message.FriendImageElement:
|
case *message.FriendImageElement:
|
||||||
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
if ur {
|
||||||
|
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
|
||||||
|
} else {
|
||||||
|
r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeText(o.Url))
|
||||||
|
}
|
||||||
case *message.GroupFlashImgElement:
|
case *message.GroupFlashImgElement:
|
||||||
return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename)
|
return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename)
|
||||||
case *message.FriendFlashImgElement:
|
case *message.FriendFlashImgElement:
|
||||||
|
247
docs/cqhttp.md
247
docs/cqhttp.md
@ -485,26 +485,26 @@ Type: `tts`
|
|||||||
终结点: `/.ocr_image`
|
终结点: `/.ocr_image`
|
||||||
|
|
||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------- | ------ | ------ |
|
| ------- | ------ | ------ |
|
||||||
| `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 | 坐标 |
|
||||||
|
|
||||||
|
|
||||||
### 获取群系统消息
|
### 获取群系统消息
|
||||||
|
|
||||||
@ -512,56 +512,56 @@ Type: `tts`
|
|||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------------ | ---------------- | ------------ |
|
| ------------------ | ---------------- | ------------ |
|
||||||
| `invited_requests` | InvitedRequest[] | 邀请消息列表 |
|
| `invited_requests` | InvitedRequest[] | 邀请消息列表 |
|
||||||
| `join_requests` | JoinRequest[] | 进群消息列表 |
|
| `join_requests` | JoinRequest[] | 进群消息列表 |
|
||||||
|
|
||||||
> 注意: 如果列表不存在任何消息, 将返回 `null`
|
> 注意: 如果列表不存在任何消息, 将返回 `null`
|
||||||
|
|
||||||
**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 |
|
||||||
|
|
||||||
### 获取群文件系统信息
|
### 获取群文件系统信息
|
||||||
|
|
||||||
终结点: `/get_group_file_system_info`
|
终结点: `/get_group_file_system_info`
|
||||||
|
|
||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----- | ---- |
|
| ---------- | ----- | ---- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------- | ----- | ---------- |
|
| ------------- | ----- | ---------- |
|
||||||
| `file_count` | int32 | 文件总数 |
|
| `file_count` | int32 | 文件总数 |
|
||||||
| `limit_count` | int32 | 文件上限 |
|
| `limit_count` | int32 | 文件上限 |
|
||||||
| `used_space` | int64 | 已使用空间 |
|
| `used_space` | int64 | 已使用空间 |
|
||||||
| `total_space` | int64 | 空间上限 |
|
| `total_space` | int64 | 空间上限 |
|
||||||
|
|
||||||
### 获取群根目录文件列表
|
### 获取群根目录文件列表
|
||||||
|
|
||||||
@ -570,18 +570,18 @@ Type: `tts`
|
|||||||
终结点: `/get_group_root_files`
|
终结点: `/get_group_root_files`
|
||||||
|
|
||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ----- | ---- |
|
| ---------- | ----- | ---- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| --------- | -------- | ---------- |
|
| --------- | -------- | ---------- |
|
||||||
| `files` | File[] | 文件列表 |
|
| `files` | File[] | 文件列表 |
|
||||||
| `folders` | Folder[] | 文件夹列表 |
|
| `folders` | Folder[] | 文件夹列表 |
|
||||||
|
|
||||||
### 获取群子目录文件列表
|
### 获取群子目录文件列表
|
||||||
|
|
||||||
> `File` 和 `Folder` 对象信息请参考最下方
|
> `File` 和 `Folder` 对象信息请参考最下方
|
||||||
@ -589,19 +589,19 @@ Type: `tts`
|
|||||||
终结点: `/get_group_files_by_folder`
|
终结点: `/get_group_files_by_folder`
|
||||||
|
|
||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ----------- | ------ | --------------------------- |
|
| ----------- | ------ | --------------------------- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `folder_id` | string | 文件夹ID 参考 `Folder` 对象 |
|
| `folder_id` | string | 文件夹ID 参考 `Folder` 对象 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| --------- | -------- | ---------- |
|
| --------- | -------- | ---------- |
|
||||||
| `files` | File[] | 文件列表 |
|
| `files` | File[] | 文件列表 |
|
||||||
| `folders` | Folder[] | 文件夹列表 |
|
| `folders` | Folder[] | 文件夹列表 |
|
||||||
|
|
||||||
### 获取群文件资源链接
|
### 获取群文件资源链接
|
||||||
|
|
||||||
> `File` 和 `Folder` 对象信息请参考最下方
|
> `File` 和 `Folder` 对象信息请参考最下方
|
||||||
@ -609,44 +609,75 @@ Type: `tts`
|
|||||||
终结点: `/get_group_file_url`
|
终结点: `/get_group_file_url`
|
||||||
|
|
||||||
**参数**
|
**参数**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------- | ------ | ------------------------- |
|
| ---------- | ------ | ------------------------- |
|
||||||
| `group_id` | int64 | 群号 |
|
| `group_id` | int64 | 群号 |
|
||||||
| `file_id` | string | 文件ID 参考 `File` 对象 |
|
| `file_id` | string | 文件ID 参考 `File` 对象 |
|
||||||
| `busid` | int32 | 文件类型 参考 `File` 对象 |
|
| `busid` | int32 | 文件类型 参考 `File` 对象 |
|
||||||
|
|
||||||
**响应数据**
|
**响应数据**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ----- | ------ | ------------ |
|
| ----- | ------ | ------------ |
|
||||||
| `url` | string | 文件下载链接 |
|
| `url` | string | 文件下载链接 |
|
||||||
|
|
||||||
**File**
|
**File**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ---------------- | ------ | ---------------------- |
|
| ---------------- | ------ | ---------------------- |
|
||||||
| `file_id` | string | 文件ID |
|
| `file_id` | string | 文件ID |
|
||||||
| `file_name` | string | 文件名 |
|
| `file_name` | string | 文件名 |
|
||||||
| `busid` | int32 | 文件类型 |
|
| `busid` | int32 | 文件类型 |
|
||||||
| `file_size` | int64 | 文件大小 |
|
| `file_size` | int64 | 文件大小 |
|
||||||
| `upload_time` | int64 | 上传时间 |
|
| `upload_time` | int64 | 上传时间 |
|
||||||
| `dead_time` | int64 | 过期时间,永久文件恒为0 |
|
| `dead_time` | int64 | 过期时间,永久文件恒为0 |
|
||||||
| `modify_time` | int64 | 最后修改时间 |
|
| `modify_time` | int64 | 最后修改时间 |
|
||||||
| `download_times` | int32 | 下载次数 |
|
| `download_times` | int32 | 下载次数 |
|
||||||
| `uploader` | int64 | 上传者ID |
|
| `uploader` | int64 | 上传者ID |
|
||||||
| `uploader_name` | string | 上传者名字 |
|
| `uploader_name` | string | 上传者名字 |
|
||||||
|
|
||||||
**Folder**
|
**Folder**
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| ------------------ | ------ | ---------- |
|
| ------------------ | ------ | ---------- |
|
||||||
| `folder_id` | string | 文件夹ID |
|
| `folder_id` | string | 文件夹ID |
|
||||||
| `folder_name` | string | 文件名 |
|
| `folder_name` | string | 文件名 |
|
||||||
| `create_time` | int64 | 创建时间 |
|
| `create_time` | int64 | 创建时间 |
|
||||||
| `creator` | int64 | 创建者 |
|
| `creator` | int64 | 创建者 |
|
||||||
| `creator_name` | string | 创建者名字 |
|
| `creator_name` | string | 创建者名字 |
|
||||||
| `total_file_count` | int32 | 子文件数量 |
|
| `total_file_count` | int32 | 子文件数量 |
|
||||||
|
|
||||||
|
### 获取状态
|
||||||
|
|
||||||
|
终结点: `/get_status`
|
||||||
|
|
||||||
|
**响应数据**
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| --------------- | ---------- | ------------------------------- |
|
||||||
|
| app_initialized | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
|
| app_enabled | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
|
| plugins_good | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
|
| app_good | bool | 原 `CQHTTP` 字段, 恒定为 `true` |
|
||||||
|
| online | bool | 表示BOT是否在线 |
|
||||||
|
| goold | bool | 同 `online` |
|
||||||
|
| stat | Statistics | 运行统计 |
|
||||||
|
|
||||||
|
**Statistics**
|
||||||
|
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ---------------- | ------ | ---------------- |
|
||||||
|
| packet_received | uint64 | 收到的数据包总数 |
|
||||||
|
| packet_sent | uint64 | 发送的数据包总数 |
|
||||||
|
| packet_lost | uint32 | 数据包丢失总数 |
|
||||||
|
| message_received | uint64 | 接受信息总数 |
|
||||||
|
| message_sent | uint64 | 发送信息总数 |
|
||||||
|
| disconnect_times | uint32 | TCP链接断开次数 |
|
||||||
|
| lost_times | uint32 | 账号掉线次数 |
|
||||||
|
|
||||||
|
> 注意: 所有统计信息都将在重启后重制
|
||||||
|
|
||||||
## 事件
|
## 事件
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ var DefaultConfigWithComments = `
|
|||||||
enabled: false
|
enabled: false
|
||||||
// 反向WS Universal 地址
|
// 反向WS Universal 地址
|
||||||
// 注意 设置了此项地址后下面两项将会被忽略
|
// 注意 设置了此项地址后下面两项将会被忽略
|
||||||
|
// 留空请使用 ""
|
||||||
reverse_url: ws://you_websocket_universal.server
|
reverse_url: ws://you_websocket_universal.server
|
||||||
// 反向WS API 地址
|
// 反向WS API 地址
|
||||||
reverse_api_url: ws://you_websocket_api.server
|
reverse_api_url: ws://you_websocket_api.server
|
||||||
@ -152,6 +153,7 @@ type JsonConfig struct {
|
|||||||
} `json:"_rate_limit"`
|
} `json:"_rate_limit"`
|
||||||
IgnoreInvalidCQCode bool `json:"ignore_invalid_cqcode"`
|
IgnoreInvalidCQCode bool `json:"ignore_invalid_cqcode"`
|
||||||
ForceFragmented bool `json:"force_fragmented"`
|
ForceFragmented bool `json:"force_fragmented"`
|
||||||
|
ProxyRewrite string `json:"proxy_rewrite"`
|
||||||
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
|
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
|
||||||
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
||||||
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
|
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
|
||||||
|
@ -5,7 +5,9 @@ import (
|
|||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -14,8 +16,28 @@ import (
|
|||||||
|
|
||||||
var client = &http.Client{
|
var client = &http.Client{
|
||||||
Timeout: time.Second * 15,
|
Timeout: time.Second * 15,
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Proxy: func(request *http.Request) (u *url.URL, e error) {
|
||||||
|
if Proxy == "" {
|
||||||
|
return http.ProxyFromEnvironment(request)
|
||||||
|
}
|
||||||
|
return url.Parse(Proxy)
|
||||||
|
},
|
||||||
|
DialContext: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
DualStack: true,
|
||||||
|
}).DialContext,
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Proxy string
|
||||||
|
|
||||||
func GetBytes(url string) ([]byte, error) {
|
func GetBytes(url string) ([]byte, error) {
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201120153907-26b45139c16f
|
github.com/Mrs4s/MiraiGo v0.0.0-20201126173608-8b500107c54d
|
||||||
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
|
||||||
|
5
go.sum
5
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-20201120153907-26b45139c16f h1:pjxBE1VvJpookM2iUySfiqmuNyMz52oOhcvSRwWldqw=
|
github.com/Mrs4s/MiraiGo v0.0.0-20201126173608-8b500107c54d h1:+oGHcMd+OTR/zmhlaKUI9TjjWHZJaUBQi4I3+HP7faU=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20201120153907-26b45139c16f/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
|
github.com/Mrs4s/MiraiGo v0.0.0-20201126173608-8b500107c54d/go.mod h1:J1zaJWyeX7hQIPpOobqb8opxTNPbguotudPPrHJMoDM=
|
||||||
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=
|
||||||
@ -120,7 +120,6 @@ github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFd
|
|||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
||||||
github.com/tidwall/gjson v1.6.1/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0=
|
|
||||||
github.com/tidwall/gjson v1.6.3 h1:aHoiiem0dr7GHkW001T1SMTJ7X5PvyekH5WX0whWGnI=
|
github.com/tidwall/gjson v1.6.3 h1:aHoiiem0dr7GHkW001T1SMTJ7X5PvyekH5WX0whWGnI=
|
||||||
github.com/tidwall/gjson v1.6.3/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0=
|
github.com/tidwall/gjson v1.6.3/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0=
|
||||||
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
|
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
|
||||||
|
1
main.go
1
main.go
@ -319,6 +319,7 @@ func main() {
|
|||||||
if conf.WebUi.Host == "" {
|
if conf.WebUi.Host == "" {
|
||||||
conf.WebUi.Host = "127.0.0.1"
|
conf.WebUi.Host = "127.0.0.1"
|
||||||
}
|
}
|
||||||
|
global.Proxy = conf.ProxyRewrite
|
||||||
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
|
r := server.Restart
|
||||||
|
@ -77,7 +77,7 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
//开启端口监听
|
//开启端口监听
|
||||||
if s.Conf.WebUi.Enabled {
|
if s.Conf.WebUi != nil && s.Conf.WebUi.Enabled {
|
||||||
log.Infof("Admin API 服务器已启动: %v", addr)
|
log.Infof("Admin API 服务器已启动: %v", addr)
|
||||||
err := s.engine.Run(addr)
|
err := s.engine.Run(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user