mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
修改过的回复 删掉了一些ex的词汇
This commit is contained in:
parent
faf198289f
commit
aa08eb0120
38
plugin_thesaurus/chat.go
Normal file
38
plugin_thesaurus/chat.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Package thesaurus 修改过的单纯回复插件
|
||||
package thesaurus
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
|
||||
const (
|
||||
dbpath = "data/Purechat/"
|
||||
dbfile = dbpath + "kimoi_clear.json"
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("thesaurus", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: ture,
|
||||
Help: "thesaurus\n- 稍微干净一点的chat回复 删掉了一些有点ex的w((",
|
||||
})
|
||||
kimogomap = make(kimogo, 256)
|
||||
chatList = make([]string, 0, 256)
|
||||
)
|
||||
|
||||
func init() {
|
||||
initPureChatList(func() {
|
||||
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
key := ctx.MessageString()
|
||||
val := *kimogomap[key]
|
||||
text := val[rand.Intn(len(val))]
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) // 来自于 https://github.com/Kyomotoi/AnimeThesaurus 的回复 经过二次修改
|
||||
})
|
||||
})
|
||||
}
|
||||
36
plugin_thesaurus/data.go
Normal file
36
plugin_thesaurus/data.go
Normal file
@ -0,0 +1,36 @@
|
||||
package thesaurus
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
|
||||
type kimogo = map[string]*[]string
|
||||
|
||||
func initPureChatList(postinit func()) {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
data, err := file.GetLazyData(dbfile, true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal(data, &kimogomap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for k := range kimogomap {
|
||||
chatList = append(chatList, k)
|
||||
}
|
||||
logrus.Infoln("[purechat]加载", len(chatList), "条kimoi")
|
||||
postinit()
|
||||
}()
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user