Skip to content

Commit

Permalink
update MiraiGo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Jan 24, 2021
1 parent 5aaade7 commit 8532c4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions coolq/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/md5"
"encoding/hex"
"io/ioutil"
"math"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -851,7 +852,14 @@ func (bot *CQBot) CQGetGroupMessageHistory(groupId int64, seq int64) MSG {
if g := bot.Client.FindGroup(groupId); g == nil {
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
}
msg, err := bot.Client.GetGroupMessages(groupId, seq-19, seq)
if seq == 0 {
g, err := bot.Client.GetGroupInfo(groupId)
if err != nil {
return Failed(100, "GROUP_INFO_API_ERROR", err.Error())
}
seq = g.LastMsgSeq
}
msg, err := bot.Client.GetGroupMessages(groupId, int64(math.Max(float64(seq-19), 1)), seq)
if err != nil {
log.Warnf("获取群历史消息失败: %v", err)
return Failed(100, "MESSAGES_API_ERROR", err.Error())
Expand Down Expand Up @@ -1011,11 +1019,11 @@ func Failed(code int, msg ...string) MSG {

func convertGroupMemberInfo(groupId int64, m *client.GroupMemberInfo) MSG {
return MSG{
"group_id": groupId,
"user_id": m.Uin,
"nickname": m.Nickname,
"card": m.CardName,
"sex": func() string {
"group_id": groupId,
"user_id": m.Uin,
"nickname": m.Nickname,
"card": m.CardName,
"sex": func() string {
if m.Gender == 1 {
return "female"
} else if m.Gender == 0 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.15

require (
github.com/Mrs4s/MiraiGo v0.0.0-20210124063508-a401ed3ef104
github.com/Mrs4s/MiraiGo v0.0.0-20210124065645-9549a32d954a
github.com/dustin/go-humanize v1.0.0
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.6.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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/Mrs4s/MiraiGo v0.0.0-20210124063508-a401ed3ef104 h1:dIKRhxzCrt/jdWRFdJupIU3BM94IYoicgqRzjN+2Bw4=
github.com/Mrs4s/MiraiGo v0.0.0-20210124063508-a401ed3ef104/go.mod h1:9V7DdSwpEfCKQNvLZhRnFJFkelTU0tPLfwR5l6UFF1Y=
github.com/Mrs4s/MiraiGo v0.0.0-20210124065645-9549a32d954a h1:ov5QCDpZpsr+geKLVON7E63UqrpNF0oTiKuZwbKwEmo=
github.com/Mrs4s/MiraiGo v0.0.0-20210124065645-9549a32d954a/go.mod h1:9V7DdSwpEfCKQNvLZhRnFJFkelTU0tPLfwR5l6UFF1Y=
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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit 8532c4e

Please sign in to comment.