2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-09-02 23:35:42 +00:00

[telegram] Add constructor option, 'filepath'

Feature:

  The constructor option, 'filepath', allows us to remove
  the TelegramBot's behaviour of allowing users to pass in
  file-paths as arguments, as it involves some operations
  that might be (are) strongly against what a programmer wishes
  to achieve with the library.

  Expect this to be documented better in the near future.

Implementation:

  * Backwards compatible: The default behavior is not changed!
This commit is contained in:
GochoMugo
2017-01-11 11:06:41 +03:00
parent e009b60efa
commit 0d20565bd5
3 changed files with 18 additions and 0 deletions

View File

@@ -971,5 +971,13 @@ describe('TelegramBot', function telegramSuite() {
assert.ok(is.array(resp.photo));
});
});
it('should not accept file-paths if disallowed with constructor option', function test() {
const tgbot = new TelegramBot(TOKEN, { filepath: false });
const photo = `${__dirname}/data/photo.gif`;
return tgbot.sendPhoto(USERID, photo).catch(err => {
// TODO: check for error in a better way
assert.ok(err.response.body.indexOf('Bad Request') !== -1);
});
});
});
}); // End Telegram