Skip to content

Commit

Permalink
magically fix production issues 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Mar 20, 2018
1 parent 3746ab5 commit 4e4b70d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ bot.use((ctx, next) => {
})

if (process.env.NODE_ENV === 'dev') {
bot.startPolling()
console.info('using polling')

bot.telegram.deleteWebhook()
.then(() => bot.startPolling())
.catch(console.error)
} else {
console.info('using web hook')

const WEB_HOOK_HOST = process.env.WEB_HOOK_HOST
if (!WEB_HOOK_HOST) {
console.error('Missing WEB_HOOK_HOST env var.')
Expand All @@ -62,6 +68,7 @@ if (process.env.NODE_ENV === 'dev') {
process.exit(1)
}

bot.webhookReply = false
bot.telegram.setWebhook(url.format({
protocol: 'https',
host: WEB_HOOK_HOST,
Expand Down

0 comments on commit 4e4b70d

Please sign in to comment.