diff --git a/index.js b/index.js index 38e6870..d3f1203 100644 --- a/index.js +++ b/index.js @@ -8,16 +8,21 @@ var config = require('./config.json'); var chat_ids = {}; var botUsername = 'UNKNOWN'; -var options = { - webHook: { - port: config.webhook_port, - key: __dirname+'/key.pem', - cert: __dirname+'/crt.pem' - } -}; - +var options = {}; + +if (Number(config.polling)) { + options.webHook = { + port: config.webhook_port, + key: __dirname+'/key.pem', + cert: __dirname+'/crt.pem' + } + }; +} var bot = new telegram(config.token, options); -bot.setWebHook(config.webhook_prefix + config.token, __dirname+'/crt.pem'); + +if (Number(config.polling)) { + bot.setWebHook(config.webhook_prefix + config.token, __dirname+'/crt.pem'); +} function sendMessage(destination, message, retry) { if (retry === null || retry === undefined) {