1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

update MiraiGo.

This commit is contained in:
Mrs4s 2021-01-24 15:04:09 +08:00
parent 5aaade7835
commit 8532c4ecbe
3 changed files with 17 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import (
"crypto/md5"
"encoding/hex"
"io/ioutil"
"math"
"os"
"path"
"path/filepath"
@ -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())
@ -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 {

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=