autofish's colorable output for windows

and non color output for daze
This commit is contained in:
Tnze
2019-07-28 19:31:51 +08:00
parent cc3789ff22
commit 708097608c
4 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"github.com/Tnze/go-mc/bot" "github.com/Tnze/go-mc/bot"
"github.com/Tnze/go-mc/chat" "github.com/Tnze/go-mc/chat"
"github.com/mattn/go-colorable"
"log" "log"
"time" "time"
) )
@ -15,6 +16,7 @@ var (
) )
func main() { func main() {
log.SetOutput(colorable.NewColorableStdout())
c = bot.NewClient() c = bot.NewClient()
//Login //Login

View File

@ -47,7 +47,7 @@ func onGameStart() error {
} }
func onChatMsg(c chat.Message, pos byte) 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 return nil
} }

5
go.mod
View File

@ -2,4 +2,7 @@ module github.com/Tnze/go-mc
go 1.12 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
)

5
go.sum
View File

@ -1,2 +1,7 @@
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= 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/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=