mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
修复qqwife bug,优化程序 (#432)
* Update command.go * Update function.go * Update command.go
This commit is contained in:
parent
92b9bab76a
commit
f2ff66ec1d
@ -89,7 +89,7 @@ func init() {
|
||||
return true
|
||||
})
|
||||
// 技能CD设置
|
||||
engine.OnRegex(`^设置CD为(\d+)小时`, zero.OnlyGroup, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
engine.OnRegex(`^设置CD为(\d+)小时`, zero.OnlyGroup, zero.AdminPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
cdTime, err := strconv.ParseFloat(ctx.State["regex_matched"].([]string)[1], 64)
|
||||
if err != nil {
|
||||
@ -104,7 +104,7 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
engine.OnRegex(`^(允许|禁止)(自由恋爱|牛头人)$`, zero.AdminPermission, getdb).SetBlock(true).
|
||||
engine.OnRegex(`^(允许|禁止)(自由恋爱|牛头人)$`, zero.OnlyGroup, zero.AdminPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
status := ctx.State["regex_matched"].([]string)[1]
|
||||
mode := ctx.State["regex_matched"].([]string)[2]
|
||||
@ -161,7 +161,7 @@ func init() {
|
||||
case status == "攻": // 娶过别人
|
||||
ctx.SendChain(
|
||||
message.At(uid),
|
||||
message.Text("\n今天你已经娶过了,群老婆是"),
|
||||
message.Text("\n今天你在", targetinfo.Updatetime, "娶了群友"),
|
||||
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.Target, 10)+"&s=640").Add("cache", 0),
|
||||
message.Text(
|
||||
"\n",
|
||||
@ -173,12 +173,12 @@ func init() {
|
||||
case status == "受": // 嫁给别人
|
||||
ctx.SendChain(
|
||||
message.At(uid),
|
||||
message.Text("\n今天你被娶了,群老公是"),
|
||||
message.Text("\n今天你在", targetinfo.Updatetime, "被群友"),
|
||||
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.User, 10)+"&s=640").Add("cache", 0),
|
||||
message.Text(
|
||||
"\n",
|
||||
"[", targetinfo.Username, "]",
|
||||
"(", targetinfo.User, ")哒",
|
||||
"(", targetinfo.User, ")娶了",
|
||||
),
|
||||
)
|
||||
return
|
||||
@ -243,6 +243,11 @@ func init() {
|
||||
uid := ctx.Event.UserID
|
||||
choice := ctx.State["regex_matched"].([]string)[1]
|
||||
fiancee, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||
// 写入CD
|
||||
err := 民政局.writeCDtime(gid, uid, 1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
if uid == fiancee { // 如果是自己
|
||||
switch rand.Intn(3) {
|
||||
case 1:
|
||||
@ -307,6 +312,11 @@ func init() {
|
||||
uid := ctx.Event.UserID
|
||||
fid := ctx.State["regex_matched"].([]string)
|
||||
fiancee, _ := strconv.ParseInt(fid[2]+fid[3], 10, 64)
|
||||
// 写入CD
|
||||
err := 民政局.writeCDtime(gid, uid, 2)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
if fiancee == uid {
|
||||
ctx.SendChain(message.Text("今日获得成就:自我攻略"))
|
||||
return
|
||||
@ -391,6 +401,11 @@ func init() {
|
||||
uid := ctx.Event.UserID
|
||||
gayOne, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||
gayZero, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||
// 写入CD
|
||||
err := 民政局.writeCDtime(gid, uid, 3)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
favor, err := 民政局.getFavorability(gayOne, gayZero)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]好感度库发生问题力\n", err))
|
||||
@ -447,6 +462,11 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
// 写入CD
|
||||
err := 民政局.writeCDtime(gid, uid, 4)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
info, uidstatus, err := 民政局.查户口(gid, uid)
|
||||
mun := 2
|
||||
var fiancee int64
|
||||
@ -466,7 +486,10 @@ func init() {
|
||||
ctx.SendChain(message.Text("[qqwife]好感度库发生问题力\n", err))
|
||||
return
|
||||
}
|
||||
if rand.Intn(1+favor) > favor/10 {
|
||||
if favor < 20 {
|
||||
favor = 10
|
||||
}
|
||||
if rand.Intn(101) > 100-favor {
|
||||
ctx.SendChain(message.Text(sendtext[3][rand.Intn(len(sendtext[3]))]))
|
||||
return
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// nolint: asciicheck
|
||||
//nolint: asciicheck
|
||||
// nolint: asciicheck
|
||||
type 婚姻登记 struct {
|
||||
db *sql.Sqlite
|
||||
dbmu sync.RWMutex
|
||||
@ -60,12 +60,7 @@ func (sql *婚姻登记) 开门时间(gid int64) (ok bool, err error) {
|
||||
ok = false
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
if err = sql.db.Drop("updateinfo"); err == nil {
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
gidstr := strconv.FormatInt(gid, 10)
|
||||
dbinfo := updateinfo{}
|
||||
@ -243,7 +238,7 @@ func (sql *婚姻登记) 登记(gid, uid, target int64, username, targetname str
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updatetime := time.Now().Format("2006/01/02")
|
||||
updatetime := time.Now().Format("15:04:05")
|
||||
// 填写夫妻信息
|
||||
uidinfo := userinfo{
|
||||
User: uid,
|
||||
@ -498,7 +493,6 @@ func (sql *婚姻登记) compareCDtime(gid, uid, mun int64, cdtime float64) (ok
|
||||
|
||||
// 注入判断 是否为单身
|
||||
func checkdog(ctx *zero.Ctx) bool {
|
||||
mode := int64(1) // 指代技能1
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
// 获取CD
|
||||
@ -506,7 +500,7 @@ func checkdog(ctx *zero.Ctx) bool {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]获取该群技能CD错误(将以CD12H计算)\n", err))
|
||||
}
|
||||
ok, err := 民政局.compareCDtime(gid, uid, mode, cdTime)
|
||||
ok, err := 民政局.compareCDtime(gid, uid, 1, cdTime)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]查询用户CD状态失败,请重试\n", err))
|
||||
return false
|
||||
@ -515,11 +509,6 @@ func checkdog(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("你的技能还在CD中..."))
|
||||
return false
|
||||
}
|
||||
// 写入CD
|
||||
err = 民政局.writeCDtime(gid, uid, mode)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
// 判断是否符合条件
|
||||
stauts, _, err := 民政局.营业模式(gid)
|
||||
if err != nil {
|
||||
@ -583,7 +572,6 @@ func checkdog(ctx *zero.Ctx) bool {
|
||||
|
||||
// 注入判断 是否满足小三要求
|
||||
func checkcp(ctx *zero.Ctx) bool {
|
||||
mode := int64(2) // 指代技能2
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
// 获取CD
|
||||
@ -591,7 +579,7 @@ func checkcp(ctx *zero.Ctx) bool {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]获取该群技能CD错误(将以CD12H计算)\n", err))
|
||||
}
|
||||
ok, err := 民政局.compareCDtime(gid, uid, mode, cdTime)
|
||||
ok, err := 民政局.compareCDtime(gid, uid, 2, cdTime)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]查询用户CD状态失败,请重试\n", err))
|
||||
return false
|
||||
@ -600,11 +588,6 @@ func checkcp(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("你的技能还在CD中..."))
|
||||
return false
|
||||
}
|
||||
// 写入CD
|
||||
err = 民政局.writeCDtime(gid, uid, mode)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
// 判断是否符合条件
|
||||
_, stauts, err := 民政局.营业模式(gid)
|
||||
if err != nil {
|
||||
@ -669,7 +652,6 @@ func checkcp(ctx *zero.Ctx) bool {
|
||||
|
||||
// 注入判断 是否满足离婚要求
|
||||
func checkdivorce(ctx *zero.Ctx) bool {
|
||||
mode := int64(3) // 指代技能3
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
// 获取CD
|
||||
@ -677,7 +659,7 @@ func checkdivorce(ctx *zero.Ctx) bool {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]获取该群技能CD错误(将以CD12H计算)\n", err))
|
||||
}
|
||||
ok, err := 民政局.compareCDtime(gid, uid, mode, cdTime)
|
||||
ok, err := 民政局.compareCDtime(gid, uid, 4, cdTime)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]查询用户CD状态失败,请重试\n", err))
|
||||
return false
|
||||
@ -686,11 +668,6 @@ func checkdivorce(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("你的技能还在CD中..."))
|
||||
return false
|
||||
}
|
||||
// 写入CD
|
||||
err = 民政局.writeCDtime(gid, uid, mode)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
// 判断是否符合条件
|
||||
_, uidstatus, err := 民政局.查户口(gid, uid)
|
||||
switch uidstatus {
|
||||
@ -706,7 +683,6 @@ func checkdivorce(ctx *zero.Ctx) bool {
|
||||
|
||||
// 注入判断 是否满足做媒要求
|
||||
func checkCondition(ctx *zero.Ctx) bool {
|
||||
mode := int64(4) // 指代技能4
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
// 获取CD
|
||||
@ -714,7 +690,7 @@ func checkCondition(ctx *zero.Ctx) bool {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]获取该群技能CD错误(将以CD12H计算)\n", err))
|
||||
}
|
||||
ok, err := 民政局.compareCDtime(gid, uid, mode, cdTime)
|
||||
ok, err := 民政局.compareCDtime(gid, uid, 3, cdTime)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]查询用户CD状态失败,请重试\n", err))
|
||||
return false
|
||||
@ -723,11 +699,6 @@ func checkCondition(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("你的技能还在CD中..."))
|
||||
return false
|
||||
}
|
||||
// 写入CD
|
||||
err = 民政局.writeCDtime(gid, uid, mode)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
// 得先判断用户是否存在才行在,再重置
|
||||
gayOne, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user