This commit is contained in:
源文雨 2022-12-02 14:12:43 +08:00
commit 7547b33f65
2 changed files with 76 additions and 77 deletions

View File

@ -5,6 +5,7 @@ import (
"math/rand" "math/rand"
"sort" "sort"
"strconv" "strconv"
"strings"
"sync" "sync"
"time" "time"
@ -346,6 +347,7 @@ func (sql *婚姻登记) 开门时间(gid int64) error {
// 如果跨天了就删除 // 如果跨天了就删除
_ = sql.db.Drop("group" + strconv.FormatInt(gid, 10)) _ = sql.db.Drop("group" + strconv.FormatInt(gid, 10))
// 更新数据时间 // 更新数据时间
grouInfo.GID = gid
grouInfo.Updatetime = time.Now().Format("2006/01/02") grouInfo.Updatetime = time.Now().Format("2006/01/02")
return sql.db.Insert("updateinfo", &grouInfo) return sql.db.Insert("updateinfo", &grouInfo)
} }
@ -456,7 +458,7 @@ func (sql *婚姻登记) 清理花名册(gid ...string) error {
default: default:
err := sql.db.Drop(gid[0]) err := sql.db.Drop(gid[0])
if err == nil { if err == nil {
err = sql.db.Del("cdsheet", "where GroupID is "+gid[0]) _ = sql.db.Del("cdsheet", "where GroupID is "+strings.ReplaceAll(gid[0], "group", ""))
} }
return err return err
} }

View File

