2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

92 Commits

Author SHA1 Message Date
GochoMugo
ab17ba2848
pkg: Drop support for Node.js v0.12, v4, v5 2017-11-16 21:18:08 +03:00
CapacitorSet
8fd243e6a8
src/telegram: Add TelegramBot#uploadStickerFile
Notes:

    * Closes PR #430

References:

    * FR: https://github.com/yagop/node-telegram-bot-api/issues/407
    * PR: https://github.com/yagop/node-telegram-bot-api/pull/430
    * PR-by: @CapacitorSet
2017-10-07 15:08:18 +03:00
CapacitorSet
a2d85b889a
src/telegram: Add TelegramBot#getStickerSet()
References:

    * FR: https://github.com/yagop/node-telegram-bot-api/issues/407
    * PR: https://github.com/yagop/node-telegram-bot-api/pull/429
    * PR-by: @CapacitorSet, @libertylocked
2017-10-07 14:50:25 +03:00
GochoMugo
ef48af49f5
src/telegram: Deprecate auto-enabling Promise cancellation
Side-effects:

  src/telegram: Allow providing custom Promise constructor

References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/319
2017-08-25 18:39:13 +03:00
GochoMugo
5f7d306f60
test: Skip tests on TelegramBot#sendVideoNote()
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/365
2017-08-06 12:22:43 +03:00
Yago
f20a7f4ee5 Uppps, fix "{" 2017-07-05 23:51:03 +02:00
Yago
0bf148adb9 Check if test are running in CI and skip invoice if so 2017-07-05 23:47:05 +02:00
Yago
e1f8fb25ec Skip sendInvoice test method 2017-07-05 23:30:14 +02:00
GochoMugo
8ed0a2dcef
test: Fix test for TelegramBot#setChatDescription()
Bug:

  We MUST ensure we update the description. If the description
  is unchanged, an error is thrown by the API.

Fix:

  Append a random number to the description.
2017-07-05 11:38:39 +03:00
GochoMugo
96b90c2d56
src/telegram: Add tests for Bot API v3.1 methods
References:

  * PR: https://github.com/yagop/node-telegram-bot-api/pull/369
  * PR-by: @kamikazechaser
  * Parent-PR: https://github.com/yagop/node-telegram-bot-api/pull/362
  * Parent-PR-by: @Lord-Protector
2017-07-05 09:09:42 +03:00
Mohammed Sohail
fe527957e0 src/telegram: Support API v3 Payments (#335)
References:

   * API v3 Payments: https://core.telegram.org/bots/payments
    * PR: https://github.com/yagop/node-telegram-bot-api/pull/335
    * PR-by: @kamikazechaser 
    * API v3 progress tracker: https://github.com/yagop/node-telegram-bot-api/issues/332
2017-05-26 17:59:22 +03:00
GochoMugo
cda9d8d597
src/telegram: Add deleteMessage method
References:

  * API deleteMessage method: https://core.telegram.org/bots/api#deleteMessage
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/324
  * PR-by: @JonasFowl
  * API v3: https://github.com/yagop/node-telegram-bot-api/issues/332
2017-05-26 16:29:02 +03:00
Mohammed Sohail
942fc4854b src/telegram: Add sendVideoNote method (#330)
References:

    * API sendVideoNote method: https://core.telegram.org/bots/api#sendvideonote
    * PR: https://github.com/yagop/node-telegram-bot-api/pull/330
    * PR-by: @kamikazechaser 
    * API v3: https://github.com/yagop/node-telegram-bot-api/issues/332
2017-05-26 16:25:34 +03:00
GochoMugo
64bbefd898
test: Fix tests for 'TelegramBot#onText()'
Bug:

  The registered listeners remain in effect even after
  the suite is completed; allowing other suites to trigger
  the listeners.

Fix:

  Perform clean-up before moving to next suite.
2017-05-13 11:34:14 +03:00
GochoMugo
11bcdd3b6a
src/telegram: Add TelegramBot#removeTextListener()
Feature:

  This is the opposite action to `TelegramBot#onText()`.
  It allows removing any previously-registered listeners.

  It is similar to `TelegramBot#removeReplyListener()`.
2017-05-13 11:28:04 +03:00
Fabio Zuber
9f3107b5ab src/telegram: reset state of global regexp (#326)
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/325
  * BR-by: @Sirius-A
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/326
  * PR-by: @Sirius-A
2017-05-13 10:53:21 +03:00
Evgeny Bondarenko
c1fc486225 src: Load transpiled code for Node 5
References:
  * Bug-Report #297: https://github.com/yagop/node-telegram-bot-api/issues/297
  * Bug-Report-by: @jehy
  * PR  #298: https://github.com/yagop/node-telegram-bot-api/pull/298
  * PR-by: @jehy
2017-03-09 17:17:03 +03:00
GochoMugo
130f6940ce
src/polling: Fix bug #284
Bug:

  During polling, deleting the already-set webhook, caused
  the `TelegramBotPolling#_getUpdates()` return an unexpected
  value.

  We expect the method to return an array (in the `.then()` clause).
  However, deleting the webhook returns its value, which is an object,
  from the method `_getUpdates()`.

Fix:

  Simply retry the polling request and return the promise.

Notes:

  Should we use recursion? I do not think so.
  Why? The chances of getting the error (having a webhook set) AGAIN
  is quite rare. And if it happens, there must be some problem with
  different instances invoking polling and webhook simultaneously.
  In that case, we wont struggle to recover from such a scenario.
  User is on their own! Isht!

References:

  * Bug report:   https://github.com/yagop/node-telegram-bot-api/issues/284
  * Reported by:  @dcparga
2017-02-10 12:40:47 +03:00
GochoMugo
9a9dfa9560
src: Minor fixes 2017-02-09 19:06:38 +03:00
Gocho Mugo
eed7c1e4d0 src: Add proper error handling (#283)
Feature:

    Please see `doc/usage.md` for more information on error-handling.
2017-02-09 16:12:22 +03:00
GochoMugo
79de62a96e
src/telegram: Add TelegramBot#removeReplyListener()
Feature:

  Please see the updated API Reference.

References:

  * Author: @githugger (Frederic Schneider <fschneider1992@gmail.com>)
  * Original PR: https://github.com/yagop/node-telegram-bot-api/pull/74
2017-02-09 15:07:08 +03:00
GochoMugo
d4a469df6b
pkg: Fix bug #275
Bug:

  Node.js v4 does not support the ES6 syntax fully, thus we
  get the error:

    Block scoped declarations (let, const, function,class) not yet
    supported outside strict mode

Fix:

  * Load transpiled code
  * Deprecate support for Node.js v4.x

References:

  * Bug report: https://github.com/yagop/node-telegram-bot-api/issues/275
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/280
  * Reported-by: @crazyabdul
  * PR-by: @crazyabdul
2017-02-08 12:16:51 +03:00
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