From 84115a7316187f3bf4f5028f8b44f326be4f36aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 1 Mar 2023 11:26:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20windows=20console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/console.go | 2 ++ main_windows.go => console/console_windows.go | 12 ++++++++++-- kanban/banner.go | 11 ++++++++--- kanban/gen/banner.go | 11 ++++++++--- main.go | 2 ++ run.bat | 2 +- run.sh | 2 +- 7 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 console/console.go rename main_windows.go => console/console_windows.go (93%) diff --git a/console/console.go b/console/console.go new file mode 100644 index 00000000..8cf28292 --- /dev/null +++ b/console/console.go @@ -0,0 +1,2 @@ +// Package console sets console's behavior on init +package console diff --git a/main_windows.go b/console/console_windows.go similarity index 93% rename from main_windows.go rename to console/console_windows.go index c6561620..ad69d123 100644 --- a/main_windows.go +++ b/console/console_windows.go @@ -1,12 +1,15 @@ -package main +package console import ( "bytes" - "golang.org/x/sys/windows" "os" "strings" + "golang.org/x/sys/windows" + "github.com/sirupsen/logrus" + + "github.com/FloatTech/ZeroBot-Plugin/kanban" ) func init() { @@ -50,6 +53,11 @@ func init() { } // windows 带颜色 log 自定义格式 logrus.SetFormatter(&LogFormat{}) + + err = windows.SetConsoleTitle("ZeroBot-Blugin " + kanban.Version + " " + kanban.Copyright) + if err != nil { + panic(err) + } } const ( diff --git a/kanban/banner.go b/kanban/banner.go index 6236e697..9852f306 100644 --- a/kanban/banner.go +++ b/kanban/banner.go @@ -1,10 +1,15 @@ +// Code generated by kanban/gen. DO NOT EDIT. + package kanban // Version ... -var Version = "v1.6.2" +var Version = "v1.7.0-beta1" + +// Copyright ... +var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-02-27 21:00:34 +0800 CST\n" + - "* Copyright © 2020 - 2023 FloatTech. All Rights Reserved.\n" + + "* Version " + Version + " - 2023-03-01 11:21:16 +0800 CST\n" + + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/kanban/gen/banner.go b/kanban/gen/banner.go index 85f2ea0d..54727979 100644 --- a/kanban/gen/banner.go +++ b/kanban/gen/banner.go @@ -10,15 +10,20 @@ import ( "time" ) -const banner = `package kanban +const banner = `// Code generated by kanban/gen. DO NOT EDIT. + +package kanban // Version ... var Version = "%s" +// Copyright ... +var Copyright = "© 2020 - %d FloatTech" + // Banner ... var Banner = "* OneBot + ZeroBot + Golang\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" ` @@ -39,7 +44,7 @@ func main() { } s := strings.Split(vartag.String(), "\n") 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 { panic(err) } diff --git a/main.go b/main.go index 3faba22c..6fe5608f 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,8 @@ import ( "github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner + _ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性 + // ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- // // ----------------------插件优先级按顺序从高到低---------------------- // // // diff --git a/run.bat b/run.bat index e34b0338..31420462 100644 --- a/run.bat +++ b/run.bat @@ -3,5 +3,5 @@ go env -w GOPROXY=https://goproxy.cn,direct go env -w GO111MODULE=auto go mod tidy ::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe -go run main.go main_windows.go +go run main.go pause diff --git a/run.sh b/run.sh index 39afee7e..a6112ad6 100644 --- a/run.sh +++ b/run.sh @@ -3,4 +3,4 @@ go env -w GOPROXY=https://goproxy.cn,direct go env -w GO111MODULE=auto go mod tidy #go build -ldflags="-s -w" -o ZeroBot-Plugin -go run main.go \ No newline at end of file +go run main.go