diff --git a/README.md b/README.md index fc22992..dba5ac1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ - [x] HTTP API - [x] 反向HTTP POST - [x] 正向Websocket -- [x] 反向Websocket (测试中) +- [x] 反向Websocket #### 拓展支持 - [x] HTTP POST多点上报 @@ -18,7 +18,7 @@ - [x] 修改群名 - [x] 消息撤回事件 - [x] 解析/发送 回复消息 -- [x] 解析合并转发 +- [x] 解析 合并转发 #### 实现
diff --git a/coolq/bot.go b/coolq/bot.go index 1ab468b..70802fc 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -75,7 +75,7 @@ func (bot *CQBot) GetGroupMessage(mid int32) MSG { return err } buff := new(bytes.Buffer) - buff.Write(e.Value) + buff.Write(binary.GZipUncompress(e.Value)) return gob.NewDecoder(buff).Decode(&m) }) if err == nil { @@ -140,7 +140,7 @@ func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32 { if err := gob.NewEncoder(buf).Encode(val); err != nil { return err } - return tx.Put("group-messages", binary.ToBytes(id), buf.Bytes(), 0) + return tx.Put("group-messages", binary.ToBytes(id), binary.GZipCompress(buf.Bytes()), 0) }) if err != nil { log.Warnf("记录聊天数据时出现错误: %v", err) diff --git a/server/http.go b/server/http.go index aa39563..fa6f883 100644 --- a/server/http.go +++ b/server/http.go @@ -286,7 +286,7 @@ func (s *httpServer) SetGroupKick(c *gin.Context) { func (s *httpServer) SetGroupBan(c *gin.Context) { gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64) uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64) - i, _ := strconv.ParseInt(getParam(c, "duration"), 10, 64) + i, _ := strconv.ParseInt(getParamOrDefault(c, "duration", "1800"), 10, 64) c.JSON(200, s.bot.CQSetGroupBan(gid, uid, uint32(i))) } diff --git a/server/websocket.go b/server/websocket.go index 45be051..f893bca 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -364,7 +364,12 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{ return bot.CQSetGroupKick(p.Get("group_id").Int(), p.Get("user_id").Int(), p.Get("message").Str) }, "set_group_ban": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { - return bot.CQSetGroupBan(p.Get("group_id").Int(), p.Get("user_id").Int(), uint32(p.Get("duration").Int())) + return bot.CQSetGroupBan(p.Get("group_id").Int(), p.Get("user_id").Int(), func() uint32 { + if p.Get("duration").Exists() { + return uint32(p.Get("duration").Int()) + } + return 1800 + }()) }, "set_group_whole_ban": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { return bot.CQSetGroupWholeBan(p.Get("group_id").Int(), func() bool {