✏️ 增加小作文实时反应

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 ignoretests: true
goimports: goimports:
local-prefixes: github.com/Yiwen-Chan/ZeroBot-Plugin local-prefixes: github.com/FloatTech/ZeroBot-Plugin
gocritic: gocritic:
disabled-checks: disabled-checks:

View File

@ -17,13 +17,13 @@ func init() {
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
rand.Seed(time.Now().UnixNano()) 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). zero.OnFullMatch("发大病", zero.OnlyToMe).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
// 第一行是发病 // 第一行是发病
ctx.Send(data.Array[0]) ctx.Send((*data.Array)[0])
}) })
// 增加小作文 // 增加小作文
zero.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission). zero.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).

View File

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