mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-07-04 13:23:25 +00:00
Compare commits
3 Commits
d89d21d0b6
...
192b8c8692
Author | SHA1 | Date | |
---|---|---|---|
192b8c8692 | |||
ab371c1878 | |||
494692aa6f |
@ -11,13 +11,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/auth"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/packets/wtlogin/qrcodestate"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||
"github.com/mattn/go-colorable"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -13,26 +13,26 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/auth"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
para "github.com/fumiama/go-hide-param"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
"golang.org/x/term"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/auth"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/action"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
|
||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/cache"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/selfdiagnosis"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/selfupdate"
|
||||
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
||||
"github.com/Mrs4s/go-cqhttp/server"
|
||||
para "github.com/fumiama/go-hide-param"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// InitBase 解析参数并检测
|
||||
@ -325,11 +325,13 @@ func LoginInteract() {
|
||||
global.Check(cli.RefreshAllGroupsInfo(), true)
|
||||
GroupListLen := len(cli.GetCachedAllGroupsInfo())
|
||||
log.Infof("共加载 %v 个群.", GroupListLen)
|
||||
// TODO 设置在线状态 暂不支持?
|
||||
// if uint(base.Account.Status) >= uint(len(allowStatus)) {
|
||||
// base.Account.Status = 0
|
||||
//}
|
||||
//cli.SetOnlineStatus(allowStatus[base.Account.Status])
|
||||
if uint(base.Account.Status) >= 3000 {
|
||||
base.Account.Status = 10
|
||||
}
|
||||
_ = cli.SetOnlineStatus(utils.Ternary(base.Account.Status >= 1000, action.SetStatus{
|
||||
Status: 10,
|
||||
ExtStatus: uint32(base.Account.Status),
|
||||
}, action.SetStatus{Status: uint32(base.Account.Status)}))
|
||||
servers.Run(coolq.NewQQBot(cli))
|
||||
log.Info("资源初始化完成, 开始处理信息.")
|
||||
log.Info("アトリは、高性能ですから!")
|
||||
@ -342,8 +344,7 @@ func LoginInteract() {
|
||||
func WaitSignal() {
|
||||
go func() {
|
||||
selfupdate.CheckUpdate()
|
||||
// TODO 服务器连接质量测试
|
||||
// selfdiagnosis.NetworkDiagnosis(cli)
|
||||
selfdiagnosis.NetworkDiagnosis(cli)
|
||||
}()
|
||||
|
||||
<-global.SetupMainSignalHandler()
|
||||
|
23
coolq/api.go
23
coolq/api.go
@ -8,35 +8,30 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/sign"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/msg"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/entity"
|
||||
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/entity"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/sign"
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/cache"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/msg"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/param"
|
||||
"github.com/Mrs4s/go-cqhttp/modules/filter"
|
||||
"github.com/Mrs4s/go-cqhttp/pkg/onebot"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
// CQGetLoginInfo 获取登录号信息
|
||||
@ -1519,7 +1514,7 @@ func (bot *CQBot) CQGetEssenceMessageList(groupID int64) global.MSG {
|
||||
"operator_id": m.OperatorUin,
|
||||
}
|
||||
if operator := bot.Client.GetCachedMemberInfo(m.OperatorUin, uint32(groupID)); operator != nil {
|
||||
msg["operator_nick"] = operator.MemberName
|
||||
msg["operator_nick"] = operator.DisplayName()
|
||||
}
|
||||
msg["message_id"] = db.ToGlobalID(groupID, int32(m.Message.ID))
|
||||
list = append(list, msg)
|
||||
|
@ -3,10 +3,9 @@ package coolq
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
// CQGetVersion 获取版本信息 OneBotV12
|
||||
|
29
coolq/bot.go
29
coolq/bot.go
@ -12,28 +12,23 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/sign"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/mime"
|
||||
"golang.org/x/image/webp"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/entity"
|
||||
event2 "github.com/LagrangeDev/LagrangeGo/client/event"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/sign"
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/mime"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/msg"
|
||||
"github.com/Mrs4s/go-cqhttp/pkg/onebot"
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/image/webp"
|
||||
)
|
||||
|
||||
// CQBot CQBot结构体,存储Bot实例相关配置
|
||||
@ -294,11 +289,7 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) (in
|
||||
member := bot.Client.GetCachedMemberInfo(i.TargetUin, uint32(groupID))
|
||||
if member != nil {
|
||||
i.TargetUID = member.UID
|
||||
if member.MemberCard != "" {
|
||||
i.Display = "@" + member.MemberCard
|
||||
} else {
|
||||
i.Display = "@" + member.MemberName
|
||||
}
|
||||
i.Display = "@" + member.DisplayName()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,17 +5,18 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client/entity"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func convertGroupMemberInfo(groupID int64, m *entity.GroupMember) global.MSG {
|
||||
// TODO nt 协议依然是获取不到
|
||||
sex := "unknown"
|
||||
//if m.Gender == 1 { // unknown = 0xff
|
||||
// sex = "female"
|
||||
//} else if m.Gender == 0 {
|
||||
// sex = "male"
|
||||
//}
|
||||
role := "member"
|
||||
switch m.Permission { // nolint:exhaustive
|
||||
case entity.Owner:
|
||||
@ -28,7 +29,7 @@ func convertGroupMemberInfo(groupID int64, m *entity.GroupMember) global.MSG {
|
||||
return global.MSG{
|
||||
"group_id": groupID,
|
||||
"user_id": m.Uin,
|
||||
"nickname": m.MemberName,
|
||||
"nickname": m.Nickname,
|
||||
"card": m.MemberCard,
|
||||
"sex": sex,
|
||||
"age": 0,
|
||||
|
@ -15,16 +15,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
b14 "github.com/fumiama/go-base16384"
|
||||
"github.com/segmentio/asm/base64"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
@ -34,6 +28,10 @@ import (
|
||||
"github.com/Mrs4s/go-cqhttp/internal/msg"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/param"
|
||||
"github.com/Mrs4s/go-cqhttp/pkg/onebot"
|
||||
b14 "github.com/fumiama/go-base16384"
|
||||
"github.com/segmentio/asm/base64"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
// TODO: move this file to internal/msg, internal/onebot
|
||||
|
@ -8,19 +8,17 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
"github.com/LagrangeDev/LagrangeGo/client/entity"
|
||||
event2 "github.com/LagrangeDev/LagrangeGo/client/event"
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/cache"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式
|
||||
@ -179,8 +177,8 @@ func (bot *CQBot) tempMessageEvent(_ *client.QQClient, e *message.TempMessage) {
|
||||
func (bot *CQBot) groupMutedEvent(c *client.QQClient, e *event2.GroupMute) {
|
||||
g := c.GetCachedGroupInfo(e.GroupUin)
|
||||
operator := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID, e.GroupUin), e.GroupUin)
|
||||
target := c.GetCachedMemberInfo(c.GetUin(e.TargetUID, e.GroupUin), e.GroupUin)
|
||||
if e.TargetUID == "" {
|
||||
target := c.GetCachedMemberInfo(c.GetUin(e.UserUID, e.GroupUin), e.GroupUin)
|
||||
if e.UserUID == "" {
|
||||
if e.Duration != 0 {
|
||||
log.Infof("群 %v 被 %v 开启全员禁言.",
|
||||
formatGroupName(g), formatMemberName(operator))
|
||||
@ -219,7 +217,7 @@ func (bot *CQBot) groupRecallEvent(c *client.QQClient, e *event2.GroupRecall) {
|
||||
g := c.GetCachedGroupInfo(e.GroupUin)
|
||||
gid := db.ToGlobalID(int64(e.GroupUin), int32(e.Sequence))
|
||||
operator := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID, e.GroupUin), e.GroupUin)
|
||||
Author := c.GetCachedMemberInfo(c.GetUin(e.AuthorUID, e.GroupUin), e.GroupUin)
|
||||
Author := c.GetCachedMemberInfo(c.GetUin(e.UserUID, e.GroupUin), e.GroupUin)
|
||||
log.Infof("群 %v 内 %v 撤回了 %v 的消息: %v.",
|
||||
formatGroupName(g), formatMemberName(operator), formatMemberName(Author), gid)
|
||||
|
||||
@ -239,13 +237,13 @@ func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e event2.INotifyEvent) {
|
||||
//nolint:gocritic
|
||||
switch notify := e.(type) {
|
||||
case *event2.GroupPokeEvent:
|
||||
sender := c.GetCachedMemberInfo(notify.Sender, e.From())
|
||||
sender := c.GetCachedMemberInfo(notify.UserUin, e.From())
|
||||
receiver := c.GetCachedMemberInfo(notify.Receiver, e.From())
|
||||
log.Infof("群 %v 内 %v 戳了戳 %v", formatGroupName(group), formatMemberName(sender), formatMemberName(receiver))
|
||||
bot.dispatchEvent("notice/notify/poke", global.MSG{
|
||||
"group_id": group.GroupUin,
|
||||
"user_id": notify.Sender,
|
||||
"sender_id": notify.Sender,
|
||||
"user_id": notify.UserUin,
|
||||
"sender_id": notify.UserUin,
|
||||
"target_id": notify.Receiver,
|
||||
})
|
||||
//case *client.GroupRedBagLuckyKingNotifyEvent:
|
||||
@ -301,25 +299,25 @@ func (bot *CQBot) friendNotifyEvent(c *client.QQClient, e event2.INotifyEvent) {
|
||||
|
||||
func (bot *CQBot) memberTitleUpdatedEvent(c *client.QQClient, e *event2.MemberSpecialTitleUpdated) {
|
||||
group := c.GetCachedGroupInfo(e.GroupUin)
|
||||
mem := c.GetCachedMemberInfo(e.Uin, e.GroupUin)
|
||||
mem := c.GetCachedMemberInfo(e.UserUin, e.GroupUin)
|
||||
log.Infof("群 %v(%v) 内成员 %v(%v) 获得了新的头衔: %v", group.GroupName, group.GroupUin, mem.MemberCard, mem.Uin, e.NewTitle)
|
||||
bot.dispatchEvent("notice/notify/title", global.MSG{
|
||||
"group_id": group.GroupUin,
|
||||
"user_id": e.Uin,
|
||||
"user_id": e.UserUin,
|
||||
"title": e.NewTitle,
|
||||
})
|
||||
}
|
||||
|
||||
func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *event2.FriendRecall) {
|
||||
f := c.GetCachedFriendInfo(c.GetUin(e.FromUID))
|
||||
gid := db.ToGlobalID(int64(f.Uin), int32(e.Sequence))
|
||||
//if f != nil {
|
||||
gid := db.ToGlobalID(int64(e.FromUin), int32(e.Sequence))
|
||||
if f != nil {
|
||||
log.Infof("好友 %v(%v) 撤回了消息: %v", f.Nickname, f.Uin, gid)
|
||||
//} else {
|
||||
// log.Infof("好友 %v 撤回了消息: %v", e.FriendUin, gid)
|
||||
//}
|
||||
} else {
|
||||
log.Infof("好友 %v 撤回了消息: %v", e.FromUin, gid)
|
||||
}
|
||||
ev := bot.event("notice/friend_recall", global.MSG{
|
||||
"user_id": f.Uin,
|
||||
"user_id": e.FromUin,
|
||||
"message_id": gid,
|
||||
})
|
||||
ev.Time = int64(e.Time)
|
||||
@ -365,7 +363,7 @@ func (bot *CQBot) memberPermissionChangedEvent(_ *client.QQClient, e *event2.Gro
|
||||
}
|
||||
bot.dispatchEvent("notice/group_admin/"+st, global.MSG{
|
||||
"group_id": e.GroupUin,
|
||||
"user_id": e.TargetUin,
|
||||
"user_id": e.UserUin,
|
||||
})
|
||||
}
|
||||
|
||||
@ -381,12 +379,12 @@ func (bot *CQBot) memberPermissionChangedEvent(_ *client.QQClient, e *event2.Gro
|
||||
//}
|
||||
|
||||
func (bot *CQBot) memberJoinEvent(c *client.QQClient, e *event2.GroupMemberIncrease) {
|
||||
log.Infof("新成员 %v 进入了群 %v.", formatMemberName(c.GetCachedMemberInfo(e.MemberUin, e.GroupUin)), formatGroupName(c.GetCachedGroupInfo(e.GroupUin)))
|
||||
bot.dispatch(bot.groupIncrease(int64(e.GroupUin), 0, int64(e.MemberUin)))
|
||||
log.Infof("新成员 %v 进入了群 %v.", formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)), formatGroupName(c.GetCachedGroupInfo(e.GroupUin)))
|
||||
bot.dispatch(bot.groupIncrease(int64(e.GroupUin), 0, int64(e.UserUin)))
|
||||
}
|
||||
|
||||
func (bot *CQBot) memberLeaveEvent(c *client.QQClient, e *event2.GroupMemberDecrease) {
|
||||
member := c.GetCachedMemberInfo(c.GetUin(e.MemberUID), e.GroupUin)
|
||||
member := c.GetCachedMemberInfo(c.GetUin(e.UserUID), e.GroupUin)
|
||||
op := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID), e.GroupUin)
|
||||
group := c.GetCachedGroupInfo(e.GroupUin)
|
||||
if e.IsKicked() {
|
||||
@ -431,11 +429,11 @@ func (bot *CQBot) groupInvitedEvent(_ *client.QQClient, e *event2.GroupInvite) {
|
||||
|
||||
func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *event2.GroupMemberJoinRequest) {
|
||||
group := c.GetCachedGroupInfo(e.GroupUin)
|
||||
log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", group.GroupName, e.GroupUin, e.TargetNick, e.TargetUin)
|
||||
log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", group.GroupName, e.GroupUin, e.TargetNick, e.UserUin)
|
||||
flag := strconv.FormatInt(int64(e.RequestSeq), 10)
|
||||
bot.dispatchEvent("request/group/add", global.MSG{
|
||||
"group_id": e.GroupUin,
|
||||
"user_id": e.TargetUin,
|
||||
"user_id": e.UserUin,
|
||||
"invitor_id": e.InvitorUin,
|
||||
"comment": e.Answer,
|
||||
"flag": flag,
|
||||
@ -458,7 +456,6 @@ func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *event2.GroupMemberJoi
|
||||
// })
|
||||
//}
|
||||
|
||||
// TODO 精华消息
|
||||
func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent) {
|
||||
g := c.GetCachedGroupInfo(e.GroupUin)
|
||||
gid := db.ToGlobalID(int64(e.GroupUin), int32(e.MessageID))
|
||||
@ -467,7 +464,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent
|
||||
"群 %v 内 %v 将 %v 的消息(%v)设为了精华消息.",
|
||||
formatGroupName(g),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.OperatorUin, e.GroupUin)),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.SenderUin, e.GroupUin)),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)),
|
||||
gid,
|
||||
)
|
||||
} else {
|
||||
@ -475,7 +472,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent
|
||||
"群 %v 内 %v 将 %v 的消息(%v)移出了精华消息.",
|
||||
formatGroupName(g),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.OperatorUin, e.GroupUin)),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.SenderUin, e.GroupUin)),
|
||||
formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)),
|
||||
gid,
|
||||
)
|
||||
}
|
||||
@ -488,7 +485,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent
|
||||
}
|
||||
bot.dispatchEvent("notice/essence/"+subtype, global.MSG{
|
||||
"group_id": e.GroupUin,
|
||||
"sender_id": e.SenderUin,
|
||||
"sender_id": e.UserUin,
|
||||
"operator_id": e.OperatorUin,
|
||||
"message_id": gid,
|
||||
})
|
||||
|
@ -3,16 +3,13 @@ package leveldb
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
)
|
||||
|
||||
type database struct {
|
||||
|
@ -6,9 +6,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type intReader struct {
|
||||
|
@ -3,13 +3,12 @@ package mongodb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/pkg/errors"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
)
|
||||
|
||||
type database struct {
|
||||
|
@ -1,10 +1,9 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
)
|
||||
|
||||
// backends 多数据库支持, 后端支持
|
||||
|
@ -8,16 +8,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils"
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/db"
|
||||
)
|
||||
|
||||
type database struct {
|
||||
|
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.20
|
||||
|
||||
require (
|
||||
github.com/FloatTech/sqlite v1.6.3
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241128062531-bea32754985f
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba
|
||||
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a
|
||||
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
|
||||
|
7
go.sum
7
go.sum
@ -2,8 +2,10 @@ github.com/FloatTech/sqlite v1.6.3 h1:MQkqBNlkPuCoKQQgoNLuTL/2Ci3tBTFAnVYBdD0Wy4
|
||||
github.com/FloatTech/sqlite v1.6.3/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
|
||||
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1 h1:g4pTnDJUW4VbJ9NvoRfUvdjDrHz/6QhfN/LoIIpICbo=
|
||||
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241128062531-bea32754985f h1:arXQxi9PrzbK3d2dw9xvRFkn9jMqqd0dwziwO24dMhg=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241128062531-bea32754985f/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129090211-e0fdf8ca5390 h1:NIDdk9Z5ztBhWcLJc8WvXxRSgdSqZlikrFBU5pII78Q=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129090211-e0fdf8ca5390/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba h1:x3ccoK+TJhIcZjO+Ybsv1YwCbowNq9ZHvjOtlKBuCFU=
|
||||
github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA=
|
||||
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a h1:aU1703IHxupjzipvhu16qYKLMR03e+8WuNR+JMsKfGU=
|
||||
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a/go.mod h1:OZqLNXdYJHmx7aqq/T6wAdFEdoGm5nmIfC4kU7M8P8o=
|
||||
github.com/RomiChan/protobuf v0.1.1-0.20230204044148-2ed269a2e54d h1:/Xuj3fIiMY2ls1TwvPKmaqQrtJsPY+c9s+0lOScVHd8=
|
||||
@ -162,6 +164,7 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJ
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.ilharper.com/x/isatty v1.1.1 h1:RAg32Pxq/nIK4AVtdm9RBqxsxZZX1uRKRSS21E5SHMk=
|
||||
gopkg.ilharper.com/x/isatty v1.1.1/go.mod h1:ofpv77Td5qQO6R1dmDd3oNt8TZdRo+l5gYAMxopRyS0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
@ -2,10 +2,10 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/utils/binary"
|
||||
)
|
||||
|
||||
// @@@ CQ码转义处理 @@@
|
||||
|
@ -1,8 +1,9 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
"io"
|
||||
|
||||
"github.com/LagrangeDev/LagrangeGo/message"
|
||||
)
|
||||
|
||||
// Poke 拍一拍
|
||||
|
@ -1,15 +1,19 @@
|
||||
// Package selfdiagnosis 自我诊断相关
|
||||
package selfdiagnosis
|
||||
|
||||
/*
|
||||
import (
|
||||
"github.com/LagrangeDev/LagrangeGo/client"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// NetworkDiagnosis 诊断网络状态并输出结果
|
||||
func NetworkDiagnosis(c *client.QQClient) {
|
||||
log.Infof("开始诊断网络情况")
|
||||
qualityInfo := c.ConnectionQualityTest()
|
||||
log.Debugf("聊天服务器连接延迟: %vms", qualityInfo.ChatServerLatency)
|
||||
log.Debugf("聊天服务器丢包率: %v%%", qualityInfo.ChatServerPacketLoss*10)
|
||||
log.Debugf("长消息服务器连接延迟: %vms", qualityInfo.LongMessageServerLatency)
|
||||
log.Debugf("长消息服务器响应延迟: %vms", qualityInfo.LongMessageServerResponseLatency)
|
||||
//log.Debugf("长消息服务器连接延迟: %vms", qualityInfo.LongMessageServerLatency)
|
||||
//log.Debugf("长消息服务器响应延迟: %vms", qualityInfo.LongMessageServerResponseLatency)
|
||||
log.Debugf("媒体服务器连接延迟: %vms", qualityInfo.SrvServerLatency)
|
||||
log.Debugf("媒体服务器丢包率: %v%%", qualityInfo.SrvServerPacketLoss*10)
|
||||
|
||||
@ -31,21 +35,21 @@ func NetworkDiagnosis(c *client.QQClient) {
|
||||
log.Warnf("警告: 本地连接聊天服务器丢包率为 %v%%, %v", qualityInfo.ChatServerPacketLoss*10, chatServerErrorMessage)
|
||||
}
|
||||
|
||||
if qualityInfo.LongMessageServerLatency > 1000 {
|
||||
if qualityInfo.LongMessageServerLatency == 9999 {
|
||||
log.Errorf("错误: 长消息服务器延迟测试失败, %v 如果您使用的腾讯云服务器, 请修改DNS到114.114.114.114", longMessageServerErrorMessage)
|
||||
} else {
|
||||
log.Warnf("警告: 长消息延迟为 %vms, 大于 1000ms, %v", qualityInfo.LongMessageServerLatency, longMessageServerErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
if qualityInfo.LongMessageServerResponseLatency > 2000 {
|
||||
if qualityInfo.LongMessageServerResponseLatency == 9999 {
|
||||
log.Errorf("错误: 长消息服务器响应延迟测试失败, %v 如果您使用的腾讯云服务器, 请修改DNS到114.114.114.114", longMessageServerErrorMessage)
|
||||
} else {
|
||||
log.Warnf("警告: 长消息响应延迟为 %vms, 大于 1000ms, %v", qualityInfo.LongMessageServerResponseLatency, longMessageServerErrorMessage)
|
||||
}
|
||||
}
|
||||
//if qualityInfo.LongMessageServerLatency > 1000 {
|
||||
// if qualityInfo.LongMessageServerLatency == 9999 {
|
||||
// log.Errorf("错误: 长消息服务器延迟测试失败, %v 如果您使用的腾讯云服务器, 请修改DNS到114.114.114.114", longMessageServerErrorMessage)
|
||||
// } else {
|
||||
// log.Warnf("警告: 长消息延迟为 %vms, 大于 1000ms, %v", qualityInfo.LongMessageServerLatency, longMessageServerErrorMessage)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if qualityInfo.LongMessageServerResponseLatency > 2000 {
|
||||
// if qualityInfo.LongMessageServerResponseLatency == 9999 {
|
||||
// log.Errorf("错误: 长消息服务器响应延迟测试失败, %v 如果您使用的腾讯云服务器, 请修改DNS到114.114.114.114", longMessageServerErrorMessage)
|
||||
// } else {
|
||||
// log.Warnf("警告: 长消息响应延迟为 %vms, 大于 1000ms, %v", qualityInfo.LongMessageServerResponseLatency, longMessageServerErrorMessage)
|
||||
// }
|
||||
//}
|
||||
|
||||
if qualityInfo.SrvServerLatency > 1000 {
|
||||
if qualityInfo.SrvServerPacketLoss == 9999 {
|
||||
@ -59,7 +63,11 @@ func NetworkDiagnosis(c *client.QQClient) {
|
||||
log.Warnf("警告: 本地连接媒体服务器丢包率为 %v%%, %v", qualityInfo.SrvServerPacketLoss*10, mediaServerErrorMessage)
|
||||
}
|
||||
|
||||
if qualityInfo.ChatServerLatency > 1000 || qualityInfo.ChatServerPacketLoss > 0 || qualityInfo.LongMessageServerLatency > 1000 || qualityInfo.SrvServerLatency > 1000 || qualityInfo.SrvServerPacketLoss > 0 {
|
||||
if qualityInfo.ChatServerLatency > 1000 ||
|
||||
qualityInfo.ChatServerPacketLoss > 0 ||
|
||||
//qualityInfo.LongMessageServerLatency > 1000 ||
|
||||
qualityInfo.SrvServerLatency > 1000 ||
|
||||
qualityInfo.SrvServerPacketLoss > 0 {
|
||||
log.Infof("网络诊断完成. 发现问题, 请检查日志.")
|
||||
} else {
|
||||
log.Infof("网络诊断完成. 未发现问题")
|
||||
@ -75,4 +83,3 @@ func DNSDiagnosis() {
|
||||
func EnvironmentDiagnosis() {
|
||||
// todo
|
||||
}
|
||||
*/
|
||||
|
@ -26,8 +26,8 @@ account: # 账号相关
|
||||
#
|
||||
# 服务器不提供自建
|
||||
sign-servers:
|
||||
- url: 'https://sign.ciallo.site/api/sign' # 主签名服务器地址, 必填
|
||||
- url: 'https://sign.lagrangecore.org/api/sign/25765' # 备用
|
||||
- url: '-' # 主签名服务器地址, 必填
|
||||
- url: '-' # 备用
|
||||
|
||||
# 连续寻找可用签名服务器最大尝试次数
|
||||
# 为 0 时会在连续 3 次没有找到可用签名服务器后保持使用主签名服务器,不再尝试进行切换备用
|
||||
|
Reference in New Issue
Block a user