1
0
Fork 0

🎨 Initialize router before setting webhook

This commit is contained in:
Maxim Lebedev 2017-11-29 19:55:53 +05:00
parent bd77128c06
commit c6face26f4
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 6 additions and 6 deletions

View File

@ -55,10 +55,6 @@ func (bot *Bot) NewWebhookChannel(
}
}
if _, err := bot.SetWebhook(params); err != nil {
log.Fatalln(err.Error())
}
channel := make(chan Update, 100)
go func() {
requiredPath := []byte(listen)
@ -69,11 +65,11 @@ func (bot *Bot) NewWebhookChannel(
dlog.Ln("Unsupported request path:", string(ctx.Path()))
return
}
dlog.Ln("Catched supported request path:", string(ctx.Path()))
var update Update
if err := json.Unmarshal(ctx.Request.Body(), &update); err != nil {
log.Fatalln(err.Error())
return
}
channel <- update
@ -88,5 +84,9 @@ func (bot *Bot) NewWebhookChannel(
}
}()
if _, err := bot.SetWebhook(params); err != nil {
log.Fatalln(err.Error())
}
return channel
}