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

372 Commits

Author SHA1 Message Date
GochoMugo
061d11a109
[npm] Add script: mocha 2017-01-11 17:05:38 +03:00
GochoMugo
0c18cda922
[docs] Fix undocumented return value for TelegramBot#setWebHook() 2017-01-11 16:20:07 +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
6753f7befd
[telegram] Handle error when formatting formData
Bug:

  The method TelegramBot#_formatSendData() throws an error
  if the Buffer file type is NOT supported. We need to handle
  it, by returning a Promise that is reject with the originally
  thrown exception.

References:

  * PR trying to achieve the same: https://github.com/yagop/node-telegram-bot-api/pull/66
2017-01-09 16:16:01 +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
4735518116
[docs] Mention auto-deletion of webhook during polling 2017-01-09 15:56:28 +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
ddadc4569b
[npm] Revert update of deps to support Node v0.12
Bug:

  Upgrading the dependencies 'file-type' and 'babel-eslint'
  removed support for Node.js v0.12 series.

  We are intending to continue to support 0.12 until we
  reach v1.
2017-01-09 15:28:19 +03:00
GochoMugo
aaa3992a78
[webhook] Fix referencing options
Bug:

  The confusion between using 'options' (passed by caller)
  and 'this.options' (cached on the object), we were making
  the assumption 'options.https' is unchanged!

  It's references is changed already as we had earlier assigned
  'this.options' to point to 'options', thus same object.
