diff --git a/lib/methods.js b/lib/methods.js index 6cd0c4b..143a660 100644 --- a/lib/methods.js +++ b/lib/methods.js @@ -206,10 +206,17 @@ const methods = { }, setWebhook(url, certificate) { - let args = !certificate ? [{ url }] : - [null, { url, certificate: fs.readFileSync(certificate) }]; - args.unshift('/setWebhook'); - return this.request.apply(this, args); + if (certificate) { + const form = { + url, + certificate: { + value: fs.readFileSync(certificate), + options: { filename: 'cert.pem' } + } + }; + return this.request('/setWebhook', null, form); + } + return this.request('/setWebhook', { url }); } }; diff --git a/lib/telebot.js b/lib/telebot.js index 8d8e584..4fc2c00 100644 --- a/lib/telebot.js +++ b/lib/telebot.js @@ -83,9 +83,9 @@ class TeleBot { // Set webhook if (this.webhook) { - let { url, key } = this.webhook; + let { url, cert } = this.webhook; if (url) url = `${ url }/${ this.token }`; - return this.setWebhook(url, key).then(x => { + return this.setWebhook(url, cert).then(x => { console.log(`[bot.webhook] set to "${url}"`); return webhook.call(this, this, this.webhook); }).catch(error => {