✏️ print kanban on start

This commit is contained in:
fumiama 2021-12-15 15:38:05 +08:00
parent 6e0222f5e2
commit 2a5c1ac92c

28
main.go
View File

@ -113,10 +113,25 @@ func printBanner() {
fmt.Print( fmt.Print(
"\n======================[ZeroBot-Plugin]======================", "\n======================[ZeroBot-Plugin]======================",
"\n", banner, "\n", "\n", banner, "\n",
"----------------------[ZeroBot-公告栏]----------------------",
"\n", getKanban(), "\n",
"============================================================\n", "============================================================\n",
) )
} }
func getKanban() string {
err := reg.Connect()
defer reg.Close()
if err != nil {
return err.Error()
}
text, err := reg.Get("ZeroBot-Plugin/kanban")
if err != nil {
return err.Error()
}
return text
}
func main() { func main() {
printBanner() printBanner()
// 帮助 // 帮助
@ -126,18 +141,7 @@ func main() {
}) })
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).FirstPriority(). zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
err := reg.Connect() ctx.SendChain(message.Text(getKanban()))
defer reg.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
text, err := reg.Get("ZeroBot-Plugin/kanban")
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text(text))
}) })
zero.RunAndBlock( zero.RunAndBlock(
zero.Config{ zero.Config{