Skip to content

Commit 36bf579

Browse files
authored
feat: del group notice (#1567)
* update dep * feat: _del_group_notice * doc: get_group_notice && del_group_notice
1 parent 551a475 commit 36bf579

File tree

5 files changed

+87
-9
lines changed

5 files changed

+87
-9
lines changed

coolq/api.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,23 @@ func (bot *CQBot) CQSetGroupMemo(groupID int64, msg, img string) global.MSG {
11141114
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
11151115
}
11161116

1117+
// CQDelGroupMemo 扩展API-删除群公告
1118+
// @route(_del_group_notice)
1119+
// @rename(fid->notice_id)
1120+
func (bot *CQBot) CQDelGroupMemo(groupID int64, fid string) global.MSG {
1121+
if g := bot.Client.FindGroup(groupID); g != nil {
1122+
if g.SelfPermission() == client.Member {
1123+
return Failed(100, "PERMISSION_DENIED", "权限不足")
1124+
}
1125+
err := bot.Client.DelGroupNotice(groupID, fid)
1126+
if err != nil {
1127+
return Failed(100, "DELETE_NOTICE_ERROR", err.Error())
1128+
}
1129+
return OK(nil)
1130+
}
1131+
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
1132+
}
1133+
11171134
// CQSetGroupKick 群组踢人
11181135
//
11191136
// https://git.io/Jtz1V

docs/cqhttp.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
- [设置群名](#设置群名)
4343
- [获取用户VIP信息](#获取用户vip信息)
4444
- [发送群公告](#发送群公告)
45+
- [获取群公告](#获取群公告)
46+
- [删除群公告](#删除群公告)
4547
- [设置精华消息](#设置精华消息)
4648
- [移出精华消息](#移出精华消息)
4749
- [获取精华消息列表](#获取精华消息列表)
@@ -244,7 +246,8 @@ Type: `node`
244246
| `seq` | message | 具体消息 | 用于自定义消息 |
245247

246248
特殊说明: **需要使用单独的API `/send_group_forward_msg` 发送,并且由于消息段较为复杂,仅支持Array形式入参。 如果引用消息和自定义消息同时出现,实际查看顺序将取消息段顺序.
247-
另外按 [Onebot v11](https://github.com/botuniverse/onebot-11/blob/master/message/array.md) 文档说明, `data` 应全为字符串, 但由于需要接收`message` 类型的消息, 所以 *仅限此Type的content字段* 支持Array套娃**
249+
另外按 [Onebot v11](https://github.com/botuniverse/onebot-11/blob/master/message/array.md) 文档说明, `data` 应全为字符串,
250+
但由于需要接收`message` 类型的消息, 所以 *仅限此Type的content字段* 支持Array套娃**
248251

249252
示例:
250253

@@ -627,7 +630,7 @@ Type: `rps`
627630

628631
### 发送合并转发(群/私聊)
629632

630-
终结点: `/send_group_forward_msg`, `send_private_forward_msg`, `send_forward_msg`
633+
终结点: `/send_group_forward_msg`, `send_private_forward_msg`, `send_forward_msg`
631634

632635
**参数**
633636

@@ -1108,13 +1111,67 @@ JSON数组:
11081111

11091112
`该 API 没有响应数据`
11101113

1114+
### 获取群公告
1115+
1116+
终结点: `/_get_group_notice`
1117+
1118+
**参数**
1119+
1120+
| 字段名 | 数据类型 | 默认值 | 说明 |
1121+
| ---------- | -------- | ------ | -------- |
1122+
| `group_id` | int64 | | 群号 |
1123+
1124+
**响应数据**
1125+
1126+
数组信息:
1127+
1128+
| 字段名 | 数据类型 | 默认值 | 说明 |
1129+
|----------------|--------| ------ |-------|
1130+
| `notice_id` | string | | 公告id |
1131+
| `sender_id` | string | | 发布者id |
1132+
| `publish_time` | string | | 发布时间 |
1133+
| `message` | GroupNoticeMessage | | 公告id |
1134+
1135+
响应示例
1136+
1137+
```json
1138+
{
1139+
"data": [
1140+
{
1141+
"notice_id": "8850de2e00000000cc6bbd628a150c00",
1142+
"sender_id": 1111111,
1143+
"publish_time": 1656581068,
1144+
"message": {
1145+
"text": "这是一条公告",
1146+
"images": []
1147+
}
1148+
}
1149+
],
1150+
"retcode": 0,
1151+
"status": "ok"
1152+
}
1153+
```
1154+
1155+
### 删除群公告
1156+
1157+
终结点: `/_del_group_notice`
1158+
1159+
**参数**
1160+
1161+
| 字段名 | 数据类型 | 默认值 | 说明 |
1162+
|-------------| -------- | ------ |------|
1163+
| `group_id` | int64 | | 群号 |
1164+
| `notice_id` | string | | 公告id |
1165+
1166+
`该 API 没有响应数据`
1167+
11111168
### 获取单向好友列表
11121169

11131170
终结点: `/get_unidirectional_friend_list`
11141171

11151172
**响应数据**
11161173

1117-
数组信息:
1174+
数组信息:
11181175

11191176
| 字段 | 类型 | 说明 |
11201177
| ------------- | ------ | -------- |

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/Microsoft/go-winio v0.5.1
7-
github.com/Mrs4s/MiraiGo v0.0.0-20220622015746-24ee0103e7de
7+
github.com/Mrs4s/MiraiGo v0.0.0-20220630160133-a39b3fdd962f
88
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c
99
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc
1010
github.com/fumiama/go-base16384 v1.5.2
@@ -26,7 +26,7 @@ require (
2626
)
2727

2828
require (
29-
github.com/RomiChan/protobuf v0.1.1-0.20220602121309-9e3b8cbefd7a // indirect
29+
github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0 // indirect
3030
github.com/davecgh/go-spew v1.1.1 // indirect
3131
github.com/fumiama/imgsz v0.0.2 // indirect
3232
github.com/go-stack/stack v1.8.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
22
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
3-
github.com/Mrs4s/MiraiGo v0.0.0-20220622015746-24ee0103e7de h1:senbiV71dgsYt60BWLEHWwvKFCYUcIzGQ/fmXRaOeQ4=
4-
github.com/Mrs4s/MiraiGo v0.0.0-20220622015746-24ee0103e7de/go.mod h1:mZp8Lt7uqLCUwSLouB2yuiP467Cwl4mnG9IMAaXUKA0=
5-
github.com/RomiChan/protobuf v0.1.1-0.20220602121309-9e3b8cbefd7a h1:WIfEWYj82oEuPtm5pqlyQmCJCoiw00C6ugZFqHA0cC8=
6-
github.com/RomiChan/protobuf v0.1.1-0.20220602121309-9e3b8cbefd7a/go.mod h1:2Ie+hdBFQpQFDHfeklgxoFmQRCE7O+KwFpISeXq7OwA=
3+
github.com/Mrs4s/MiraiGo v0.0.0-20220630160133-a39b3fdd962f h1:PHOwN3/cEL/zoBpcJJXwx1mJ1NL901zrt2mvlQUO5BA=
4+
github.com/Mrs4s/MiraiGo v0.0.0-20220630160133-a39b3fdd962f/go.mod h1:Ow7nlaVS5FztyjrTlTRSG7HLpTNmgINMluHRCgKunDI=
5+
github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0 h1:+UGPBYVjssFsdahLJIiNPwpmmwgl/OaVdv1oc5NonC0=
6+
github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0/go.mod h1:2Ie+hdBFQpQFDHfeklgxoFmQRCE7O+KwFpISeXq7OwA=
77
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
88
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
99
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=

modules/api/api.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)