mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
// Package curse 骂人插件(求骂,自卫)
|
|
package curse
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
zero "github.com/wdvxdr1123/ZeroBot"
|
|
"github.com/wdvxdr1123/ZeroBot/message"
|
|
|
|
fcext "github.com/FloatTech/floatbox/ctxext"
|
|
"github.com/FloatTech/floatbox/process"
|
|
sql "github.com/FloatTech/sqlite"
|
|
ctrl "github.com/FloatTech/zbpctrl"
|
|
"github.com/FloatTech/zbputils/control"
|
|
"github.com/FloatTech/zbputils/ctxext"
|
|
)
|
|
|
|
const (
|
|
minLevel = "min"
|
|
maxLevel = "max"
|
|
)
|
|
|
|
func init() {
|
|
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
|
DisableOnDefault: true,
|
|
Brief: "骂人反击",
|
|
Help: "- 骂我\n- 大力骂我",
|
|
PublicDataFolder: "Curse",
|
|
})
|
|
|
|
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
|
db = sql.New(engine.DataFolder() + "curse.db")
|
|
_, err := engine.GetLazyData("curse.db", true)
|
|
if err != nil {
|
|
ctx.SendChain(message.Text("ERROR: ", err))
|
|
return false
|
|
}
|
|
err = db.Open(time.Hour)
|
|
if err != nil {
|
|
ctx.SendChain(message.Text("ERROR: ", err))
|
|
return false
|
|
}
|
|
err = db.Create("curse", &curse{})
|
|
if err != nil {
|
|
ctx.SendChain(message.Text("ERROR: ", err))
|
|
return false
|
|
}
|
|
c, err := db.Count("curse")
|
|
if err != nil {
|
|
ctx.SendChain(message.Text("ERROR: ", err))
|
|
return false
|
|
}
|
|
logrus.Infoln("[curse]加载", c, "条骂人语录")
|
|
return true
|
|
})
|
|
|
|
engine.OnFullMatch("骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
|
process.SleepAbout1sTo2s()
|
|
text := getRandomCurseByLevel(minLevel).Text
|
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
|
})
|
|
|
|
engine.OnFullMatch("大力骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
|
process.SleepAbout1sTo2s()
|
|
text := getRandomCurseByLevel(maxLevel).Text
|
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
|
})
|
|
|
|
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe, getdb).SetBlock(true).
|
|
Handle(func(ctx *zero.Ctx) {
|
|
text := getRandomCurseByLevel(maxLevel).Text
|
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
|
})
|
|
}
|