@ -16,7 +16,7 @@ type cdsheet struct {
Time int64 // 时间 Time int64 // 时间
GroupID int64 // 群号 GroupID int64 // 群号
UserID int64 // 用户 UserID int64 // 用户
Model string // 技能类型 ModeID string // 技能类型
} }
var sendtext = [...][]string{ var sendtext = [...][]string{
@ -40,7 +40,7 @@ var sendtext = [...][]string{
"离婚成功力\n话说你不考虑当个1", "离婚成功力\n话说你不考虑当个1",
"离婚成功力\n天涯何处无芳草何必单恋一枝花不如再摘一支bushi", "离婚成功力\n天涯何处无芳草何必单恋一枝花不如再摘一支bushi",
}, },
} }
func init() { func init() {
engine.OnRegex(`^设置CD为(\d+)小时`, zero.OnlyGroup, zero.AdminPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser). engine.OnRegex(`^设置CD为(\d+)小时`, zero.OnlyGroup, zero.AdminPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
@ -360,18 +360,18 @@ func init() {
} }
// nolint: asciicheck // nolint: asciicheck
//nolint: asciicheck // nolint: asciicheck
func (sql *婚姻登记) 判断CD(gid, uid int64, model string, cdtime float64) (ok bool, err error) { func (sql *婚姻登记) 判断CD(gid, uid int64, model string, cdtime float64) (ok bool, err error) {
sql.Lock() sql.Lock()
defer sql.Unlock() defer sql.Unlock()
// 创建群表格 // 创建群表格
err = sql.db.Create("cdsheet", &cdsheet{}) err = sql.db.Create("cdsheet", &cdsheet{})
if err != nil { if err != nil {
return return false, err
} }
limitID := "where GroupID is " + strconv.FormatInt(gid, 10) + limitID := "where GroupID is " + strconv.FormatInt(gid, 10) +
" and UserID is " + strconv.FormatInt(uid, 10) + " and UserID is " + strconv.FormatInt(uid, 10) +
" and Model is '" + model + "'" " and ModeID is '" + model + "'"
if !sql.db.CanFind("cdsheet", limitID) { if !sql.db.CanFind("cdsheet", limitID) {
// 没有记录即不用比较 // 没有记录即不用比较
return true, nil return true, nil
@ -387,7 +387,7 @@ func (sql *婚姻登记) 判断CD(gid, uid int64, model string, cdtime float64)
} }
// nolint: asciicheck // nolint: asciicheck
//nolint: asciicheck // nolint: asciicheck
func (sql *婚姻登记) 记录CD(gid, uid int64, mode string) error { func (sql *婚姻登记) 记录CD(gid, uid int64, mode string) error {
sql.Lock() sql.Lock()
defer sql.Unlock() defer sql.Unlock()
@ -395,12 +395,12 @@ func (sql *婚姻登记) 记录CD(gid, uid int64, mode string) error {
Time: time.Now().Unix(), Time: time.Now().Unix(),
GroupID: gid, GroupID: gid,
UserID: uid, UserID: uid,
Model: mode, ModeID: mode,
}) })
} }
// nolint: asciicheck // nolint: asciicheck
//nolint: asciicheck // nolint: asciicheck
func (sql *婚姻登记) 离婚休妻(gid, wife int64) error { func (sql *婚姻登记) 离婚休妻(gid, wife int64) error {
sql.Lock() sql.Lock()
defer sql.Unlock() defer sql.Unlock()
@ -410,7 +410,7 @@ func (sql *婚姻登记) 离婚休妻(gid, wife int64) error {
} }
// nolint: asciicheck // nolint: asciicheck
//nolint: asciicheck // nolint: asciicheck
func (sql *婚姻登记) 离婚休夫(gid, husband int64) error { func (sql *婚姻登记) 离婚休夫(gid, husband int64) error {
sql.Lock() sql.Lock()
defer sql.Unlock() defer sql.Unlock()
@ -444,6 +444,16 @@ func checkSingleDog(ctx *zero.Ctx) bool {
ctx.SendChain(message.Text("你群包分配,别在娶妻上面下功夫,好好水群")) ctx.SendChain(message.Text("你群包分配,别在娶妻上面下功夫,好好水群"))
return false return false
} }
// 判断CD
ok, err := 民政局.判断CD(gid, uid, "嫁娶", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
// 获取用户信息 // 获取用户信息
userInfo, _ := 民政局.查户口(gid, uid) userInfo, _ := 民政局.查户口(gid, uid)
switch { switch {
@ -465,23 +475,13 @@ func checkSingleDog(ctx *zero.Ctx) bool {
case fianceeInfo != (userinfo{}) && (fianceeInfo.Target == 0 || fianceeInfo.User == 0): // 如果是单身贵族 case fianceeInfo != (userinfo{}) && (fianceeInfo.Target == 0 || fianceeInfo.User == 0): // 如果是单身贵族
ctx.SendChain(message.Text("今天的ta是单身贵族噢")) ctx.SendChain(message.Text("今天的ta是单身贵族噢"))
return false return false
case fianceeInfo.User == uid: // 如果如为攻 case fianceeInfo.User == fiancee: // 如果如为攻
ctx.SendChain(message.Text("他有别的女人了,你该放下了")) ctx.SendChain(message.Text("他有别的女人了,你该放下了"))
return false return false
case fianceeInfo.Target == uid: // 如果为受 case fianceeInfo.Target == fiancee: // 如果为受
ctx.SendChain(message.Text("ta被别人娶了,你来晚力")) ctx.SendChain(message.Text("ta被别人娶了,你来晚力"))
return false return false
} }
// 判断CD
ok, err := 民政局.判断CD(gid, uid, "嫁娶", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
return true return true
} }
@ -510,6 +510,16 @@ func checkMistress(ctx *zero.Ctx) bool {
ctx.SendChain(message.Text("你群发布了牛头人禁止令,放弃吧")) ctx.SendChain(message.Text("你群发布了牛头人禁止令,放弃吧"))
return false return false
} }
// 判断CD
ok, err := 民政局.判断CD(gid, uid, "嫁娶", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
// 获取用户信息 // 获取用户信息
fianceeInfo, _ := 民政局.查户口(gid, fiancee) fianceeInfo, _ := 民政局.查户口(gid, fiancee)
switch { switch {
@ -519,6 +529,9 @@ func checkMistress(ctx *zero.Ctx) bool {
case fianceeInfo.Target == 0 || fianceeInfo.User == 0: // 如果是单身贵族 case fianceeInfo.Target == 0 || fianceeInfo.User == 0: // 如果是单身贵族
ctx.SendChain(message.Text("今天的ta是单身贵族噢")) ctx.SendChain(message.Text("今天的ta是单身贵族噢"))
return false return false
case fianceeInfo.Target == uid || fianceeInfo.User == uid:
ctx.SendChain(message.Text("笨蛋!你们已经在一起了!"))
return false
} }
// 获取用户信息 // 获取用户信息
userInfo, _ := 民政局.查户口(gid, uid) userInfo, _ := 民政局.查户口(gid, uid)
@ -526,9 +539,6 @@ func checkMistress(ctx *zero.Ctx) bool {
case userInfo != (userinfo{}) && (userInfo.Target == 0 || userInfo.User == 0): // 如果是单身贵族 case userInfo != (userinfo{}) && (userInfo.Target == 0 || userInfo.User == 0): // 如果是单身贵族
ctx.SendChain(message.Text("今天的你是单身贵族噢")) ctx.SendChain(message.Text("今天的你是单身贵族噢"))
return false return false
case userInfo.Target == fiancee || userInfo.User == fiancee:
ctx.SendChain(message.Text("笨蛋!你们已经在一起了!"))
return false
case userInfo.User == uid: // 如果如为攻 case userInfo.User == uid: // 如果如为攻
ctx.SendChain(message.Text("打灭,不给纳小妾!")) ctx.SendChain(message.Text("打灭,不给纳小妾!"))
return false return false
@ -536,16 +546,6 @@ func checkMistress(ctx *zero.Ctx) bool {
ctx.SendChain(message.Text("该是0就是0,当0有什么不好")) ctx.SendChain(message.Text("该是0就是0,当0有什么不好"))
return false return false
} }
// 判断CD
ok, err := 民政局.判断CD(gid, uid, "NTR", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
return true return true
} }
@ -609,6 +609,21 @@ func checkMatchmaker(ctx *zero.Ctx) bool {
ctx.SendChain(message.Text("[ERROR]:", err)) ctx.SendChain(message.Text("[ERROR]:", err))
return false return false
} }
// 获取CD
groupInfo, err := 民政局.查看设置(gid)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:", err))
return false
}
ok, err := 民政局.判断CD(gid, uid, "做媒", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
gayOneInfo, _ := 民政局.查户口(gid, gayOne) gayOneInfo, _ := 民政局.查户口(gid, gayOne)
switch { switch {
case gayOneInfo != (userinfo{}) && (gayOneInfo.Target == 0 || gayOneInfo.User == 0): // 如果是单身贵族 case gayOneInfo != (userinfo{}) && (gayOneInfo.Target == 0 || gayOneInfo.User == 0): // 如果是单身贵族
@ -627,27 +642,9 @@ func checkMatchmaker(ctx *zero.Ctx) bool {
case gayOneInfo != (userinfo{}) && (gayZeroInfo.Target == 0 || gayZeroInfo.User == 0): // 如果是单身贵族 case gayOneInfo != (userinfo{}) && (gayZeroInfo.Target == 0 || gayZeroInfo.User == 0): // 如果是单身贵族
ctx.SendChain(message.Text("今天的攻方是单身贵族噢")) ctx.SendChain(message.Text("今天的攻方是单身贵族噢"))
return false return false
case gayZeroInfo.Target == gayZero || gayZeroInfo.User == gayZero:
ctx.SendChain(message.Text("笨蛋!ta们已经在一起了!"))
return false
case gayZeroInfo != (userinfo{}): // 如果不是单身 case gayZeroInfo != (userinfo{}): // 如果不是单身
ctx.SendChain(message.Text("方不是单身,不允许给这种人做媒!")) ctx.SendChain(message.Text("受方不是单身,不允许给这种人做媒!"))
return false return false
} }
// 获取CD return true
groupInfo, err := 民政局.查看设置(gid)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:", err))
return false
}
ok, err := 民政局.判断CD(gid, uid, "做媒", groupInfo.CDtime)
switch {
case err != nil:
ctx.SendChain(message.Text("[ERROR]:", err))
return false
case !ok:
ctx.SendChain(message.Text("你的技能还在CD中..."))
return false
}
return false
} }