1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-06-30 11:53:25 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
3bb844d1d4 support group quit. 2020-07-31 12:45:52 +08:00
0fdb01e82c cqcode share supported. 2020-07-31 01:30:45 +08:00
7cf199189a doc update. 2020-07-30 22:11:52 +08:00
8 changed files with 30 additions and 3 deletions

View File

@ -46,6 +46,7 @@
| /set_group_kick | [群组T人](https://cqhttp.cc/docs/4.15/#/API?id=set_group_kick-群组踢人) |
| /set_group_ban | [群组单人禁言](https://cqhttp.cc/docs/4.15/#/API?id=set_group_ban-群组单人禁言) |
| /set_group_whole_ban | [群组全员禁言](https://cqhttp.cc/docs/4.15/#/API?id=set_group_whole_ban-群组全员禁言) |
| /set_group_leave | [退出群组](https://cqhttp.cc/docs/4.15/#/API?id=set_group_leave-退出群组) |
| /set_group_name | 设置群组名(拓展API) |
| /get_image | 获取图片信息(拓展API) |
| /get_group_msg | 获取群组消息(拓展API) |

View File

@ -273,6 +273,15 @@ func (bot *CQBot) CQSetGroupWholeBan(groupId int64, enable bool) MSG {
return Failed(100)
}
// https://cqhttp.cc/docs/4.15/#/API?id=set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84
func (bot *CQBot) CQSetGroupLeave(groupId int64) MSG {
if g := bot.Client.FindGroup(groupId); g != nil {
g.Quit()
return OK(nil)
}
return Failed(100)
}
// https://cqhttp.cc/docs/4.15/#/API?id=set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG {
req, ok := bot.friendReqCache.Load(flag)

View File

@ -213,6 +213,8 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
}
t, _ := strconv.ParseInt(qq, 10, 64)
return message.NewAt(t), nil
case "share":
return message.NewUrlShare(d["url"], d["title"], d["content"], d["image"]), nil
default:
return nil, errors.New("unsupported cq code: " + t)
}

View File

@ -199,7 +199,7 @@ Type: `node`
{
"content": "合并转发1",
"sender": {
"nick": "发送者A",
"nickname": "发送者A",
"user_id": 10086
},
"time": 1595694374
@ -207,7 +207,7 @@ Type: `node`
{
"content": "合并转发2[CQ:image,file=xxxx,url=xxxx]",
"sender": {
"nick": "发送者B",
"nickname": "发送者B",
"user_id": 10087
},
"time": 1595694393

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20200730113850-298c1bb9119f
github.com/Mrs4s/MiraiGo v0.0.0-20200731043935-dbb4073480bb
github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.1

4
go.sum
View File

@ -2,6 +2,10 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20200730113850-298c1bb9119f h1:+MW9qbGu9uWJc9vs6m8+8oQLh9nK6RCW2wk3BX7Z14c=
github.com/Mrs4s/MiraiGo v0.0.0-20200730113850-298c1bb9119f/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/Mrs4s/MiraiGo v0.0.0-20200730171208-f076f2a45730 h1:ZQoh1RyCacWyyJV9+MO9S+kJ5HOQOaA9PLBEGBbL3oA=
github.com/Mrs4s/MiraiGo v0.0.0-20200730171208-f076f2a45730/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/Mrs4s/MiraiGo v0.0.0-20200731043935-dbb4073480bb h1:L40i56EyeItfy5SN/TRtZL/aLtMDoFIjTTefJBhgU6E=
github.com/Mrs4s/MiraiGo v0.0.0-20200731043935-dbb4073480bb/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

View File

@ -127,6 +127,9 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
s.engine.Any("/set_group_name", s.SetGroupName)
s.engine.Any("/set_group_name_async", s.SetGroupName)
s.engine.Any("/set_group_leave", s.SetGroupLeave)
s.engine.Any("/set_group_leave_async", s.SetGroupLeave)
s.engine.Any("/get_image", s.GetImage)
s.engine.Any("/get_image_async", s.GetImage)
@ -317,6 +320,11 @@ func (s *httpServer) SetGroupName(c *gin.Context) {
c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "name")))
}
func (s *httpServer) SetGroupLeave(c *gin.Context) {
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
c.JSON(200, s.bot.CQSetGroupLeave(gid))
}
func (s *httpServer) GetForwardMessage(c *gin.Context) {
resId := getParam(c, "message_id")
c.JSON(200, s.bot.CQGetForwardMessage(resId))

View File

@ -393,6 +393,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"set_group_name": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQSetGroupName(p.Get("group_id").Int(), p.Get("name").Str)
},
"set_group_leave": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQSetGroupLeave(p.Get("group_id").Int())
},
"get_image": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQGetImage(p.Get("file").Str)
},