From eecaecb373207df544bfd84f2bc4507bdfd8d5b9 Mon Sep 17 00:00:00 2001 From: JustAnotherID Date: Mon, 20 Nov 2023 13:05:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(qq):=20=E4=BF=AE=E5=A4=8D=E5=BC=BA?= =?UTF-8?q?=E8=BD=ACgocq=E7=9A=84adapter=E5=AF=BC=E8=87=B4=E7=9A=84panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dice/dice_backup.go | 3 +-- dice/dice_ban.go | 10 +++++++++- dice/platform_adapter.go | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dice/dice_backup.go b/dice/dice_backup.go index 7a84423e..dfd771bf 100644 --- a/dice/dice_backup.go +++ b/dice/dice_backup.go @@ -158,8 +158,7 @@ func (dm *DiceManager) Backup(cfg AllBackupConfig, bakFilename string) (string, if cfg2.Accounts { for _, i := range d.ImSession.EndPoints { if i.Platform == "QQ" { - pa := i.Adapter.(*PlatformAdapterGocq) - if pa.UseInPackGoCqhttp { + if pa, ok := i.Adapter.(*PlatformAdapterGocq); ok && pa.UseInPackGoCqhttp { backup(d, filepath.Join(d.BaseConfig.DataDir, i.RelWorkDir, "config.yml")) backup(d, filepath.Join(d.BaseConfig.DataDir, i.RelWorkDir, "device.json")) backup(d, filepath.Join(d.BaseConfig.DataDir, i.RelWorkDir, "session.token")) diff --git a/dice/dice_ban.go b/dice/dice_ban.go index 94479ff5..a20a0825 100644 --- a/dice/dice_ban.go +++ b/dice/dice_ban.go @@ -127,6 +127,7 @@ func (i *BanListInfo) AfterLoads() { // AddScoreBase // 这一份ctx有endpoint就行 func (i *BanListInfo) AddScoreBase(uid string, score int64, place string, reason string, ctx *MsgContext) *BanListInfoItem { + log := i.Parent.Logger v, _ := i.Map.Load(uid) if v == nil { v = &BanListInfoItem{ @@ -161,7 +162,14 @@ func (i *BanListInfo) AddScoreBase(uid string, score int64, place string, reason v.BanTime = time.Now().Unix() if ctx.EndPoint.Platform == "QQ" { - ctx.EndPoint.Adapter.(*PlatformAdapterGocq).DeleteFriend(ctx, place) + switch adapter := ctx.EndPoint.Adapter.(type) { + case *PlatformAdapterGocq: + adapter.DeleteFriend(ctx, place) + case *PlatformAdapterWalleQ: + adapter.DeleteFriend(ctx, place) + default: + log.Warn("当前qq适配器不支持删除好友") + } } } diff --git a/dice/platform_adapter.go b/dice/platform_adapter.go index bc11a17b..c96de94f 100644 --- a/dice/platform_adapter.go +++ b/dice/platform_adapter.go @@ -17,4 +17,7 @@ type PlatformAdapter interface { MemberKick(groupID string, userID string) GetGroupInfoAsync(groupID string) + + // DeleteFriend 删除好友,目前只有 QQ 平台下的 gocq 和 walleq 实现有这个方法 + // DeleteFriend(ctx *MsgContext, id string) } From b883670c88fd4537bfbfee39411717fcb7b9f3d7 Mon Sep 17 00:00:00 2001 From: JustAnotherID Date: Mon, 20 Nov 2023 13:22:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(qq):=20=E5=BE=AE=E8=B0=83=E5=BC=BA?= =?UTF-8?q?=E8=BD=AC=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dice/dice_ban.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dice/dice_ban.go b/dice/dice_ban.go index a20a0825..c47eae6d 100644 --- a/dice/dice_ban.go +++ b/dice/dice_ban.go @@ -167,8 +167,10 @@ func (i *BanListInfo) AddScoreBase(uid string, score int64, place string, reason adapter.DeleteFriend(ctx, place) case *PlatformAdapterWalleQ: adapter.DeleteFriend(ctx, place) + case *PlatformAdapterRed: + log.Warn("qq red 适配器不支持删除好友") default: - log.Warn("当前qq适配器不支持删除好友") + log.Error("unknown qq adapter") } } }