From 75de7bd55797e10d69142d9b8c3442f3a7b16798 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Mar 2026 02:59:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8B=87=E8=80=85?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E5=92=8C=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/utils/help.go | 10 ++++++ modules/config/controller/robot/boss.go | 43 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 modules/config/controller/robot/boss.go diff --git a/common/utils/help.go b/common/utils/help.go index b35cf44be..3f0ed8110 100644 --- a/common/utils/help.go +++ b/common/utils/help.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "math/rand/v2" + "strings" "time" "github.com/gogf/gf/v2/os/gtime" @@ -167,3 +168,12 @@ func IsCurrentTimeInRange(startStr, endStr string) (bool, error) { // 3. 比较当前时间是否在 [startToday, endToday] 区间内 return now.After(startToday) && now.Before(endToday), nil } + +// Format 把 args 按顺序填入 {0},{1},{2}... +func Format(s string, args ...interface{}) string { + for i, arg := range args { + placeholder := "{" + string(rune('0'+i)) + "}" + s = strings.ReplaceAll(s, placeholder, gconv.String(arg)) + } + return s +} diff --git a/modules/config/controller/robot/boss.go b/modules/config/controller/robot/boss.go new file mode 100644 index 000000000..3a3943928 --- /dev/null +++ b/modules/config/controller/robot/boss.go @@ -0,0 +1,43 @@ +package robot + +import ( + "blazing/common/data/xmlres" + "blazing/modules/config/service" + "strings" + + "github.com/gogf/gf/v2/util/gconv" + zero "github.com/wdvxdr1123/ZeroBot" +) + +func init() { + zero.OnCommand("勇者"). + Handle(func(ctx *zero.Ctx) { + msgs := strings.Fields(ctx.Event.Message.String()) + //eids := dict.NewDictInfoService().GetData("eid") + + if len(msgs) > 1 { + count := gconv.Uint32(msgs[1]) + if count != 0 { + var cdks []string + r := service.NewTower500Service().Boss(count) //获取第一个配置,因为塔只绑定一组boss,bossid也是0 + if len(r) > 0 { + var buf strings.Builder + for _, v := range service.NewBossService().Get(r[0].BossIds[0]) { + buf.WriteString(xmlres.PetMAP[int(v.MonID)].DefName + "\n") + + for _, effs := range service.NewEffectService().Args(v.Effect) { + + buf.WriteString(effs.Desc + "\n") + } + cdks = append(cdks, buf.String()) + + } + } + + ctx.Send(strings.Join(cdks, "\n")) + } + + } + + }) +}