fix: add removing webhook before start pooling

This commit is contained in:
Igor Kamyshev 2019-07-26 10:50:31 +03:00
parent 2b2e2fca03
commit b9d659efef

View File

@ -50,19 +50,22 @@ export class TelegramBot {
) )
} }
const url = `${this.sitePublicUrl}/${path}`
this.bot.telegram this.bot.telegram
.setWebhook(`${this.sitePublicUrl}/${path}`) .setWebhook(url)
.then(() => console.log('Webhook set success')) .then(() => console.log(`Webhook set success @ ${url}`))
return this.bot.webhookCallback(`/${path}`) return this.bot.webhookCallback(`/${path}`)
} }
public startPolling() { public startPolling() {
try { this.bot.telegram.deleteWebhook().then(
this.bot.startPolling() () => this.bot.startPolling(),
} catch (e) { () => {
// okay, never mind // okay, never mind
} },
)
} }
private createHandlers(): Handler[] { private createHandlers(): Handler[] {