That slash shouldn't be there
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Hamcha 2019-08-22 17:23:30 +02:00
parent fdc0e326ff
commit 5e7513fd42
Signed by: Hamcha
GPG Key ID: 44AD3571EB09A39E
4 changed files with 16 additions and 6 deletions

View File

@ -1 +1,2 @@
README.md
.vscode

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vscode

1
go.mod
View File

@ -10,6 +10,7 @@ require (
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.20.0+incompatible
github.com/go-kit/kit v0.8.0
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.7 // indirect

17
main.go
View File

@ -10,6 +10,7 @@ import (
"git.fromouter.space/mcg/mlp-server-tools/draftbot"
"git.fromouter.space/hamcha/tg"
"github.com/go-kit/kit/log"
"github.com/spf13/viper"
)
@ -24,6 +25,7 @@ func checkErr(err error, msg string, args ...interface{}) {
var api *tg.Telegram
var botname string
var tgapi *tgInterface
var logger log.Logger
func main() {
viper.AutomaticEnv()
@ -55,6 +57,10 @@ func main() {
initTemplates()
logger = log.NewLogfmtLogger(os.Stderr)
logger = log.With(logger, "ts", log.DefaultTimestampUTC)
logger = log.With(logger, "caller", log.DefaultCaller)
// Ignore CA errors
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
@ -65,8 +71,9 @@ func main() {
usermap: make(map[string]int64),
}
bot := draftbot.NewDraftBot(tgapi, botname)
bot.Logger = logger
tgapi.Bind(bot)
api.HandleWebhook(bind, webhookPath, webhook)
logger.Log("err", api.HandleWebhook(bind, webhookPath, webhook))
}
func webhook(update tg.APIUpdate) {
@ -77,15 +84,15 @@ func webhook(update tg.APIUpdate) {
}
switch msg.Chat.Type {
case tg.ChatTypeGroup, tg.ChatTypeSupergroup:
if isCommand(msg, "/newdraft") {
tgapi.StartDraft(msg.Chat, msg.User)
if isCommand(msg, "newdraft") {
tgapi.NewDraft(msg.Chat, msg.User)
return
}
if isCommand(msg, "/join") {
if isCommand(msg, "join") {
tgapi.JoinDraft(msg.Chat, msg.User)
return
}
if isCommand(msg, "/begindraft") {
if isCommand(msg, "startdraft") {
tgapi.StartDraft(msg.Chat, msg.User)
return
}