add hot-reload & debugger
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1c37735dea
commit
2cd46585a8
10
.air.toml
Normal file
10
.air.toml
Normal file
@ -0,0 +1,10 @@
|
||||
root = "."
|
||||
|
||||
[build]
|
||||
exclude_regex = ["_test\\.go"]
|
||||
bin = "/usr/bin/make debug"
|
||||
cmd = "/usr/bin/make build"
|
||||
kill_delay = 0
|
||||
log = "build-errors.log"
|
||||
send_interrupt = true
|
||||
stop_on_error = true
|
@ -19,3 +19,5 @@ steps:
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- master
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,6 +22,8 @@ vendor/
|
||||
# Go workspace file
|
||||
go.work
|
||||
.idea/
|
||||
.config/
|
||||
tmp/
|
||||
|
||||
# Env files
|
||||
.env
|
||||
|
21
Makefile
21
Makefile
@ -2,20 +2,37 @@ SHELL = /bin/bash -o pipefail
|
||||
export PATH := $(shell go env GOPATH)/bin:$(PATH)
|
||||
|
||||
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
BIN=$(ROOT_DIR)/build/vegapokerbot
|
||||
BIN_NAME=vegapokerbot
|
||||
BIN=$(ROOT_DIR)/build/$(BIN_NAME)
|
||||
GO_VERSION=$(shell go version | sed -e 's/go version //')
|
||||
BIN_DIR=$(ROOT_DIR)/build
|
||||
|
||||
build: deps fmt
|
||||
@echo "> building with ${GO_VERSION}"
|
||||
ifeq ($(DEBUG), true)
|
||||
@echo "> building debug with ${GO_VERSION}"
|
||||
@CGO_ENABLED=0 go build -buildvcs=false -gcflags "all=-N -l" -tags=release -o $(BIN) .
|
||||
else
|
||||
@echo "> building release with ${GO_VERSION}"
|
||||
@CGO_ENABLED=0 go build -buildvcs=false -tags=release -o $(BIN) .
|
||||
endif
|
||||
@echo $(BIN)
|
||||
|
||||
docker:
|
||||
@docker buildx build --platform linux/amd64 --tag $CI_APP_IMAGE --file Dockerfile .
|
||||
|
||||
run:
|
||||
ifeq ($(DEBUG), true)
|
||||
@killall -s 9 dlv > /dev/null 2>&1 || true
|
||||
@killall -s 9 ${BIN_NAME} > /dev/null 2>&1 || true
|
||||
@air
|
||||
else
|
||||
@${BIN} run
|
||||
endif
|
||||
|
||||
debug:
|
||||
@echo "> starting under delve"
|
||||
@dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient --log exec ${BIN} run
|
||||
|
||||
fmt:
|
||||
@echo "> fmt"
|
||||
@gofmt -l -s -w `go list -buildvcs=false -f '{{.Dir}}' ${ROOT_DIR}/... | grep -v /vendor/`
|
||||
|
@ -1,29 +1,23 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: app
|
||||
POSTGRES_PASSWORD: app
|
||||
POSTGRES_DATABASE: app
|
||||
networks:
|
||||
- default
|
||||
|
||||
app:
|
||||
image: "gitea.neur0tx.site/neur0toxine/vegapokerbot:latest"
|
||||
networks:
|
||||
- default
|
||||
links:
|
||||
- db
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
labels:
|
||||
traefik.enable: "true"
|
||||
traefik.http.routers.vegapokerbot.rule: Host(`vegapokerbot.neur0tx.site`) && PathPrefix(`/webhook8c31c4b2d65a87b4f3a6f10f8eb166fba9a2e5dc7696bc5291a7e69641dc5c21`)
|
||||
traefik.http.routers.vegapokerbot.rule: Host(`vegapokerbot.example.com`) && PathPrefix(`/webhook`)
|
||||
traefik.http.routers.vegapokerbot.entrypoints: websecure
|
||||
traefik.http.services.vegapokerbot.loadbalancer.server.port: "3333"
|
||||
traefik.http.routers.vegapokerbot.tls: true
|
||||
traefik.http.routers.vegapokerbot.tls.certresolver: letsencrypt
|
||||
|
||||
networks:
|
||||
default:
|
||||
driver: bridge
|
||||
|
@ -22,8 +22,10 @@ services:
|
||||
- db
|
||||
environment:
|
||||
GOCACHE: /go
|
||||
DEBUG: true # Set to false to disable hot-reload & debugger.
|
||||
ports:
|
||||
- 3333:3333
|
||||
- 40000:40000
|
||||
command: make build run
|
||||
|
||||
networks:
|
||||
|
@ -30,10 +30,6 @@ func (h *MessageHandler) Handle(wh telego.Update) error {
|
||||
return group.NewPoll(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
|
||||
}
|
||||
|
||||
if util.MatchCommand("start", wh.Message) {
|
||||
return wizard.NewRegister(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
|
||||
}
|
||||
|
||||
setup, found := store.RedmineSetups.Get(wh.Message.Chat.ID)
|
||||
if found {
|
||||
return wizard.NewRedmineSetup(h.App, wh.Message.From.ID, wh.Message.Chat.ID, setup).Handle(wh)
|
||||
|
@ -8,3 +8,10 @@ import (
|
||||
func MatchCommand(command string, msg *telego.Message) bool {
|
||||
return th.CommandEqual(command)(telego.Update{Message: msg})
|
||||
}
|
||||
|
||||
func HasCommand(msg *telego.Message) bool {
|
||||
if msg == nil {
|
||||
return false
|
||||
}
|
||||
return th.CommandRegexp.MatchString(msg.Text)
|
||||
}
|
||||
|
2
internal/handler/wizard/doc.go
Normal file
2
internal/handler/wizard/doc.go
Normal file
@ -0,0 +1,2 @@
|
||||
// Package wizard contains setup wizard implementation.
|
||||
package wizard
|
@ -32,7 +32,7 @@ func init() {
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
localizers[tag.String()] = &localizer{loc: i18n.NewLocalizer(bundle, tag.String())}
|
||||
localizers[tag.String()] = &localizer{loc: i18n.NewLocalizer(bundle, tag.String()), tag: tag}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,19 @@
|
||||
package locale
|
||||
|
||||
import "github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
import (
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
type Localizer interface {
|
||||
Message(string) string
|
||||
Template(string, interface{}) string
|
||||
Tag() language.Tag
|
||||
}
|
||||
|
||||
type localizer struct {
|
||||
loc *i18n.Localizer
|
||||
tag language.Tag
|
||||
}
|
||||
|
||||
func (l *localizer) Message(str string) string {
|
||||
@ -21,3 +26,7 @@ func (l *localizer) Template(str string, tpl interface{}) string {
|
||||
TemplateData: tpl,
|
||||
})
|
||||
}
|
||||
|
||||
func (l *localizer) Tag() language.Tag {
|
||||
return l.tag
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user