From 8a4b11f92a2f15035f8184850f7348cdb52bd38c Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 20 Sep 2018 20:35:04 +0800 Subject: [PATCH] update 1. add makefile 2. modify dockerfile 3. add config twitch.bot_user --- Dockerfile | 4 +++- Makefile | 9 +++++++++ config.default.yml | 1 + module/config/config.go | 1 + module/twitch-irc/twitch-irc.go | 2 +- router/routes/routes.go | 6 +----- 6 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index fd96a95..dc0a0b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM golang:1.11-alpine3.8 as builder WORKDIR /go/src/git.trj.tw/golang/mtfosbot +RUN apk add --no-cache make git +RUN go get -u github.com/otakukaze/go-bindata/... COPY . . -RUN GOOS=linux go build -o mtfosbot . +RUN make FROM alpine:latest RUN apk add --no-cache ca-certificates diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..64f0cc4 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ + +.PHONY: clean build + +build: + go-bindata -pkg schema -ignore .git -o module/schema/static.go schema/ + GOOS=linux go build -o mtfosbot . + +clean: + rm -rf mtfosbot && go clean \ No newline at end of file diff --git a/config.default.yml b/config.default.yml index d2a76fc..94f24d4 100644 --- a/config.default.yml +++ b/config.default.yml @@ -10,6 +10,7 @@ twitch: sub_secret: '' chat_host: '' bot_oauth: '' + bot_user: '' google: api_key: '' database: diff --git a/module/config/config.go b/module/config/config.go index 5a6e8c7..f609ff5 100644 --- a/module/config/config.go +++ b/module/config/config.go @@ -25,6 +25,7 @@ type Config struct { SubSecret string `yaml:"sub_secret"` ChatHost string `yaml:"chat_host"` BotOauth string `yaml:"bot_oauth"` + BotUser string `yaml:"bot_user"` } `yaml:"twitch"` Google struct { APIKey string `yaml:"api_key"` diff --git a/module/twitch-irc/twitch-irc.go b/module/twitch-irc/twitch-irc.go index 9d91afa..cdd506c 100644 --- a/module/twitch-irc/twitch-irc.go +++ b/module/twitch-irc/twitch-irc.go @@ -33,7 +33,7 @@ func InitIRC() { ReJoin() config := irc.ClientConfig{ - Nick: "mtfos", + Nick: conf.Twitch.BotUser, Pass: conf.Twitch.BotOauth, Handler: irc.HandlerFunc(ircHandle), } diff --git a/router/routes/routes.go b/router/routes/routes.go index 4e0b642..f38bf72 100644 --- a/router/routes/routes.go +++ b/router/routes/routes.go @@ -43,12 +43,8 @@ func NewServ() *gin.Engine { // SetRoutes - set routes func SetRoutes(r *gin.Engine) { - r.NoRoute(func(c *gin.Context) { - fmt.Println("match not route") - c.String(404, "404 page not found") - }) - r.GET("/", func(c *gin.Context) { + fmt.Println("in next") c.JSON(200, gin.H{ "message": "ok", })