优化 windows console

This commit is contained in:
源文雨 2023-03-01 11:26:21 +08:00
parent 4dc837854b
commit 84115a7316
7 changed files with 32 additions and 10 deletions

2
console/console.go Normal file
View File

@ -0,0 +1,2 @@
// Package console sets console's behavior on init
package console

View File

@ -1,12 +1,15 @@
package main package console
import ( import (
"bytes" "bytes"
"golang.org/x/sys/windows"
"os" "os"
"strings" "strings"
"golang.org/x/sys/windows"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/kanban"
) )
func init() { func init() {
@ -50,6 +53,11 @@ func init() {
} }
// windows 带颜色 log 自定义格式 // windows 带颜色 log 自定义格式
logrus.SetFormatter(&LogFormat{}) logrus.SetFormatter(&LogFormat{})
err = windows.SetConsoleTitle("ZeroBot-Blugin " + kanban.Version + " " + kanban.Copyright)
if err != nil {
panic(err)
}
} }
const ( const (

View File

@ -1,10 +1,15 @@
// Code generated by kanban/gen. DO NOT EDIT.
package kanban package kanban
// Version ... // Version ...
var Version = "v1.6.2" var Version = "v1.7.0-beta1"
// Copyright ...
var Copyright = "© 2020 - 2023 FloatTech"
// Banner ... // Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" + var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - 2023-02-27 21:00:34 +0800 CST\n" + "* Version " + Version + " - 2023-03-01 11:21:16 +0800 CST\n" +
"* Copyright © 2020 - 2023 FloatTech. All Rights Reserved.\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin" "* Project: https://github.com/FloatTech/ZeroBot-Plugin"

View File

@ -10,15 +10,20 @@ import (
"time" "time"
) )
const banner = `package kanban const banner = `// Code generated by kanban/gen. DO NOT EDIT.
package kanban
// Version ... // Version ...
var Version = "%s" var Version = "%s"
// Copyright ...
var Copyright = "© 2020 - %d FloatTech"
// Banner ... // Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" + var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - %s\n" + "* Version " + Version + " - %s\n" +
"* Copyright © 2020 - %d FloatTech. All Rights Reserved.\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin" "* Project: https://github.com/FloatTech/ZeroBot-Plugin"
` `
@ -39,7 +44,7 @@ func main() {
} }
s := strings.Split(vartag.String(), "\n") s := strings.Split(vartag.String(), "\n")
now := time.Now() now := time.Now()
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Format(timeformat), now.Year()) _, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Year(), now.Format(timeformat))
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -14,6 +14,8 @@ import (
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner "github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner
_ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- // // ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
// ----------------------插件优先级按顺序从高到低---------------------- // // ----------------------插件优先级按顺序从高到低---------------------- //
// // // //

View File

@ -3,5 +3,5 @@ go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=auto go env -w GO111MODULE=auto
go mod tidy go mod tidy
::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe ::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe
go run main.go main_windows.go go run main.go
pause pause

2
run.sh
View File

@ -3,4 +3,4 @@ go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=auto go env -w GO111MODULE=auto
go mod tidy go mod tidy
#go build -ldflags="-s -w" -o ZeroBot-Plugin #go build -ldflags="-s -w" -o ZeroBot-Plugin
go run main.go go run main.go