From 52db89b3904b9b8eecbc2b6cd7e651d997897c9c Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Mar 2026 02:21:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=87=8E=E6=80=AA?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8C=87=E4=BB=A4=E5=8F=8A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/config/controller/robot/mappit.go | 41 +++++++++++++++++++++++ modules/config/service/map_pit.go | 9 +++++ modules/dict/service/dict_info.go | 32 ++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 modules/config/controller/robot/mappit.go diff --git a/modules/config/controller/robot/mappit.go b/modules/config/controller/robot/mappit.go new file mode 100644 index 00000000..88368246 --- /dev/null +++ b/modules/config/controller/robot/mappit.go @@ -0,0 +1,41 @@ +package robot + +import ( + "blazing/modules/config/service" + dict "blazing/modules/dict/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()) + maps := dict.NewDictInfoService().GetData("mapid") + pets := dict.NewDictInfoService().GetNameData("pet") + + if len(msgs) > 1 { + var count uint32 = 0 + t, ok := pets[msgs[1]] + if ok { + count = uint32(t.Value) + } else { + count = gconv.Uint32(msgs[1]) + } + if count != 0 { + var cdks []string + for _, v := range service.NewMapPitService().GetPet(count) { + + cdks = append(cdks, gconv.String(maps[uint32(v.MapID)].Name)) + + } + + ctx.Send(strings.Join(cdks, "\n")) + } + + } + + }) +} diff --git a/modules/config/service/map_pit.go b/modules/config/service/map_pit.go index 767aac15..9558df47 100644 --- a/modules/config/service/map_pit.go +++ b/modules/config/service/map_pit.go @@ -37,3 +37,12 @@ func (s *MapPitService) GetDataALL(mapid uint32) []model.MapPit { return pet } + +func (s *MapPitService) GetPet(petid uint32) []model.MapPit { + + var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性 + dbm_enable(s.Model).Wheref(`refresh_id @> ARRAY[?]::integer[]`, petid).Scan(&pet) + + return pet + +} diff --git a/modules/dict/service/dict_info.go b/modules/dict/service/dict_info.go index f41553fe..292e80c8 100644 --- a/modules/dict/service/dict_info.go +++ b/modules/dict/service/dict_info.go @@ -91,6 +91,38 @@ func (s *DictInfoService) GetData(types string) (data map[uint32]model.DictInfo) }) return fusions +} +func (s *DictInfoService) GetNameData(types string) (data map[string]model.DictInfo) { + var ( + dictInfoModel = model.NewDictInfo() + dictTypeModel = model.NewDictType() + ) + // 如果typeData为空, 则返回空 + var ty *model.DictType + mType := cool.DBM(dictTypeModel) + mType.Where("key in (?)", types).Cache(gdb.CacheOption{ + // Duration: time.Hour, + + Force: false, + }).Scan(&ty) + + // 如果typeData为空, 则返回空 + if ty == nil { + return nil + } + m := cool.DBM(dictInfoModel) + var ress []model.DictInfo + m.Where("typeId", ty.ID).Cache(gdb.CacheOption{ + // Duration: time.Hour, + + Force: false, + }).Scan(&ress) + fusions := utils.ToMap(ress, func(t model.DictInfo) string { + + return t.Name //物品id转id + }) + return fusions + } // 获取物品的最大数限制