2017-01-08 00:43:01 +03:00
GochoMugo
0174b875ff
[examples] Update examples
Feature:

  * Add example demonstrating use of inline keyboards
    and callback queries (see PR #150)
  * Use token from environment variable, if available

References:

  * PR #150 - Provided example with inline keyboard and callbacks:
    https://github.com/yagop/node-telegram-bot-api/pull/150
2017-01-07 18:30:07 +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
GochoMugo
f8667dc548
[npm] Do not update 'contributors' by default
Bug:

  The contributors tool is invoked during testing.
  It prompts for user input which freezes the CI.
  Disable it for now until we find a proper workaround
  or fix the tool!
2017-01-07 15:05:05 +03:00
GochoMugo
d54a6cd227
Fix npm script
Bug:

  The updates jsdoc2md changes its CLI API! Update
  our usage!
2017-01-07 14:26:42 +03:00
GochoMugo
9b4e1d9088
Update npm scripts 2017-01-07 12:53:32 +03:00
GochoMugo
f1b8e2d4f5
[examples] Update examples 2017-01-07 12:44:29 +03:00
GochoMugo
cc76b27cee
[maintenance] Update dependencies
Notes:

  The following dependencies have not been updated,
  as they break our tests:

  * eslint
  * eslint-config-airbnb
2017-01-07 12:05:54 +03:00
GochoMugo
487b5f4b8b
Fix ES6 syntax
Fix:

  This enables the library to be used without transpiling on
  Node 6 (current LTS).

Author: @GingerPlusPlus
2017-01-06 22:26:25 +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
Gocho Mugo
ce4dff78fa Merge PR #250: 2017, Major Changes
See https://github.com/yagop/node-telegram-bot-api/pull/250 for
details on this PR!
2017-01-06 18:43:00 +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
eba70cd3d7
[telegram] Expose TelegramBot#processUpdate()
Feature:

  We are exposing TelegramBot#processUpdate() to allow instances
  to be used, with mechanisms of fetching updates, other than
  those provided by the library.

References:

  * Example use case: https://github.com/GochoMugo/tgfancy/pull/7
2017-01-06 14:44:42 +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
84329d05b4
[lint] Fix error reported by linter 2017-01-02 14:36:39 +03:00
GochoMugo
d768749e8f
[polling] Fix stopping polling
Bug:

  TelegramBot#stopPolling() fails to clear the timeout
  that is waiting to make the next polling request.
  Thus, if the method is invoked after the timeout has
  already been set up, once the timeout fn is executed,
  another request is made, before polling is stopped in the
  '.finally()' handler of the request!
2017-01-02 14:19:52 +03:00
GochoMugo
6b4ff126f4
[telegram] Allow specifying API Base URL
Feature:

  We can now pass a custom API Base URL to
  be used during making HTTP requests. This is useful in
  proxying requests, or running tests.

  In particular, this library is (almost) ready to
  be used with PWRTelegram API (http://pwrtelegram.xyz/).
2017-01-02 14:05:10 +03:00
GochoMugo
8edd5f4c6d
[polling,webhook] Add methods controlling polling, webhook
Feature:

  For finer control over bot's polling and web-hook, the
  following methods have been added:

  * TelegramBot#isPolling()
  * TelegramBot#openWebHook()
  * TelegramBot#closeWebHook()
  * TelegramBot#hasOpenWebHook()

  Please read README.md for more information on the
  new methods.
2017-01-02 13:58:46 +03:00
GochoMugo
69b059a4d7
[webhook] Allow enabling/disabling webhook auto-open
Feature:

  Currently, if the constructor option 'options.webHook' is passed,
  the bot opens the webHook immediately! There's NO way to disable
  this behavior, which might be useful in cases such as:

  * providing custom webhook parameters without opening the webhook
    immediately

  The new boolean option, 'autoOpen', can now be used to control this
  behavior. For example,

  ```js
  const bot = new TelegramBot(token, {
    webHook: {
      autoOpen: false,
    },
  });
  ```

  If set to 'false', the bot does NOT open the web-hook immediately.
  Currently, there's NO way to open the web-hook in this case.
  I'm working on that. Expect a feature to add a method to open
  the web-hook manually!

  If not provided, its value defaults to 'true'.

Implementation:

  * Backwards-compatible: the behavior of opening the web-hook
    immediately remains, when the parameter is NOT provided.
2017-01-02 13:43:56 +03:00
GochoMugo
e2f095fc52 [polling] Allow enabling/disabling polling auto-start
Feature:

  Currently, if the constructor option 'options.polling' is
  passed, the bot begins polling immediately! There's NO
  way to disable this behavior, which might be useful in
  cases such as:

  * providing custom polling parameters without starting
    the polling immediately

  The boolean option, 'autoStart', can now be used to control this
  behavior. For example,

  ```js
  const bot = new TelegramBot(token, {
    polling: {
      autoStart: false,
    },
  });
  ```

  If set to 'false', the bot does NOT begin polling
  immediately. You'll have to use TelegramBot#initPolling().

  If not provided, its value defaults to 'true'.

Implementation:

  * Backwards-compatible: the behavior of starting polling
    immediately remains, when the parameter is NOT provided
2017-01-02 13:42:12 +03:00
GochoMugo
daab34d98d
Update codebase
Details:

  * Update documentation on constructors and methods
  * Make code more modular
  * Improve code (generally)
2017-01-02 13:04:44 +03:00
GochoMugo
4e5a493cad
v0.25.0 v0.25.0 2016-12-21 17:33:00 +03:00
GochoMugo
7f30aef7b3
[docs] Update docs on API v2.3 updates 2016-12-17 02:19:00 +03:00
Mohammed Sohail
2a4fea42d7 New Update Fields From API v2.3 (#227)
* New Update Fields

bot will now get updates about posts in channels. Added new fields channel_post and edited_channel_post to Update.
2016-12-17 02:12:55 +03:00
GochoMugo
2ff2716ca2
[docs] Add link to docs for more information 2016-11-21 12:34:29 +03:00
Alexander Tarmolov
afd2373351 Proxy extra request options (PR #178) 2016-11-21 12:25:33 +03:00
Plusb Preco
d4a5f5d16c Fix request performance issue (PR #193) 2016-11-21 12:10:18 +03:00
Gocho Mugo
75d940c473 Add simple example in README (PR #54) (#224)
* Fixes the readme with an appropriate example that doesn't crash

Addresses #45

* [docs] Use simple example in Readme

References:

  * Original PR: https://github.com/yagop/node-telegram-bot-api/pull/54

* [docs] Improve the example in the Readme
2016-11-11 16:54:04 +03:00
GochoMugo
578ad1fa13
[doc] Update doc on TelegramBot#sendContact() 2016-11-10 18:17:59 +03:00
GochoMugo
9f79ba8b3b
[pr] PR #124: Merge branch 'master' of https://github.com/Tketa/node-telegram-bot-api into pr/124 2016-11-10 18:12:30 +03:00
GochoMugo
306b492ebf
[pr] PR #169: Merge branch 'pr/169' 2016-11-10 17:33:39 +03:00
GochoMugo
2b5dfe0e84
[pr] Merge branch 'fix-debug-prints' of https://github.com/oflisback/node-telegram-bot-api into pr-169 2016-11-10 17:31:33 +03:00
Gocho Mugo
775977e564 Merge PR #213 from jishnu7/games
Feature:

* Add `getGameHighScores`
2016-11-03 18:53:17 +03:00
Gocho Mugo
8555ab64f8 Merge PR #216 from GingerPlusPlus/master
Feature:

* Add option to ignore further regexes after match is found
2016-11-03 18:51:01 +03:00
GingerPlusPlus
0fb142f6ac Added onlyFirstMatch option 2016-11-03 18:49:13 +03:00
Gocho Mugo
54e34636f9 Merge PR #211 from desunit/master
Closes issues #202 and #207.
2016-11-03 18:40:31 +03:00
Jishnu Mohan
2fa3f68d61 adding getGameHighScores 2016-10-22 16:03:50 +05:30