mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
Update qqmapwife.go (#261)
This commit is contained in:
parent
621fd614ea
commit
b6f1b27a81
@ -1,10 +1,11 @@
|
|||||||
// Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
|
// Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品,文案采用了Hana的zbp娶群友文案
|
||||||
package qqwife
|
package qqwife
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -12,141 +13,271 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
ctrl "github.com/FloatTech/zbpctrl"
|
ctrl "github.com/FloatTech/zbpctrl"
|
||||||
"github.com/FloatTech/zbputils/binary"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/control"
|
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/math"
|
"github.com/FloatTech/zbputils/math"
|
||||||
|
|
||||||
|
//数据库
|
||||||
|
sql "github.com/FloatTech/sqlite"
|
||||||
|
//定时器
|
||||||
|
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
|
|
||||||
|
//画图
|
||||||
|
"github.com/FloatTech/zbputils/file"
|
||||||
|
"github.com/FloatTech/zbputils/img/text"
|
||||||
|
"github.com/FloatTech/zbputils/img/writer"
|
||||||
|
"github.com/fogleman/gg"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint: asciicheck
|
//nolint: asciicheck
|
||||||
type 婚姻登记 struct {
|
type 婚姻登记 struct {
|
||||||
sync.Mutex
|
db *sql.Sqlite
|
||||||
mp map[int64]map[int64]*userinfo
|
dbmu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// 结婚证信息
|
// 结婚证信息
|
||||||
type userinfo struct {
|
type userinfo struct {
|
||||||
target int64 // 对象身份证号
|
User int64 //用户身份证
|
||||||
username string // 户主名称
|
Target int64 // 对象身份证号
|
||||||
targetname string // 对象名称
|
Username string // 户主名称
|
||||||
|
Targetname string // 对象名称
|
||||||
|
Updatetime string //登记时间
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 民政局的当前时间
|
||||||
|
type updateinfo struct {
|
||||||
|
GID int64
|
||||||
|
Updatetime string //登记时间
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) checkupdate(gid int64) (updatetime string, number int, err error) {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
number, err = sql.db.Count("updateinfo")
|
||||||
|
switch { //先判断数据库是否为空
|
||||||
|
case err != nil:
|
||||||
|
return
|
||||||
|
case number <= 0:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
dbinfo := updateinfo{}
|
||||||
|
err = sql.db.Find("updateinfo", &dbinfo, "where gid is "+gidstr) //获取表格更新的时间
|
||||||
|
if err != nil {
|
||||||
|
err = sql.db.Insert("updateinfo", &updateinfo{GID: gid})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updatetime = dbinfo.Updatetime
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: asciicheck
|
//nolint: asciicheck
|
||||||
func 新登记处() (db 婚姻登记) {
|
func (sql *婚姻登记) 重置(gid string) error {
|
||||||
db.mp = make(map[int64]map[int64]*userinfo, 64)
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
if gid != "ALL" {
|
||||||
|
err := sql.db.Drop(gid)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
grouplist, err := sql.db.ListTables()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, gid := range grouplist {
|
||||||
|
err = sql.db.Drop(gid)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) 离婚休妻(gid, wife int64) error {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
wifestr := strconv.FormatInt(wife, 10)
|
||||||
|
//先判断用户是否存在
|
||||||
|
err := sql.db.Del(gidstr, "where target = "+wifestr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) 离婚休夫(gid, husband int64) error {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
husbandstr := strconv.FormatInt(husband, 10)
|
||||||
|
//先判断用户是否存在
|
||||||
|
err := sql.db.Del(gidstr, "where target = "+husbandstr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) 复婚(gid, uid, target int64, username, targetname string) error {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
uidstr := strconv.FormatInt(uid, 10)
|
||||||
|
tagstr := strconv.FormatInt(target, 10)
|
||||||
|
var info userinfo
|
||||||
|
err := sql.db.Find(gidstr, &info, "where user = "+uidstr)
|
||||||
|
if err == nil {
|
||||||
|
err = sql.db.Find(gidstr, &info, "where user = "+tagstr)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updatetime := time.Now().Format("2006/01/02")
|
||||||
|
// 更改夫妻信息
|
||||||
|
info.User = uid
|
||||||
|
info.Username = username
|
||||||
|
info.Target = target
|
||||||
|
info.Targetname = targetname
|
||||||
|
info.Updatetime = updatetime
|
||||||
|
// 民政局登记数据
|
||||||
|
err = sql.db.Insert(gidstr, &info)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = sql.db.Insert("updateinfo", &updateinfo{GID: gid, Updatetime: updatetime})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) 花名册(gid int64) (list [][4]string, number int, err error) {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
err = sql.db.Create(gidstr, &userinfo{})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
number, err = sql.db.Count(gidstr)
|
||||||
|
if err != nil || number <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var info userinfo
|
||||||
|
list = make([][4]string, 0, number)
|
||||||
|
err = sql.db.FindFor(gidstr, &info, "GROUP BY user", func() error {
|
||||||
|
dbinfo := [4]string{
|
||||||
|
info.Username,
|
||||||
|
strconv.FormatInt(info.User, 10),
|
||||||
|
info.Targetname,
|
||||||
|
strconv.FormatInt(info.Target, 10),
|
||||||
|
}
|
||||||
|
list = append(list, dbinfo)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *婚姻登记) 重置() {
|
func slicename(name string) (resultname string) {
|
||||||
db.Lock()
|
if len(name) <= 21 { //如果长度在宽度之内直接输出
|
||||||
defer db.Unlock()
|
resultname = name
|
||||||
for k := range db.mp {
|
|
||||||
delete(db.mp, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *婚姻登记) 离婚休妻(gid, wife int64) {
|
|
||||||
db.Lock()
|
|
||||||
defer db.Unlock()
|
|
||||||
delete(db.mp[gid], -wife)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *婚姻登记) 离婚休夫(gid, husband int64) {
|
|
||||||
db.Lock()
|
|
||||||
defer db.Unlock()
|
|
||||||
delete(db.mp[gid], husband)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *婚姻登记) 有登记(gid int64) (ok bool) {
|
|
||||||
db.Lock()
|
|
||||||
defer db.Unlock()
|
|
||||||
mp, ok := db.mp[gid]
|
|
||||||
if !ok {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for range mp {
|
usermane := []rune(name) //转utf8形式
|
||||||
return true
|
usermanelen := 0 //总长度
|
||||||
|
numberlen := 0 //字个数
|
||||||
|
var singlestr = " ,.;:'|!()[]" //单宽度长度的字符集
|
||||||
|
for i, v := range usermane {
|
||||||
|
if usermanelen > 18 { //6个汉字或者9个字符
|
||||||
|
numberlen = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case v/10000 >= 1:
|
||||||
|
usermanelen += 3
|
||||||
|
case strings.Contains(singlestr, string(v)):
|
||||||
|
usermanelen++
|
||||||
|
default:
|
||||||
|
usermanelen += 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultname = string(usermane[:numberlen-2]) + "......" //名字切片
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sql *婚姻登记) 查户口(gid, uid int64) (info userinfo, status int, err error) {
|
||||||
|
sql.dbmu.Lock()
|
||||||
|
defer sql.dbmu.Unlock()
|
||||||
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
|
uidstr := strconv.FormatInt(uid, 10)
|
||||||
|
status = 3
|
||||||
|
if err = sql.db.Create(gidstr, &userinfo{}); err != nil {
|
||||||
|
status = 2
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = sql.db.Find(gidstr, &info, "where user = "+uidstr)
|
||||||
|
if err == nil {
|
||||||
|
status = 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = sql.db.Find(gidstr, &info, "where target = "+uidstr)
|
||||||
|
if err == nil {
|
||||||
|
status = 0
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *婚姻登记) 花名册(ctx *zero.Ctx, gid int64) string {
|
func (sql *婚姻登记) 登记(gid, uid, target int64, username, targetname string) error {
|
||||||
db.Lock()
|
sql.dbmu.Lock()
|
||||||
defer db.Unlock()
|
defer sql.dbmu.Unlock()
|
||||||
mp, ok := db.mp[gid]
|
gidstr := strconv.FormatInt(gid, 10)
|
||||||
if !ok {
|
err := sql.db.Create(gidstr, &userinfo{})
|
||||||
return "民政局的花名册出问题了额..."
|
if err != nil {
|
||||||
}
|
return err
|
||||||
return binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
|
|
||||||
w.WriteString("群老公←———→群老婆\n-----------")
|
|
||||||
for uid, userinfo := range mp {
|
|
||||||
if uid > 0 {
|
|
||||||
_ = w.WriteByte('\n')
|
|
||||||
w.WriteString(userinfo.username)
|
|
||||||
w.WriteString(" & ")
|
|
||||||
w.WriteString(userinfo.targetname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *婚姻登记) 查户口(gid, uid int64) (userinfo *userinfo, gender int, ok bool) {
|
|
||||||
db.Lock()
|
|
||||||
defer db.Unlock()
|
|
||||||
gender = 0
|
|
||||||
mp, ok := db.mp[gid]
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userinfo, ok = mp[uid]
|
|
||||||
if !ok {
|
|
||||||
gender = 1
|
|
||||||
userinfo, ok = mp[-uid]
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *婚姻登记) 登记(gid, uid, target int64, username, targetname string) {
|
|
||||||
db.Lock()
|
|
||||||
defer db.Unlock()
|
|
||||||
_, ok := db.mp[gid]
|
|
||||||
if !ok {
|
|
||||||
db.mp[gid] = make(map[int64]*userinfo, 32)
|
|
||||||
}
|
}
|
||||||
|
updatetime := time.Now().Format("2006/01/02")
|
||||||
// 填写夫妻信息
|
// 填写夫妻信息
|
||||||
uidinfo := &userinfo{
|
uidinfo := userinfo{
|
||||||
target: target,
|
User: uid,
|
||||||
username: username,
|
Username: username,
|
||||||
targetname: targetname,
|
Target: target,
|
||||||
}
|
Targetname: targetname,
|
||||||
targetinfo := &userinfo{
|
Updatetime: updatetime,
|
||||||
target: uid,
|
|
||||||
username: targetname,
|
|
||||||
targetname: username,
|
|
||||||
}
|
}
|
||||||
// 民政局登记数据
|
// 民政局登记数据
|
||||||
db.mp[gid][uid] = uidinfo
|
err = sql.db.Insert(gidstr, &uidinfo)
|
||||||
db.mp[gid][-target] = targetinfo
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = sql.db.Insert("updateinfo", &updateinfo{GID: gid, Updatetime: updatetime})
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//nolint: asciicheck
|
//nolint: asciicheck
|
||||||
民政局 = 新登记处()
|
民政局 = &婚姻登记{
|
||||||
skillCD = rate.NewManager[string](time.Hour*24, 1)
|
db: &sql.Sqlite{},
|
||||||
lastdate time.Time
|
}
|
||||||
|
skillCD = rate.NewManager[string](time.Hour*12, 1)
|
||||||
sendtext = [...][]string{
|
sendtext = [...][]string{
|
||||||
{ // 表白成功
|
{ // 表白成功
|
||||||
"今天你向ta表白了,ta羞涩的点了点头同意了!\n",
|
"是个勇敢的孩子(*/ω\*) 今天的运气都降临在你的身边~\n\n",
|
||||||
"你对ta说“以我之名,冠你指间,一天相伴,一天相随”.ta捂着嘴点了点头\n\n",
|
"(´・ω・`)对方答应了你 并表示愿意当今天的CP\n\n",
|
||||||
},
|
},
|
||||||
{ // 表白失败
|
{ // 表白失败
|
||||||
"今天你向ta表白了,ta毫无感情的拒绝了你",
|
"今天的运气有一点背哦~明天再试试叭",
|
||||||
"今天你向ta表白了,ta对你说“你是一个非常好的人”",
|
"_(:з」∠)_下次还有机会 咱抱抱你w",
|
||||||
"今天你向ta表白了,ta给了你一个拥抱后擦肩而过",
|
"今天失败了惹. 摸摸头~咱明天还有机会",
|
||||||
},
|
},
|
||||||
{ // ntr成功
|
{ // ntr成功
|
||||||
"你处心积虑的接近ta,ta最终选择跟随你\n",
|
"因为你的个人魅力~~今天他就是你的了w\n\n",
|
||||||
|
},
|
||||||
|
{ // 离婚失败
|
||||||
|
"打是情,骂是爱,,不打不亲不相爱。答应我不要分手。",
|
||||||
|
"床头打架床尾和,夫妻没有隔夜仇。安啦安啦,不要闹变扭。",
|
||||||
|
},
|
||||||
|
{ // 离婚成功
|
||||||
|
"离婚成功力\n天涯何处无芳草,何必单恋一枝花?不如再摘一支(bushi",
|
||||||
|
"离婚成功力\n话说你不考虑当个1?",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -154,46 +285,70 @@ var (
|
|||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("qqwife", &ctrl.Options[*zero.Ctx]{
|
engine := control.Register("qqwife", &ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
|
PrivateDataFolder: "qqwife",
|
||||||
Help: "一群一天一夫一妻制群老婆\n(每天凌晨刷新CP)\n" +
|
Help: "一群一天一夫一妻制群老婆\n(每天凌晨刷新CP)\n" +
|
||||||
"- 娶群友\n- 群老婆列表\n" +
|
"- 娶群友\n- 群老婆列表\n" +
|
||||||
"--------------------------------\n以下技能每人只能二选一\n CD24H,不跨天刷新\n--------------------------------\n" +
|
"--------------------------------\n以下技能每人只能三选一\n CD12H,不跨天刷新\n--------------------------------\n" +
|
||||||
"- (娶|嫁)@对方QQ\n- 当[对方Q号|@对方QQ]的小三\n",
|
"- (娶|嫁)@对方QQ\n- 当[对方Q号|@对方QQ]的小三\n- 闹离婚",
|
||||||
})
|
})
|
||||||
engine.OnFullMatch("娶群友", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||||
|
民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db"
|
||||||
|
// 如果数据库不存在则下载
|
||||||
|
//_, _ = engine.GetLazyData("结婚登记表.db", false)
|
||||||
|
//nolint: asciicheck
|
||||||
|
err := 民政局.db.Open(time.Hour * 24)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
engine.OnFullMatch("娶群友", zero.OnlyGroup, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if time.Now().Day() != lastdate.Day() {
|
|
||||||
民政局.重置()
|
|
||||||
// 更新时间
|
|
||||||
lastdate = time.Now()
|
|
||||||
}
|
|
||||||
gid := ctx.Event.GroupID
|
gid := ctx.Event.GroupID
|
||||||
uid := ctx.Event.UserID
|
updatetime, _, err := 民政局.checkupdate(gid)
|
||||||
targetinfo, status, ok := 民政局.查户口(gid, uid)
|
switch {
|
||||||
if ok {
|
case err != nil:
|
||||||
switch status {
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
case 0: // 娶过别人
|
return
|
||||||
ctx.SendChain(
|
case time.Now().Format("2006/01/02") != updatetime:
|
||||||
message.At(uid),
|
if err := 民政局.重置(strconv.FormatInt(gid, 10)); err != nil {
|
||||||
message.Text("今天你的群老婆是"),
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.target, 10)+"&s=640").Add("cache", 0),
|
return
|
||||||
message.Text(
|
|
||||||
"\n",
|
|
||||||
"[", targetinfo.targetname, "]",
|
|
||||||
"(", targetinfo.target, ")哒",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
default: // 嫁给别人
|
|
||||||
ctx.SendChain(
|
|
||||||
message.At(uid),
|
|
||||||
message.Text("今天你的群老公是"),
|
|
||||||
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.target, 10)+"&s=640").Add("cache", 0),
|
|
||||||
message.Text(
|
|
||||||
"\n",
|
|
||||||
"[", targetinfo.targetname, "]",
|
|
||||||
"(", targetinfo.target, ")哒",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
uid := ctx.Event.UserID
|
||||||
|
targetinfo, status, err := 民政局.查户口(gid, uid)
|
||||||
|
switch {
|
||||||
|
case status == 2:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
case status != 3 && targetinfo.Target == 0: //如果为单身贵族
|
||||||
|
ctx.SendChain(message.Text("今天你是单身贵族噢"))
|
||||||
|
return
|
||||||
|
case status == 1: // 娶过别人
|
||||||
|
ctx.SendChain(
|
||||||
|
message.At(uid),
|
||||||
|
message.Text("\n今天你已经娶过了,群老婆是"),
|
||||||
|
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.Target, 10)+"&s=640").Add("cache", 0),
|
||||||
|
message.Text(
|
||||||
|
"\n",
|
||||||
|
"[", targetinfo.Targetname, "]",
|
||||||
|
"(", targetinfo.Target, ")哒",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
case status == 0: // 嫁给别人
|
||||||
|
ctx.SendChain(
|
||||||
|
message.At(uid),
|
||||||
|
message.Text("\n今天你被娶了,群老公是"),
|
||||||
|
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, ")哒",
|
||||||
|
),
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 无缓存获取群员列表
|
// 无缓存获取群员列表
|
||||||
@ -206,25 +361,29 @@ func init() {
|
|||||||
qqgrouplist := make([]int64, 0, len(temp))
|
qqgrouplist := make([]int64, 0, len(temp))
|
||||||
for k := 0; k < len(temp); k++ {
|
for k := 0; k < len(temp); k++ {
|
||||||
usr := temp[k].Get("user_id").Int()
|
usr := temp[k].Get("user_id").Int()
|
||||||
_, _, ok := 民政局.查户口(gid, usr)
|
_, status, _ := 民政局.查户口(gid, usr)
|
||||||
if ok {
|
if status != 3 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
qqgrouplist = append(qqgrouplist, usr)
|
qqgrouplist = append(qqgrouplist, usr)
|
||||||
}
|
}
|
||||||
// 没有人(只剩自己)的时候
|
// 没有人(只剩自己)的时候
|
||||||
if len(qqgrouplist) == 0 {
|
if len(qqgrouplist) == 1 {
|
||||||
ctx.SendChain(message.Text("噢, 此时此刻你还是一只单身狗, 等待下一次情缘吧"))
|
ctx.SendChain(message.Text("~群里没有ta人是单身了哦 明天再试试叭"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 随机抽娶
|
// 随机抽娶
|
||||||
fiancee := qqgrouplist[rand.Intn(len(qqgrouplist))]
|
fiancee := qqgrouplist[rand.Intn(len(qqgrouplist))]
|
||||||
if fiancee == uid { // 如果是自己
|
if fiancee == uid { // 如果是自己
|
||||||
ctx.SendChain(message.Text("噢, 此时此刻你还是一只单身狗, 等待下一次情缘吧"))
|
ctx.SendChain(message.Text("呜...没娶到,你可以再尝试一次"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 去民政局办证
|
// 去民政局办证
|
||||||
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
err = 民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
// 请大家吃席
|
// 请大家吃席
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
message.At(uid),
|
message.At(uid),
|
||||||
@ -238,26 +397,47 @@ func init() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
// 单身技能
|
// 单身技能
|
||||||
engine.OnRegex(`^(娶|嫁)\[CQ:at,qq=(\d+)\]`, zero.OnlyGroup, checkdog).SetBlock(true).Limit(cdcheck, iscding).
|
engine.OnRegex(`^(娶|嫁)\[CQ:at,qq=(\d+)\]`, zero.OnlyGroup, getdb, checkdog).SetBlock(true).Limit(cdcheck, iscding).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
choice := ctx.State["regex_matched"].([]string)[1]
|
choice := ctx.State["regex_matched"].([]string)[1]
|
||||||
fiancee, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
fiancee, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||||
uid := ctx.Event.UserID
|
uid := ctx.Event.UserID
|
||||||
|
gid := ctx.Event.GroupID
|
||||||
if uid == fiancee { // 如果是自己
|
if uid == fiancee { // 如果是自己
|
||||||
|
switch rand.Intn(2) { //二分之一概率浪费技能
|
||||||
|
case 0:
|
||||||
ctx.SendChain(message.Text("今日获得成就:自恋狂"))
|
ctx.SendChain(message.Text("今日获得成就:自恋狂"))
|
||||||
|
default:
|
||||||
|
err := 民政局.登记(gid, uid, 0, "", "")
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text("今日获得成就:单身贵族"))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rand.Intn(2) == 0 { // 二分之一的概率表白成功
|
||||||
|
ctx.SendChain(message.Text(sendtext[1][rand.Intn(len(sendtext[1]))]))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if rand.Intn(2) == 1 { // 二分之一的概率表白成功
|
|
||||||
gid := ctx.Event.GroupID
|
|
||||||
// 去民政局登记
|
// 去民政局登记
|
||||||
var choicetext string
|
var choicetext string
|
||||||
switch choice {
|
switch choice {
|
||||||
case "娶":
|
case "娶":
|
||||||
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
err := 民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
||||||
choicetext = "今天你的群老婆是"
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
choicetext = "\n今天你的群老婆是"
|
||||||
default:
|
default:
|
||||||
民政局.登记(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
|
err := 民政局.登记(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
|
||||||
choicetext = "今天你的群老公是"
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
choicetext = "\n今天你的群老公是"
|
||||||
}
|
}
|
||||||
// 请大家吃席
|
// 请大家吃席
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
@ -271,37 +451,51 @@ func init() {
|
|||||||
"(", fiancee, ")哒",
|
"(", fiancee, ")哒",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.SendChain(message.Text(sendtext[1][rand.Intn(len(sendtext[1]))]))
|
|
||||||
})
|
})
|
||||||
// NTR技能
|
// NTR技能
|
||||||
engine.OnRegex(`^当(\[CQ:at,qq=(\d+)\] |(\d+))的小三`, zero.OnlyGroup, checkcp).SetBlock(true).Limit(cdcheck, iscding).
|
engine.OnRegex(`^当(\[CQ:at,qq=(\d+)\]\s?|(\d+))的小三`, zero.OnlyGroup, getdb, checkcp).SetBlock(true).Limit(cdcheck, iscding).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
fid := ctx.State["regex_matched"].([]string)
|
fid := ctx.State["regex_matched"].([]string)
|
||||||
fiancee, _ := strconv.ParseInt(fid[2]+fid[3], 10, 64)
|
fiancee, _ := strconv.ParseInt(fid[2]+fid[3], 10, 64)
|
||||||
|
uid := ctx.Event.UserID
|
||||||
|
if fiancee == uid {
|
||||||
|
ctx.SendChain(message.Text("今日获得成就:自我攻略"))
|
||||||
|
return
|
||||||
|
}
|
||||||
if rand.Intn(10)/4 != 0 { // 十分之三的概率NTR成功
|
if rand.Intn(10)/4 != 0 { // 十分之三的概率NTR成功
|
||||||
ctx.SendChain(message.Text("你的ntr计划失败了"))
|
ctx.SendChain(message.Text("失败了!可惜"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gid := ctx.Event.GroupID
|
gid := ctx.Event.GroupID
|
||||||
uid := ctx.Event.UserID
|
|
||||||
// 判断target是老公还是老婆
|
// 判断target是老公还是老婆
|
||||||
var choicetext string
|
var choicetext string
|
||||||
targetinfo, gender, _ := 民政局.查户口(gid, fiancee)
|
_, gender, err := 民政局.查户口(gid, fiancee)
|
||||||
switch gender {
|
switch gender {
|
||||||
case 0:
|
case 3:
|
||||||
// 让对象离婚
|
ctx.SendChain(message.Text("ta现在还是单身哦,快向ta表白吧!"))
|
||||||
民政局.离婚休妻(gid, targetinfo.target)
|
return
|
||||||
|
case 2:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
// 和对象结婚登记
|
// 和对象结婚登记
|
||||||
|
err = 民政局.复婚(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
choicetext = "老公"
|
choicetext = "老公"
|
||||||
民政局.登记(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
|
case 0:
|
||||||
default:
|
|
||||||
// 让对象离婚
|
|
||||||
民政局.离婚休夫(gid, targetinfo.target)
|
|
||||||
// 和对象结婚登记
|
// 和对象结婚登记
|
||||||
|
err = 民政局.复婚(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
choicetext = "老婆"
|
choicetext = "老婆"
|
||||||
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
|
default:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// 输出结果
|
// 输出结果
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
@ -316,13 +510,121 @@ func init() {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
engine.OnFullMatch("群老婆列表", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
engine.OnFullMatch("群老婆列表", zero.OnlyGroup, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !民政局.有登记(ctx.Event.GroupID) {
|
list, number, err := 民政局.花名册(ctx.Event.GroupID)
|
||||||
ctx.SendChain(message.Text("你群并没有任何的CP额"))
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.SendChain(message.Text(民政局.花名册(ctx, ctx.Event.GroupID)))
|
if number <= 0 {
|
||||||
|
ctx.SendChain(message.Text("今天还没有人结婚哦"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
/***********设置图片的大小和底色***********/
|
||||||
|
fontSize := 50.0
|
||||||
|
if number < 10 {
|
||||||
|
number = 10
|
||||||
|
}
|
||||||
|
canvas := gg.NewContext(1500, int(250+fontSize*float64(number)))
|
||||||
|
canvas.SetRGB(1, 1, 1) //白色
|
||||||
|
canvas.Clear()
|
||||||
|
/***********下载字体,可以注销掉***********/
|
||||||
|
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
}
|
||||||
|
/***********设置字体颜色为黑色***********/
|
||||||
|
canvas.SetRGB(0, 0, 0)
|
||||||
|
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||||
|
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize*2); err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sl, h := canvas.MeasureString("群老婆列表")
|
||||||
|
/***********绘制标题***********/
|
||||||
|
canvas.DrawString("群老婆列表", (1500-sl)/2, 160-h) //放置在中间位置
|
||||||
|
canvas.DrawString("————————————————————", 0, 250-h)
|
||||||
|
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||||
|
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, h = canvas.MeasureString("焯")
|
||||||
|
for i, info := range list {
|
||||||
|
canvas.DrawString(slicename(info[0]), 0, float64(260+50*i)-h)
|
||||||
|
canvas.DrawString("("+info[1]+")", 350, float64(260+50*i)-h)
|
||||||
|
canvas.DrawString("←→", 700, float64(260+50*i)-h)
|
||||||
|
canvas.DrawString(slicename(info[2]), 800, float64(260+50*i)-h)
|
||||||
|
canvas.DrawString("("+info[3]+")", 1150, float64(260+50*i)-h)
|
||||||
|
}
|
||||||
|
data, cl := writer.ToBytes(canvas.Image())
|
||||||
|
ctx.SendChain(message.ImageBytes(data))
|
||||||
|
cl()
|
||||||
|
})
|
||||||
|
engine.OnFullMatchGroup([]string{"闹离婚", "办离婚"}, zero.OnlyGroup, getdb).SetBlock(true).Limit(cdcheck, iscding2).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
uid := ctx.Event.UserID
|
||||||
|
gid := ctx.Event.GroupID
|
||||||
|
// 获取用户信息
|
||||||
|
info, uidstatus, err := 民政局.查户口(gid, uid)
|
||||||
|
switch uidstatus {
|
||||||
|
case 3:
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
if rand.Intn(10) != 1 { // 十分之一的概率成功
|
||||||
|
ctx.SendChain(message.Text(sendtext[3][rand.Intn(len(sendtext[3]))]))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := 民政局.离婚休妻(gid, info.Target)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(sendtext[4][0]))
|
||||||
|
case 0:
|
||||||
|
if rand.Intn(10) != 0 { // 十分之一的概率成功
|
||||||
|
ctx.SendChain(message.Text(sendtext[3][rand.Intn(len(sendtext[3]))]))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := 民政局.离婚休夫(gid, info.User)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(sendtext[4][1]))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
engine.OnRegex(`重置(所有|本群|/d+)?花名册`, zero.SuperUserPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
cmd := "ALL"
|
||||||
|
switch ctx.State["regex_matched"].([]string)[1] {
|
||||||
|
case "":
|
||||||
|
if ctx.Event.GroupID == 0 {
|
||||||
|
ctx.SendChain(message.Text("该功能只能在群组使用或者指定群组"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd = strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||||
|
case "所有":
|
||||||
|
break
|
||||||
|
case "本群":
|
||||||
|
if ctx.Event.GroupID == 0 {
|
||||||
|
ctx.SendChain(message.Text("该功能只能在群组使用或者指定群组"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd = strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||||
|
default:
|
||||||
|
cmd = ctx.State["regex_matched"].([]string)[1]
|
||||||
|
}
|
||||||
|
err := 民政局.重置(cmd)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力\n[error]", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text("重置成功"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,41 +640,57 @@ func iscding(ctx *zero.Ctx) {
|
|||||||
// 注入判断 是否为单身
|
// 注入判断 是否为单身
|
||||||
func checkdog(ctx *zero.Ctx) bool {
|
func checkdog(ctx *zero.Ctx) bool {
|
||||||
gid := ctx.Event.GroupID
|
gid := ctx.Event.GroupID
|
||||||
if !民政局.有登记(gid) {
|
updatetime, number, err := 民政局.checkupdate(gid)
|
||||||
return true // 如果没有人登记,说明全是单身
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return false
|
||||||
|
case number == 0: //没有任何记录就说明全是单身
|
||||||
|
return true
|
||||||
|
case time.Now().Format("2006/01/02") != updatetime:
|
||||||
|
if err := 民政局.重置(strconv.FormatInt(gid, 10)); err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true //重置后也全是单身
|
||||||
}
|
}
|
||||||
fiancee, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
fiancee, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("额,你的target好像不存在?"))
|
ctx.SendChain(message.Text("额,你的target好像不存在?"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 获取用户信息
|
|
||||||
uid := ctx.Event.UserID
|
uid := ctx.Event.UserID
|
||||||
uidtarget, uidstatus, ok1 := 民政局.查户口(gid, uid)
|
// 获取用户信息
|
||||||
_, fianceestatus, ok2 := 民政局.查户口(gid, fiancee)
|
uidtarget, uidstatus, err1 := 民政局.查户口(gid, uid)
|
||||||
if !ok1 && !ok2 { // 必须是两个单身
|
fianceeinfo, fianceestatus, err2 := 民政局.查户口(gid, fiancee)
|
||||||
|
if uidstatus == 2 || fianceestatus == 2 {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err1, "\n", err2))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if uidstatus == 3 && fianceestatus == 3 { // 必须是两个单身
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if ok1 {
|
switch {
|
||||||
if uidtarget.target == fiancee { // 如果本就是一块
|
case uidtarget.Target == fiancee: // 如果本就是一块
|
||||||
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
|
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
|
||||||
return false
|
return false
|
||||||
}
|
case uidstatus == 1: // 如果如为攻
|
||||||
switch uidstatus {
|
|
||||||
case 0: // 如果如为攻
|
|
||||||
ctx.SendChain(message.Text("笨蛋~你家里还有个吃白饭的w"))
|
ctx.SendChain(message.Text("笨蛋~你家里还有个吃白饭的w"))
|
||||||
default: // 如果为受
|
|
||||||
ctx.SendChain(message.Text("该是0就是0,当0有什么不好"))
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
case uidstatus == 0: // 如果为受
|
||||||
if ok2 {
|
ctx.SendChain(message.Text("该是0就是0,当0有什么不好"))
|
||||||
switch fianceestatus {
|
return false
|
||||||
case 0: // 如果如为攻
|
case uidstatus != 3 && uidtarget.Target == 0: //如果是单身贵族
|
||||||
|
ctx.SendChain(message.Text("今天的你是单身贵族噢"))
|
||||||
|
return false
|
||||||
|
case fianceestatus == 1: // 如果如为攻
|
||||||
ctx.SendChain(message.Text("他有别的女人了,你该放下了"))
|
ctx.SendChain(message.Text("他有别的女人了,你该放下了"))
|
||||||
default: // 如果为受
|
return false
|
||||||
|
case fianceestatus == 0: // 如果为受
|
||||||
ctx.SendChain(message.Text("这是一个纯爱的世界,拒绝NTR"))
|
ctx.SendChain(message.Text("这是一个纯爱的世界,拒绝NTR"))
|
||||||
}
|
return false
|
||||||
|
case fianceestatus != 3 && fianceeinfo.Target == 0:
|
||||||
|
ctx.SendChain(message.Text("今天的ta是单身贵族噢"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -380,11 +698,22 @@ func checkdog(ctx *zero.Ctx) bool {
|
|||||||
|
|
||||||
// 注入判断 是否满足小三要求
|
// 注入判断 是否满足小三要求
|
||||||
func checkcp(ctx *zero.Ctx) bool {
|
func checkcp(ctx *zero.Ctx) bool {
|
||||||
// 检查群内是否有人登记了
|
|
||||||
gid := ctx.Event.GroupID
|
gid := ctx.Event.GroupID
|
||||||
if !民政局.有登记(gid) {
|
updatetime, number, err := 民政局.checkupdate(gid)
|
||||||
ctx.SendChain(message.Text("ta无法达成你当小三的条件"))
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
return false
|
return false
|
||||||
|
case number == 0: //没有任何记录就说明全是单身
|
||||||
|
ctx.SendChain(message.Text("ta现在还是单身哦,快向ta表白吧!"))
|
||||||
|
return false
|
||||||
|
case time.Now().Format("2006/01/02") != updatetime:
|
||||||
|
if err := 民政局.重置(strconv.FormatInt(gid, 10)); err != nil {
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
} else {
|
||||||
|
ctx.SendChain(message.Text("ta现在还是单身哦,快向ta表白吧!"))
|
||||||
|
}
|
||||||
|
return false //重置后全是单身
|
||||||
}
|
}
|
||||||
// 检查target
|
// 检查target
|
||||||
fid := ctx.State["regex_matched"].([]string)
|
fid := ctx.State["regex_matched"].([]string)
|
||||||
@ -395,28 +724,41 @@ func checkcp(ctx *zero.Ctx) bool {
|
|||||||
}
|
}
|
||||||
uid := ctx.Event.UserID
|
uid := ctx.Event.UserID
|
||||||
if fiancee == uid {
|
if fiancee == uid {
|
||||||
ctx.SendChain(message.Text("自我攻略?"))
|
return true
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
// 检查用户是否登记过
|
// 检查用户是否登记过
|
||||||
userinfo, uidstatus, ok := 民政局.查户口(gid, uid)
|
userinfo, uidstatus, err := 民政局.查户口(gid, uid)
|
||||||
if ok {
|
switch {
|
||||||
if userinfo.target == fiancee { // 如果本就是一块
|
case uidstatus == 2:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return false
|
||||||
|
case userinfo.Target == fiancee: // 如果本就是一块
|
||||||
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
|
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
|
||||||
return false
|
return false
|
||||||
}
|
case uidstatus != 3 && userinfo.Target == 0: // 如果是单身贵族
|
||||||
switch uidstatus {
|
ctx.SendChain(message.Text("今天的你是单身贵族哦"))
|
||||||
case 0: // 如果如为攻
|
return false
|
||||||
ctx.SendChain(message.Text("抱歉,建国之后不支持后宫"))
|
case uidstatus == 1: // 如果如为攻
|
||||||
default: // 如果为受
|
ctx.SendChain(message.Text("打灭,不给纳小妾!"))
|
||||||
|
return false
|
||||||
|
case uidstatus == 0: // 如果为受
|
||||||
ctx.SendChain(message.Text("该是0就是0,当0有什么不好"))
|
ctx.SendChain(message.Text("该是0就是0,当0有什么不好"))
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
_, _, ok = 民政局.查户口(gid, fiancee)
|
fianceeinfo, fianceestatus, err := 民政局.查户口(gid, fiancee)
|
||||||
if !ok {
|
switch {
|
||||||
ctx.SendChain(message.Text("ta无法达成你当小三的条件"))
|
case fianceestatus == 2:
|
||||||
|
ctx.SendChain(message.Text("数据库发生问题力,请联系bot管理员\n[error]", err))
|
||||||
|
return false
|
||||||
|
case fianceestatus == 3:
|
||||||
|
ctx.SendChain(message.Text("ta现在还是单身哦,快向ta表白吧!"))
|
||||||
|
return false
|
||||||
|
case fianceeinfo.Target == 0:
|
||||||
|
ctx.SendChain(message.Text("今天的ta是单身贵族哦"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
func iscding2(ctx *zero.Ctx) {
|
||||||
|
ctx.SendChain(message.Text("打灭,禁止离婚"))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user