From 708097608c0ec644dbca1d9b8326d5e35b7a3ae3 Mon Sep 17 00:00:00 2001 From: Tnze Date: Sun, 28 Jul 2019 19:31:51 +0800 Subject: [PATCH] autofish's colorable output for windows and non color output for daze --- cmd/autofish/autofish.go | 2 ++ cmd/daze/daze.go | 2 +- go.mod | 5 ++++- go.sum | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/autofish/autofish.go b/cmd/autofish/autofish.go index 7755d93..086f83a 100644 --- a/cmd/autofish/autofish.go +++ b/cmd/autofish/autofish.go @@ -3,6 +3,7 @@ package main import ( "github.com/Tnze/go-mc/bot" "github.com/Tnze/go-mc/chat" + "github.com/mattn/go-colorable" "log" "time" ) @@ -15,6 +16,7 @@ var ( ) func main() { + log.SetOutput(colorable.NewColorableStdout()) c = bot.NewClient() //Login diff --git a/cmd/daze/daze.go b/cmd/daze/daze.go index c2e1fa7..87d230d 100644 --- a/cmd/daze/daze.go +++ b/cmd/daze/daze.go @@ -47,7 +47,7 @@ func onGameStart() error { } func onChatMsg(c chat.Message, pos byte) error { - log.Println("Chat:", c) + log.Println("Chat:", c.ClearString()) // output chat message without any format code (like color or bold) return nil } diff --git a/go.mod b/go.mod index 5bf52ac..486a813 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/Tnze/go-mc go 1.12 -require github.com/google/uuid v1.1.1 +require ( + github.com/google/uuid v1.1.1 + github.com/mattn/go-colorable v0.1.2 // indirect +) diff --git a/go.sum b/go.sum index b864886..d2859d8 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,7 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=