2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-28 12:57:38 +00:00

70 Commits

Author SHA1 Message Date
GochoMugo
14f37c7181
test: Add test for TelegramBot#sendDocument() using 'fileOpts' param
References:

  * Original PR: https://github.com/yagop/node-telegram-bot-api/pull/152
  * Original Author: @evolun
2017-02-03 10:47:41 +03:00
GochoMugo
9f031a72e5
pr/272: Finish on PR 2017-01-30 13:24:15 +03:00
Anton Mironov
3263c6c253 Webhook health check endpoint 2017-01-30 12:50:22 +03:00
GochoMugo
a32259b1a1
src/telegram: Consider stream.path could not be parsed 2017-01-25 18:59:06 +03:00
GochoMugo
ef3574ee88 doc: Improve project documentation 2017-01-20 09:13:18 +03:00
GochoMugo
a9d6e93622
[telegram] Return error on trying to use Polling, WebHook together
Feature:

  Polling and WebHook are mutually exclusive. Therefore, return an
  error whenever the user tries to start polling, and the instance has
  an open webhook, or user tries to open a webhook, and the instance
  is already polling.
2017-01-11 17:06:04 +03:00
GochoMugo
0d20565bd5
[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!
2017-01-11 11:06:41 +03:00
GochoMugo
e009b60efa
[webhook] Do not rely on http.Server#listening property
Bug:

  The 'http.Server#listening' property was added in Node.js v5.7.0!
  Support the older Node.js versions!
2017-01-09 16:49:06 +03:00
GochoMugo
97c8130d93
[webhook,polling] Improve starting, stopping of webhook, polling
Feature:

  The different mechanisms of fetching updates, i.e. polling
  and webhook, have had their implementations improved:

  * the TelegramBot instance needs to create the polling and
    webhook instances once, and when necessary
  * returning promises from TelegramBot#openWebHook() and
    TelegramBot#startPolling() allows more precise control

  Also,

  * TelegramBot#initPolling() is being deprecated in favor of
    TelegramBot#startPolling() to ensure consistency (as the
    opposite action of TelegramBot#stopPolling())
2017-01-09 15:57:34 +03:00
GochoMugo
2a782fddbc
Deprecate support for Node.js v0.12
Notes:

  We are deprecating support for Node.js v0.12, to
  be removed in next major version!
2017-01-09 15:46:27 +03:00
GochoMugo
31a2376a1f
[webhook] Allow passing options to HTTPS server
Feature:

  We shall allow passing more options to the HTTP server,
  in `https.createServer()`.

  We are using a new property, `https`, to avoid any namespace
  collisions with our own options.

  `options.key`, `options.cert` and `options.pfx` are convenient
  options, in that they allow the user to provide paths to the
  corresponding files, which are read automatically,
  though synchronously!

Implementation:

  * completely backwards-compatible
  * all changes are being tested, except `options.pfx`

References:

  * Pass `ca` prop to https.createServer(): https://github.com/yagop/node-telegram-bot-api/pull/17
2017-01-07 17:58:01 +03:00
Gocho Mugo
215e0dc23b Add deleteWebHook, getWebHookInfo (#246) 2017-01-06 21:48:31 +03:00
Gocho Mugo
bc7549599e Ensure consistency of methods signatures (#245)
Bug:

  The library assumes signatures of methods to be, somewhat:

    methodName(requiredParam1, requiredParam2, form = {})

  where 'requiredParam1' ('requiredParam2', ..., 'requiredParamN')
  are parameters that MUST be provided, and
  'form' is an optional object allowing supplying any additional,
  optional parameters that the Bot API allows.

  This allows any new parameters added by Telegram to be
  readily-supported by our library.

  Also, the following have been included:

  * Corresponding tests
  * Documentation on the old, deprecated signatures
  * Console-logging the deprecation notices
2017-01-06 21:03:10 +03:00
GochoMugo
96bff10119
[test] Skip tests for TelegramBot#sendContact()
Bug:

  Please see note in test file!
2017-01-06 18:25:49 +03:00
GochoMugo
6dabdb47d8 [test] Calculate rate-limit timeout from error response
Feature:

  Instead of guessing of a proper timeout, we shall use the error
  response to calculate it. The error provides us with the number
  of milliseconds we need to wait before retrying the request.
2017-01-06 18:21:38 +03:00
GochoMugo
80a25c0e6e
[test] Place and update test options in mocha.opts file 2017-01-06 15:13:24 +03:00
GochoMugo
0cd993f3e8 [test] Fix incorrect test cases 2017-01-06 13:03:52 +03:00
GochoMugo
a7972cc6a4
[test] FIX OUR TESTS
Feature:

  Our tests are PASSING!

  NOTE:
  -----
  Before running tests, provide the environment variable,
  TEST_GAME_SHORT_NAME, whose value is the short name of a game
  created for the test bot. It is used in testing methods for
  games, such as TelegramBot#sendGame().
2017-01-02 14:37:39 +03:00
GochoMugo
db3c5c3cc3
Run test for TelegramBot#_formatSendData() on supported Node.js versions
Bug:

  The test for `TelegramBot#_formatSendData()` is only applicable on
  newer versions of Node.js (v6+) that support passing a Buffer
  representation of the path to `fs.createReadStream()`.

Fix:

  If the runtime does NOT supports passing the Buffer argument, do
  NOT run the test on it. This is safe since we are sure that
  `fs.ReadStream.path` will never be a Buffer on the runtime being
  tested.
2016-10-10 16:51:20 +03:00
Gocho Mugo
bf5ca1340b Closes #204: Fix handling fs.readStream.path if it's a buffer 2016-10-10 15:08:15 +03:00
GochoMugo
f5af2bf588
Add accompanying tests, minor fixes and updates for PR #158 2016-10-10 14:21:25 +03:00
GochoMugo
f91d426c35
Minor fixes and Docs update for PR #144 2016-10-10 13:41:28 +03:00
GochoMugo
e2eaa3c8db Add TelegramBot#getChat() method
Notes:

  Merge branch 'master' of https://github.com/serhiidmytruk/node-telegram-bot-api into pr/144

References:

  * PR #144: https://github.com/yagop/node-telegram-bot-api/pull/144
2016-10-10 13:34:00 +03:00
GochoMugo
82ee13e953 Add accompanying test for PR #133
References:

  * Test retrieved from PR #182
2016-10-10 13:25:38 +03:00
GochoMugo
618555101f
Fix test for TelegramBot#sendVenue() 2016-10-10 12:57:10 +03:00
GochoMugo
d9b2170b55
Add TelegramBot#sendVenue()
References:

  * Author: @iiroj (https://github.com/iiroj)
  * PR URL: https://github.com/yagop/node-telegram-bot-api/pull/121
2016-10-10 12:30:41 +03:00
GochoMugo
be49b69219
Fix handling fs.readStream.path if it's a buffer
Bug:

  The (private) method TelegramBot#_formatSendData(), used by public
  methods, such as TelegramBot#sendPhoto(), throws an error
  if the stream passed (fs.readStream) has the property 'path',
  being an instance of Buffer.

  For example,

    const stream = fs.createReadStream(Buffer.from('cat.png'));
    bot.sendPhoto(chatId, stream);

  Would throw an error, like

    TypeError: Path must be a string. Received <Buffer 60 62 63 64>

  This is because of this line:

    src/telegram.js:297
      fileName = URL.parse(path.basename(data.path)).pathname;

  path.basename() can not handle buffer (non-string) paths. From the
  docs, "A TypeError is thrown if path is not a string...".

Fix:

  Ensure path.basename() receives a string, by converting the buffer
  to string.

References:

  * fs.ReadStream: https://nodejs.org/docs/latest/api/fs.html#fs_class_fs_readstream
2016-10-07 19:52:00 +03:00
Conor Fennell
96adb918c1 Create a stop method #81 2016-06-21 10:48:05 +01:00
Serhii Dmytruk
cf8e90e70f getchat action 2016-06-10 12:51:10 +03:00
Iiro Jäppinen
5633aa97bd add test for the sendVenue method
This test uses the same location as the #sendLocation test, while providing info on the venue (The Village Shopping Centre).
2016-05-06 21:05:47 +03:00
Devin Doolin
a0c1d05441 Removes unnecessary done() calls in tests 2016-05-06 19:21:41 +09:00
Devin Doolin
ae7ec074be Further updates for Bots 2.0
- Adds support for callback_query-type messages
- Adds a showAlert option to answerCallbackQuery to more-closely align with the real bot API
- Adds tests for message editing functionality
- Adds a global test timeout of 10s and adds done() calls to all tests for assurance
2016-05-04 06:48:49 +09:00
Yago
d883ebe6f2 Babel compile ES2015 to ES5 for publishing, support for old NodeJS versions. JSDoc can't parse class-properties, generate lib-doc. Run tests against lib. #90 2016-03-20 20:13:47 +01:00
AVVS
83e42201ee refactor: rewrite to babel, es6 & eslint 2016-03-17 13:02:25 +03:00
Yago
34e935e81b Check update_id in TelegramBotPolling test 2016-03-13 14:29:27 +01:00
Yago
bcafbfb0ac #TelegramBotPolling test a bit clear 2016-03-13 13:44:06 +01:00
Yago
610a989e69 downloadFile test 2016-03-13 11:32:11 +01:00
Yago
385590ef3f Test video Buffer 2016-01-04 23:34:13 +01:00
Yago
f2153a7754 Throw error if Unsupported Buffer file type. Test 'should send a video from a Buffer' 2016-01-03 17:03:04 +01:00
Yago
fd4cf4e353 Tests cases for #56 2016-01-03 12:54:45 +01:00
Yago
cfd32f47bf Method bot.onText 2015-10-10 17:54:11 +02:00
Yago
bb6a0bb3ff setWebHook allow sending certificate as param. WebHook Documentation 2015-09-27 13:05:46 +02:00
Yago
6a679b5644 jshint 2015-09-27 11:18:25 +02:00
Yago
c8a4fc6917 Can't import 'del' module. Use fs.unlinkSync instead. 2015-09-26 20:29:24 +02:00
Yago
d716f27e44 Merge branch 'downloadFile' of https://github.com/universome/node-telegram-bot-api into universome-downloadFile 2015-09-26 19:49:36 +02:00
Yago
ea61696275 Merge branch 'getFileLink' of https://github.com/universome/node-telegram-bot-api into universome-getFileLink 2015-09-26 19:18:00 +02:00
Yago
e8978d4bcb Merge branch 'getFile' of https://github.com/universome/node-telegram-bot-api into universome-getFile 2015-09-26 19:12:27 +02:00
Yago
2cc46de512 How to run the tests. 2015-09-26 19:06:28 +02:00
Ivan Skorokhodov
14dbd12f68 Added downloadFile sugar method 2015-09-26 19:52:17 +03:00
Ivan Skorokhodov
6006ba4fd6 Added getFileLink method to TelegramBot and moved generating of urls to separate method _buildURL 2015-09-26 19:39:42 +03:00