Merge branch 'main' of github.com:72wo/blazing

This commit is contained in:
2026-01-06 23:25:58 +08:00
3 changed files with 42 additions and 26 deletions

View File

@@ -266,10 +266,10 @@ func (our *Input) GetAction() {
our.FightC.UseSkill(our.Player, uint32(bestKillSkill.ID))
return
}
if len(allSkills) <= 0 {
our.FightC.UseSkill(our.Player, 0)
return
}
// if len(allSkills) <= 0 {
// our.FightC.UseSkill(our.Player, 0)
// return
// }
// 优化随机选择技能的逻辑,直接使用随机索引
randomIdx := grand.Intn(len(allSkills))

View File

@@ -11,6 +11,7 @@ import (
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/gfile"
"github.com/xiaoqidun/qqwry"
"golang.org/x/time/rate"
)
@@ -28,6 +29,10 @@ var (
if cool.IsRedisMode {
go cool.ListenFunc(ctx)
}
// // 从文件加载IP数据库
if err := qqwry.LoadFile("public/qqwry.ipdb"); err != nil {
panic(err)
}
//go robot()
go reg()
s := g.Server()

View File

@@ -2,14 +2,13 @@ package service
import (
"blazing/cool"
"fmt"
"sync"
"blazing/modules/base/model"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"github.com/xiaoqidun/qqwry"
)
type BaseSysLogService struct {
@@ -31,6 +30,16 @@ func NewBaseSysLogService() *BaseSysLogService {
Condition: `"user".id = base_sys_log."userId"`,
},
},
ModifyResult: func(ctx g.Ctx, data interface{}) interface{} {
// baseSysLog.IPAddr = fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
// location.Country,
// location.Province,
// location.City,
// location.District,
// location.ISP,
// )
return data
},
},
},
}
@@ -47,19 +56,19 @@ func (s *BaseSysLogService) Record(ctx g.Ctx) {
baseSysLog.Action = r.Method + ":" + r.URL.Path
baseSysLog.IP = r.GetClientIp()
// 从内存或缓存查询IP
location, err := qqwry.QueryIP(baseSysLog.IP)
if err != nil {
fmt.Printf("错误:%v\n", err)
return
}
baseSysLog.IPAddr = fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
location.Country,
location.Province,
location.City,
location.District,
location.ISP,
)
// // 从内存或缓存查询IP
// location, err := qqwry.QueryIP(baseSysLog.IP)
// if err != nil {
// fmt.Printf("错误:%v\n", err)
// return
// }
// baseSysLog.IPAddr = fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
// location.Country,
// location.Province,
// location.City,
// location.District,
// location.ISP,
// )
baseSysLog.Params = r.GetBodyString()
m := cool.DBM(s.Model)
if baseSysLog.UserID == 10001 {
@@ -69,7 +78,7 @@ func (s *BaseSysLogService) Record(ctx g.Ctx) {
"userId": baseSysLog.UserID,
"action": baseSysLog.Action,
"ip": baseSysLog.IP,
"ipAddr": baseSysLog.IPAddr,
//"ipAddr": baseSysLog.IPAddr,
"params": baseSysLog.Params,
})
}
@@ -87,10 +96,12 @@ func (s *BaseSysLogService) Clear(isAll bool) (err error) {
return
}
func init() {
// 从文件加载IP数据库
if err := qqwry.LoadFile("public/qqwry.ipdb"); err != nil {
panic(err)
}
var ipdata sync.Once
}
// func init() {
// // 从文件加载IP数据库
// if err := qqwry.LoadFile("public/qqwry.ipdb"); err != nil {
// panic(err)
// }
// }