forked from FloatTech/ZeroBot-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix:vtb数据不用从zbp更新 * feat:独立骂人插件 * fix:修lint * feat:添加关键词 Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
- Loading branch information
1 parent
8ea64e7
commit 16e05e0
Showing
8 changed files
with
112 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Package curse 骂人插件(求骂,自卫) | ||
package curse | ||
|
||
import ( | ||
"github.com/FloatTech/ZeroBot-Plugin/control" | ||
"github.com/FloatTech/ZeroBot-Plugin/utils/process" | ||
zero "github.com/wdvxdr1123/ZeroBot" | ||
"github.com/wdvxdr1123/ZeroBot/extension/rate" | ||
"github.com/wdvxdr1123/ZeroBot/message" | ||
"time" | ||
) | ||
|
||
const ( | ||
prio = 10 | ||
minLevel = "min" | ||
maxLevel = "max" | ||
) | ||
|
||
var ( | ||
engine = control.Register("curse", &control.Options{ | ||
DisableOnDefault: false, | ||
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我\n- @bot 他妈|公交车|你妈|操|屎|去死|快死|日|逼|尼玛|艾滋|癌症|有病|戴套|啊对对对|烦你|你爹|屮|tui|cnm", | ||
}) | ||
limit = rate.NewManager(time.Minute, 30) | ||
) | ||
|
||
func init() { | ||
engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { | ||
if !limit.Load(ctx.Event.GroupID).Acquire() { | ||
return | ||
} | ||
process.SleepAbout1sTo2s() | ||
text := getRandomCurseByLevel(minLevel).Text | ||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) | ||
}) | ||
|
||
engine.OnFullMatch("大力骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { | ||
if !limit.Load(ctx.Event.GroupID).Acquire() { | ||
return | ||
} | ||
process.SleepAbout1sTo2s() | ||
text := getRandomCurseByLevel(maxLevel).Text | ||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) | ||
}) | ||
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "日", "逼", "尼玛", "艾滋", "癌症", "有病", "戴套", "啊对对对", "烦你", "你爹", "屮", "tui", "cnm"}, zero.OnlyToMe).SetBlock(true).SetPriority(prio). | ||
Handle(func(ctx *zero.Ctx) { | ||
text := getRandomCurseByLevel(maxLevel).Text | ||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package curse | ||
|
||
import ( | ||
"github.com/FloatTech/ZeroBot-Plugin/utils/file" | ||
"github.com/FloatTech/ZeroBot-Plugin/utils/process" | ||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql" | ||
"github.com/sirupsen/logrus" | ||
"os" | ||
) | ||
|
||
const ( | ||
dbpath = "data/Curse/" | ||
dbfile = dbpath + "curse.db" | ||
) | ||
|
||
var ( | ||
db = &sql.Sqlite{DBPath: dbfile} | ||
) | ||
|
||
// 加载数据库 | ||
func init() { | ||
go func() { | ||
process.SleepAbout1sTo2s() | ||
_ = os.MkdirAll(dbpath, 0755) | ||
_, err := file.GetLazyData(dbfile, false, true) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Create("curse", &curse{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
c, _ := db.Count("curse") | ||
logrus.Infoln("[curse]加载", c, "条骂人语录") | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package curse | ||
|
||
type curse struct { | ||
ID uint32 `db:"id"` | ||
Text string `db:"text"` | ||
Level string `db:"level"` | ||
} | ||
|
||
func getRandomCurseByLevel(level string) (c curse) { | ||
_ = db.Find("curse", &c, "where level = '"+level+"' ORDER BY RANDOM() limit 1") | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters