mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
💩👌 make lint happy
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package diana
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
@@ -71,6 +72,9 @@ func init() {
|
||||
// 增加小作文
|
||||
zero.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
addText(ctx.State["regex_matched"].([]string)[1])
|
||||
err := addText(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -23,23 +23,27 @@ func init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
loadText()
|
||||
array = compo.Array
|
||||
if loadText() == nil {
|
||||
array = compo.Array
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func loadText() {
|
||||
func loadText() error {
|
||||
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
|
||||
f, err := os.Open(pbfile)
|
||||
if err == nil {
|
||||
data, err1 := io.ReadAll(f)
|
||||
if err1 == nil {
|
||||
if len(data) > 0 {
|
||||
compo.Unmarshal(data)
|
||||
return compo.Unmarshal(data)
|
||||
}
|
||||
}
|
||||
return err1
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addText(txt string) error {
|
||||
|
||||
Reference in New Issue
Block a user