Skip to content

Commit

Permalink
web hook: server port
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Mar 7, 2018
1 parent 4d25c6a commit 184e140
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if (!WEB_HOOK) {
console.error('Missing WEB_HOOK env var.')
process.exit(1)
}
const PORT = process.env.PORT
if (!PORT) {
console.error('Missing PORT env var.')
process.exit(1)
}

const parseCmd = (msg) => {
if ('string' !== typeof msg.text) return null
Expand All @@ -43,7 +48,14 @@ Report this to my creator @derhuerst to help making this bot better.`
let api
if (process.env.NODE_ENV === 'production') {
console.info('using ' + WEB_HOOK + ' as web hook')
api = new Api(TOKEN, {polling: false})

const http = require('http')

const server = http.createServer()
api = new Api(TOKEN, {
polling: false,
webHook: {port: PORT}
})
api.setWebHook(WEB_HOOK)
} else {
console.info('using polling')
Expand Down

0 comments on commit 184e140

Please sign in to comment.