mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
chore: update deps
This commit is contained in:
@@ -21,8 +21,8 @@ import (
|
||||
)
|
||||
|
||||
type robberyRepo struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
type robberyRecord struct {
|
||||
@@ -32,9 +32,7 @@ type robberyRecord struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
police := &robberyRepo{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
var police robberyRepo
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "打劫别人的钱包",
|
||||
@@ -58,7 +56,7 @@ func init() {
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
police.db.DBPath = engine.DataFolder() + "robbery.db"
|
||||
police.db = sql.New(engine.DataFolder() + "robbery.db")
|
||||
err := police.db.Open(time.Hour)
|
||||
if err == nil {
|
||||
// 创建CD表
|
||||
@@ -157,9 +155,8 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
return 1, err
|
||||
}
|
||||
// 拼接查询SQL
|
||||
limitID := "where victim_id is " + strconv.FormatInt(victimID, 10) +
|
||||
" or user_id is " + strconv.FormatInt(uid, 10)
|
||||
if !sql.db.CanFind("criminal_record", limitID) {
|
||||
limitID := "WHERE victim_id = ? OR user_id = ?"
|
||||
if !sql.db.CanFind("criminal_record", limitID, victimID, uid) {
|
||||
// 没有记录即不用比较
|
||||
return 0, nil
|
||||
}
|
||||
@@ -168,7 +165,7 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
err = sql.db.FindFor("criminal_record", &cdInfo, limitID, func() error {
|
||||
if time.Now().Format("2006/01/02") != cdInfo.Time {
|
||||
// // 如果跨天了就删除
|
||||
err = sql.db.Del("criminal_record", limitID)
|
||||
err = sql.db.Del("criminal_record", limitID, victimID, uid)
|
||||
return nil
|
||||
}
|
||||
// 俩个if是为了保证,重复打劫同一个人,ok == 3
|
||||
@@ -180,7 +177,7 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
ok++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}, victimID, uid)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user