✏️ 增加小作文实时反应

This commit is contained in:
fumiama 2021-08-06 21:44:00 +08:00
parent 1989d4a61f
commit ef1981934b
3 changed files with 10 additions and 8 deletions

View File

@ -4,7 +4,7 @@ linters-settings:
ignoretests: true
goimports:
local-prefixes: github.com/Yiwen-Chan/ZeroBot-Plugin
local-prefixes: github.com/FloatTech/ZeroBot-Plugin
gocritic:
disabled-checks:

View File

@ -17,13 +17,13 @@ func init() {
Handle(func(ctx *zero.Ctx) {
rand.Seed(time.Now().UnixNano())
// 绕过第一行发病
ctx.SendChain(message.Text(data.Array[rand.Intn(len(data.Array)-1)+1]))
ctx.SendChain(message.Text((*data.Array)[rand.Intn(len(*data.Array)-1)+1]))
})
// 逆天
zero.OnFullMatch("发大病", zero.OnlyToMe).
Handle(func(ctx *zero.Ctx) {
// 第一行是发病
ctx.Send(data.Array[0])
ctx.Send((*data.Array)[0])
})
// 增加小作文
zero.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).

View File

@ -15,8 +15,8 @@ const (
var (
compo Composition
// Array 小作文数组
Array []string
// Array 小作文数组指针
Array = &compo.Array
)
func init() {
@ -26,10 +26,12 @@ func init() {
if err != nil {
panic(err)
}
if LoadText() == nil {
Array = compo.Array
err1 := LoadText()
if err1 == nil {
fmt.Printf("[Diana]读取%d条小作文\n", len(*Array))
} else {
fmt.Printf("[Diana]读取小作文错误:%v\n", err1)
}
fmt.Printf("[Diana]读取%d条小作文\n", len(Array))
}()
}