mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
💩👌 make lint happy
This commit is contained in:
parent
932abcbdb6
commit
178b55ad52
@ -1,3 +1,4 @@
|
|||||||
|
// Package data 加载位于 datapath 的小作文
|
||||||
package data
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -13,6 +14,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
compo Composition
|
compo Composition
|
||||||
|
// 小作文数组
|
||||||
Array []string
|
Array []string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ func init() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载小作文
|
||||||
func LoadText() error {
|
func LoadText() error {
|
||||||
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
|
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
|
||||||
f, err := os.Open(pbfile)
|
f, err := os.Open(pbfile)
|
||||||
@ -46,6 +49,7 @@ func LoadText() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加小作文
|
||||||
func AddText(txt string) error {
|
func AddText(txt string) error {
|
||||||
if txt != "" {
|
if txt != "" {
|
||||||
compo.Array = append(compo.Array, txt)
|
compo.Array = append(compo.Array, txt)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
|
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
|
||||||
@ -27,7 +28,7 @@ func main() {
|
|||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
// optionally, resize scanner's capacity for lines over 64K, see next example
|
// optionally, resize scanner's capacity for lines over 64K, see next example
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
//fmt.Println(scanner.Text())
|
// fmt.Println(scanner.Text())
|
||||||
compo.Array = append(compo.Array, scanner.Text())
|
compo.Array = append(compo.Array, scanner.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +40,13 @@ func main() {
|
|||||||
f, err1 := os.OpenFile(os.Args[2], os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
f, err1 := os.OpenFile(os.Args[2], os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
if err1 == nil {
|
if err1 == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
f.Write(data)
|
_, err2 := f.Write(data)
|
||||||
|
if err2 == nil {
|
||||||
|
fmt.Println("成功")
|
||||||
|
} else {
|
||||||
|
panic(err2)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic(err1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user