2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 18:07:16 +00:00

Compare commits

...

212 Commits

Author SHA1 Message Date
danielperez9430
59b43a5355 feat: Support Telegram Bot API v9.1 2025-07-28 20:44:55 +02:00
danielperez9430
6d7adc3e12 feat: Support Telegram Bot API 9.0 2025-04-17 01:04:54 +02:00
danielperez9430
8fe6f04df2 feat: Partial Support Telegram Bot API v9.0 2025-04-16 19:38:18 +02:00
danielperez9430
074912cdb3 deps: upgrade @cypress/request
Added request to devDeps for test because @cypress/request-promise require it but not autoinstall it for the tests
2025-04-16 19:37:35 +02:00
danielperez9430
cb21b01c3a style: doc block format 2025-04-16 18:53:19 +02:00
danielperez9430
0b2662fd24 feat: Bot API v8.3 2025-04-16 15:48:03 +02:00
danielperez9430
b4effe6980 docs(Readme) 2025-04-16 11:16:46 +02:00
danielperez9430
94e61c0a10 feat: Bot API 8.1 2025-04-16 11:14:41 +02:00
Ismail Bin Mujeeb
8cff652e05
feat: save prepared inline message v8.0 (#1248)
* Add support for savePreparedInlineMessage in bot api v8.0 #1243

* run `npm run doc` command

---------

Co-authored-by: Daniel Pérez Fernández <dpefe@hotmail.es>
2025-04-16 10:54:56 +02:00
danielperez9430
01c3ea77c9 feat: Support Telegram Bot API 7.10 2025-04-16 10:07:23 +02:00
Daniel Pérez Fernández
5fd83b3243 feat: Support for sendPaidMedia 2025-04-16 01:14:46 +02:00
Melroy van den Berg
531a15e7b8
docs: Remove travis badge (#1225) 2025-04-15 13:34:12 +02:00
ivanjh
12d28f3958
fix: FatalError set reference to causing error (#1257) 2025-04-15 13:33:09 +02:00
danielperez9430
766b4344a8 🚧: Support bot api v7.9
Added:

* getStarTransactions (v7.5)
* createChatSubscriptionInviteLink (v7.9)
* editChatSubscriptionInviteLink (v7.9)
2024-09-06 00:07:16 +02:00
danielperez9430
f40b421717 feat: Support Telegram Bot API 7.4 2024-05-30 23:33:27 +02:00
Dmytro Svynarenko
e7dd42c227
fix: getChatMember #1200 (#1201) 2024-05-30 22:55:50 +02:00
danielperez9430
7e9ee42769 fix: getUserChatBoosts 2024-05-30 22:37:54 +02:00
danielperez9430
65ef0a2fcc feat: Support Telegram Bot API 7.3 2024-05-08 15:36:52 +02:00
danielperez9430
fea59f455c feat: Support Telegram Bot API 7.2 2024-05-03 20:30:33 +02:00
danielperez9430
556de8794d fix: Missing updates 2024-03-09 19:13:58 +01:00
danielperez9430
7fe501f19f feat: Support for message reaction event 2024-03-09 19:03:58 +01:00
danielperez9430
d323a3bac5 feat: support getUserChatBoosts 2024-02-21 01:20:45 +01:00
danielperez9430
515a1acdc7 feat: Telegram Bot API 7.1 2024-02-21 01:05:50 +01:00
danielperez9430
8f741b2cb6 fix: setMessageReaction 2024-02-21 00:59:45 +01:00
danielperez9430
db976c4598 fix: CopyMessages 2024-02-21 00:59:15 +01:00
danielperez9430
8df6e6583e test: CopyMessage and getMyDefaultAdministratorRights 2024-02-21 00:58:40 +01:00
danielperez9430
be25ec69d2 feat: Support forwardMessages method 2024-02-20 23:29:44 +01:00
danielperez9430
00ffca5fdd chore: Code style and order of the methods 2024-02-20 19:56:20 +01:00
Sp3rick
cceea22a93
feat: Add methods deleteMessages and copyMessages
* Added setMessageReaction method
* Added setMessageReaction method

* Added and implemented _fixReplyParameters

---------

Co-authored-by: Sp3rick <your_email@example.com>
2024-02-20 19:47:13 +01:00
許景欣
e81ec60377
feat: add copyMessages method 2024-02-16 23:40:17 +01:00
Daniel
4fa9a735bb fix: RegexExp in process messges updates 2023-11-01 12:31:54 +01:00
Daniel
5385d41f1f feat: update to v0.64.0 version 2023-10-25 12:41:41 +02:00
Daniel Pérez Fernández
12d4d25af4
deps: Change request to @cypress/request (#1145) 2023-10-25 12:31:46 +02:00
Daniel
f17e801b8a docs: revokeChatInviteLink 2023-10-24 11:25:43 +02:00
Daniel Pérez Fernández
595cdbd0c6
feat: Telegram Bot API 6.8 support (#1113)
* feat: Telegram Bot API 6.8 support

* chore: telegramWebHook file format
2023-08-23 01:07:17 +02:00
Ilya Khrustalev
dfe24a4d38
docs: update api.md for setWebHook (fix #1083) (#1084) 2023-08-23 00:57:17 +02:00
Daniel Pérez Fernández
542002ec0d
feat: Telegram Bot API Support 6.6 + 6.7 [WIP] (#1069)
* feat: Telegram Bot API Support

* refactor: uploadStickerFile

* feat: Support Telegram Bot API v6.7

* fix: tests

* feat: Test for deleteStickerSet
2023-08-23 00:49:09 +02:00
Yago
2885db0e31
Merge pull request #1094 from kaiserdj/patch-1
docs: Update group link
2023-06-19 11:45:07 +09:00
Kaiserdj™
ad2b8c2ce1
docs: Update group link 2023-06-09 21:37:52 +02:00
Daniel
4ec6a68840 docs: Update group link 2023-06-07 15:36:22 +02:00
Karl-Heinz Wind
ab0eb183ad
fix: Handle rejected when open a webhook in a port that was already in use
Co-authored-by: windka <karl-heinz.wind.external@trumpf.com>
2023-05-03 10:32:25 +02:00
Dmitry Vyazin
c4164a21ce
docs: Update README 2023-05-03 10:29:58 +02:00
agoudbg
6077f9ba10
docs: update api.md for createNewStickerSet (#1043)
* fix: createNewStickerSet description error

* docs: Update api.md
2023-01-31 01:17:55 +01:00
Dmitry Vyazin
41f493ba82
docs: update README.md (#1044) 2023-01-31 01:17:06 +01:00
Daniel
53b5565e8a fix: remove try catch in _fixAddFileThumb 2022-12-31 14:07:51 +01:00
Daniel Pérez Fernández
58261d1be3
feat: Telegram Bot API 6.4 Support (#1040)
* feat: Telegram Bot API 6.4

* fix: Add Thumb sendVideo/...

* docs: Regenerate

* fix: set/get mycommands and suggested tip amounts
2022-12-30 20:47:36 +01:00
Yurii Hrom
4ef4fe9ba9
Update incorrect link in tutorials.md (#1027) 2022-11-19 17:52:25 +03:00
Daniel Pérez Fernández
ab5928669b
feat: Telegram Bot API v6.3 (#1020)
* feat: Telegram Topics

* update docs

* fix: test

* update: docs
2022-11-06 02:54:23 +01:00
Antonio Hernández
0eb8b8032f
fix: Parse entities when sending request (#1013) 2022-11-06 00:15:24 +01:00
Daniel Pérez Fernández
ccdd14670b
docs: Fix readme with correct link to api docs 2022-09-26 19:44:05 +02:00
Daniel Pérez Fernández
d85370452a
fix: Changelog 2022-08-29 10:22:39 +02:00
SerKo
22d99fd91d
docs: update @types install note (#999) 2022-08-24 17:11:22 +03:00
Daniel Pérez Fernández
fe4afd6533
feat: Support Bot API v6.2 (#996)
* docs: Update readme and add Typescript types

* feat: getCustomEmojiStickers

* feat: Add getCustomEmojiStickers test + fix other test

* fix: docs

* docs: Update changelog + docs
2022-08-15 21:44:44 +02:00
Tinsae
c9b05e7996
feat: Support test enviroment (#994)
* Added a support for testing enviroment

* Added annotation for testing enviroment and run doc

Co-authored-by: Mohamed Sohail <sohailsameja@gmail.com>
2022-08-15 01:00:41 +02:00
Daniel Pérez Fernández
f50cf982c7
Hotfix: tests + modify order src/telegram + docs (#988)
* test: stopPoll

* test: setChatStickerSet and deleteChatStickerSet

* refactor: src/telegram.js

* Remove legacy methods:
 - getChatMembersCount
 - getChatMembersCount
 - kickChatMember

* Remove mandatory param  “start_parameter” from sendInvoice, because actually is a optional param

* docs: Update docs API

* docs: Update

* fix: addStickerToSet

* fix: stringify

* refactor: And add deleteStickerFromSet + setStickerPositionInSet

* fix: eslint

* docs: Update changelog
2022-07-19 12:43:39 +02:00
Daniel Pérez Fernández
449f03f786
feat: Remove bluebird + depd (#987)
* feat: Remove bluebird

* docs: Update

* remove depd ans use node native deprecate msg warnings

* fix: correct util import name

* remove: contributor dev dependencie and add list of contributors in the readme
2022-07-18 08:41:31 +02:00
Daniel Pérez Fernández
d28875154c
feat: Telegram Bot API 6.1 and bug fixes (#977)
## [0.58.0][0.58.0] - 2022-06-22

1. Support Bot API v6.1: (@danielperez9430)
   * Add method *createInvoiceLink()*

2. Support for setStickerSetThumb (@elihaidv)

3. Add new test (@danielperez9430)
   * createInvoiceLink

4. Test fixes (@danielperez9430)
   * sendVideoNote
   * createNewStickerSet
   * setStickerSetThumb
   * getChatMenuButton
   * setWebHook

5. Bug fixes (@danielperez9430)
   * answerWebAppQuery
   * Support for send thumb in sendAudio
2022-06-22 21:11:16 +02:00
Lawrence Onah
f97cad7588
Update README.md (#978) 2022-06-21 21:29:24 +02:00
Daniel Pérez Fernández
6ad9115fb1
Merge pull request #846 from elihaidv/master
setStickerSetThumb function added
2022-06-03 23:28:43 +02:00
Yago
72feca3d02
Merge pull request #966 from danielperez9430/master
Support for Telegram Bot API 6.0
2022-04-24 22:19:44 +02:00
danielperez9430
280a58c0e2 Support for Telegram Bot API 6.0
* Add method *setChatMenuButton()*
   * Add method *getChatMenuButton()*
   * Add method *setMyDefaultAdministratorRights()*
   * Add method *getMyDefaultAdministratorRights()*
   * Add method *answerWebAppQuery()*
   * Renamed the fields voice_chat_scheduled, voice_chat_started, voice_chat_ended, and voice_chat_participants_invited to video_chat_scheduled, video_chat_started, video_chat_ended, and video_chat_participants_invited

   Tests:

   * answerWebAppQuery
   * setChatMenuButton
   * getChatMenuButton
   * setMyDefaultAdministratorRights
   * getMyDefaultAdministratorRights
2022-04-23 01:01:34 +02:00
Antonio Hernández
0f33cb5ab7
doc: added missing documentation related to events (#938) 2022-02-06 20:14:29 +03:00
Yago
e114682f2e
Merge pull request #922 from danielperez9430/master
Telegram Bot API 5.5 Support
2021-12-10 02:13:56 +01:00
danielperez9430
1a7f41c930 docs: Generate new docs 2021-12-09 02:27:50 +01:00
danielperez9430
c6cb87ec12 fix: Bug with docs 2021-12-09 02:27:38 +01:00
danielperez9430
bbbc6cb8b8 feat: Support Telegram Bot API 5.5 2021-12-07 16:43:16 +01:00
danielperez9430
5ff22148d8 feat: banChatSenderChat and unbanChatSenderChat methods 2021-12-07 16:42:00 +01:00
danielperez9430
19b5fc5bd3 fix(Test): Update test for new chat invite link format 2021-12-07 16:41:35 +01:00
Yago
68ac69cf99
Merge pull request #912 from danielperez9430/master
Support for Telegram Bot API 5.4
2021-11-07 20:33:48 +01:00
Daniel Pérez Fernández
e119612b5f docs(Changelog) 2021-11-07 18:56:42 +01:00
Daniel Pérez Fernández
b9e8675736 fix: editMessageMedia - Now you can send a local file 2021-11-07 18:55:14 +01:00
Daniel Pérez Fernández
d87e8d258d chore: Update package.json version to 0.55.0 2021-11-07 16:08:57 +01:00
Daniel Pérez Fernández
a1e73481db docs: Update changelod and readme 2021-11-07 16:08:22 +01:00
Daniel Pérez Fernández
6c0f2e73c0 feat: Add support for new event "chat_join_request" 2021-11-07 16:07:50 +01:00
Daniel Pérez Fernández
15c878ea89 docs: Update api.md 2021-11-07 16:07:21 +01:00
Daniel Pérez Fernández
b60f065a83 feat: Add new method "approveChatJoinRequest" and "declineChatJoinRequest" 2021-11-07 16:06:51 +01:00
Daniel Pérez Fernández
921cb65fce docs: Update api.md 2021-11-07 16:06:04 +01:00
Alexander Cerutti
5cc6629ca0
Removed deprecated node-telegram-operations-manager from list (#896)
* Removed deprecated node-telegram-operations-manager from list

* Fixed repeated words
2021-08-12 21:19:34 +03:00
Yago Perez
2416679cee 0.54.0 2021-07-21 22:01:08 +02:00
Daniel Pérez Fernández
5a4787884e
Telegram Bot API v5.3 Support (#886)
* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test

* Add unpinAllChatMessages Support

* Add copyMessage support

* Add close and logOut Support

* Add Test + Minor fixes

* Update CHANGELOG

Update version 0.50.1

* Update Readme Bot API Badge

* Update Version to 0.51.0

* Bot API 5.1 support Improved Invite Links

- Added the method createChatInviteLink
- Added the method editChatInviteLink
- Added the method revokeChatInviteLink

* Update version to 0.52.0 and new tests

- Update Changelog
- New Test
- Update version to 0.52.0

* Add new messageTypes

-  voice_chat_started
-  voice_chat_ended
- voice_chat_participants_invited

* Update Changelog and add new MessageType

* New messageTypes and updates

Add support for new messageTypes:
  - chat_invite_link
  - chat_member_updated

Add support for new updates:
 - my_chat_member
 - chat_member

* Telegram Bot API 5.2 Support

* Update Changelog + readme

* Fix Changelog

* Telegram Bot API v5.3

Add new methods:
* deleteMyCommands
* banChatMember
* getChatMemberCount

Deprecated:
 * Method kickChatMember()
 * Method getChatMembersCount()

New Test:
  * deleteMyCommands
  * banChatMember
  * getChatMemberCount

* docs: gen on linux

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
2021-06-29 11:38:33 +03:00
Yago Perez
2c06bc3b3d 0.53.0 2021-04-29 23:59:11 +02:00
Daniel Pérez Fernández
e6938f81eb
Telegram Bot API 5.2 Support (#870)
* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test

* Add unpinAllChatMessages Support

* Add copyMessage support

* Add close and logOut Support

* Add Test + Minor fixes

* Update CHANGELOG

Update version 0.50.1

* Update Readme Bot API Badge

* Update Version to 0.51.0

* Bot API 5.1 support Improved Invite Links

- Added the method createChatInviteLink
- Added the method editChatInviteLink
- Added the method revokeChatInviteLink

* Update version to 0.52.0 and new tests

- Update Changelog
- New Test
- Update version to 0.52.0

* Add new messageTypes

-  voice_chat_started
-  voice_chat_ended
- voice_chat_participants_invited

* Update Changelog and add new MessageType

* New messageTypes and updates

Add support for new messageTypes:
  - chat_invite_link
  - chat_member_updated

Add support for new updates:
 - my_chat_member
 - chat_member

* Telegram Bot API 5.2 Support

* Update Changelog + readme

* Fix Changelog
2021-04-26 19:50:34 +03:00
Daniel Pérez Fernández
de76dcd2cb
Bot API 5.1: Support Improved Invite Links and new messageTypes (#859)
* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test

* Add unpinAllChatMessages Support

* Add copyMessage support

* Add close and logOut Support

* Add Test + Minor fixes

* Update CHANGELOG

Update version 0.50.1

* Update Readme Bot API Badge

* Update Version to 0.51.0

* Bot API 5.1 support Improved Invite Links

- Added the method createChatInviteLink
- Added the method editChatInviteLink
- Added the method revokeChatInviteLink

* Update version to 0.52.0 and new tests

- Update Changelog
- New Test
- Update version to 0.52.0

* Add new messageTypes

-  voice_chat_started
-  voice_chat_ended
- voice_chat_participants_invited

* Update Changelog and add new MessageType

* New messageTypes and updates

Add support for new messageTypes:
  - chat_invite_link
  - chat_member_updated

Add support for new updates:
 - my_chat_member
 - chat_member
2021-03-29 17:37:10 +03:00
elihaidv
7738677b45
setStickerSetThumb function added
https://core.telegram.org/bots/api#setstickersetthumb

Now you can add thumb image to the sticker set
2020-12-28 18:47:38 +02:00
Mohammed Sohail
28cd62e355
doc: add clear listener methods 2020-12-10 14:40:37 +03:00
Daniel Huber
ec7e61e041
feat: add clear listener methods (#834)
- by @daniel0611

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
2020-12-10 14:30:09 +03:00
砂糖梨子
3829e727aa
fix: send animation (#843)
-required param is 'animation'
2020-12-10 13:51:52 +03:00
Daniel Pérez Fernández
5d30b6a134
Telegram Bot API 5.0 Support (#835)
* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test

* Add unpinAllChatMessages Support

* Add copyMessage support

* Add close and logOut Support

* Add Test + Minor fixes

* Update CHANGELOG

Update version 0.50.1

* Update Readme Bot API Badge

* Update Version to 0.51.0
2020-12-10 13:47:22 +03:00
Leonardo Bloise (Blusa)
fc24d0dc4d
[Docs] How to set webhooks using express local server and NGROK (#824)
It's a guide to help new people how to set webhooks and test their bots using local server.
2020-09-16 18:20:56 +05:30
Davide Pastore
167e52c04a
[security] bump bl package to minver
- Related to https://github.com/advisories/GHSA-pp7h-53gx-mx7r
2020-09-16 18:17:43 +05:30
Mohammed Sohail
93eaad082c
test: update removeTextListener 2020-05-12 12:42:44 +05:30
Mohammed Sohail
917c20c2c7
release: v0.50.0 2020-05-12 11:58:32 +05:30
Igor
7643551adc
Fix catch error while file not able download (#737) 2020-05-12 09:59:29 +05:30
German Smirnov
d853a18079
fix regexp compare (#783)
* fix regexp compare

* npm run doc

* docs: fix

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
2020-05-12 09:50:52 +05:30
pyg
b4309cf45a
src/telegram: Add request options in getFileStream (#771)
Here it's request unable to use proxy options
2020-05-12 09:39:17 +05:30
Ilan
1ca5e2b967
Update tutorials.md (#803) 2020-05-12 09:38:17 +05:30
Daniel Pérez Fernández
1bae9c2964
Add new method sendDice, getMyCommands, setMyCommands and more (#796)
* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test
2020-05-12 09:31:30 +05:30
Mohamed Nainar
c6a0eedc9a
Update README.md (#790) 2020-04-30 20:54:29 +05:30
Melroy van den Berg
8bf57c1275
example: update express example
bodyParser is built-in again. (#791)

See: https://stackoverflow.com/questions/47232187/express-json-vs-bodyparser-json/47232318
2020-04-30 20:52:00 +05:30
lgy
5169d79bd9 docs: add proxy usage reference
-refs: #766 
-by @97thjingba
2020-01-20 16:38:42 +05:30
Mohammed Sohail
667380f1de
test: skip sendContact
- rate limits still apply
2019-10-15 21:50:06 +05:30
Mohammed Sohail
5553ceecbb
release: tidy up
- remove appveyor badge
- restrict builds to main versions of node
- add npm badge
2019-10-15 21:38:49 +05:30
Mohammed Sohail
e66243a776
[Docs] Update documentation (#753)
* doc: update readme.md
2019-10-15 20:51:07 +05:30
Mohammed Sohail
1f1e46e01b
test: skip stopMessageLiveLocation
- unexplicable error that is probabilistic in natuu
2019-10-15 20:19:44 +05:30
Mohammed Sohail
690c26faa2
[Package] Bump to v.0.40.0 (#752)
* doc: update changelog

- support for v4. to v4.2

* doc: update license date to 2019

* pkg: bump npm package to 0.40.0
2019-10-15 15:33:30 +05:30
Mohammed Sohail
0613a1bb08
test: temporarily disable pr builds
ref: https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
2019-10-15 15:16:08 +05:30
Mohammed Sohail
7feb88464d
test: update test suite
- remove unecessary tests for node v5 and below
- fix tg side errors when running tests i.e. currency format
- enable force builds on pr
2019-10-15 15:03:20 +05:30
GochoMugo
a0aa87329f
test: Run tests on Node.js v10, v12 2019-05-07 16:25:27 +03:00
Gocho Mugo
0b8ca03b54
chore/mr: Merge MR #720 2019-05-07 16:23:25 +03:00
Mohammed Sohail
f1a044e88e
src: Support Bot API v4.2 2019-05-07 16:17:43 +03:00
Mohammed Sohail
0b476fe35d
Merge pull request #678 from alexandercerutti/master
Added node-telegram-operation-manager to community field
2018-11-05 11:31:05 +05:30
Alexander Cerutti
cf28a17654
Added node-telegram-operation-manager to community field 2018-11-04 23:34:18 +01:00
Sedric Heidarizarei
8a51b70028 Copyright Updated (#658)
* Update README/LICENSE.md

- Year to 2018
2018-11-02 11:12:25 +05:30
Mohammed Sohail
d6f5639768
Update badges (#667)
* Update README badges

- Update badge to reflect the current update (#625)
- Fix broken BitHound badge

* Update badges

- Replace coveralls with codecov
- Add new appveyor badge

* Fix minor typo
2018-11-02 11:09:48 +05:30
Mohammed Sohail Sameja
47bea20539
[Tests] Update
- Set max-len at 200
- Fix eslint errors
2018-10-31 21:34:24 +05:30
Mohammed Sohail
29e0038bf3
Merge pull request #627 from vito2005/patch-1
one more tutorial for node-telegram-bot-api

by @vito2005
2018-10-31 16:24:42 +05:30
Yago
d70442d746
Merge pull request #613 from mashed-potatoes/master
Remove bitHound Score
2018-10-30 22:52:20 +01:00
Yago
6e46f48606
Merge pull request #671 from kamikazechaser/fix/v4
[v4.0] Add tests and add minor improvement
2018-10-30 22:45:08 +01:00
Mohammed Sohail Sameja
6a7c088a63
[v4.0] Add tests and add minor improvement
Follow up update to #625

 - Tests for both methods (sendAnimation, editMediaMessage) have been
 added. editMediaMessage is nested under sendAnimation, hence both tests
 are technically under a single block.

- Add an improvement/minor fix to the editMediaMessage method, where we
now stringify the first parameter (media) object interally within the
library. This allows the lib user to simply pass an object as the 1st
param without stringifying it.
2018-10-26 15:03:52 +05:30
Yago
11a6b221e9
Merge pull request #636 from sinchang-bot/patch-1
doc: fix typo
2018-10-12 12:01:04 +02:00
Yago
42b31fbc9e
Merge pull request #625 from kamikazechaser/api-v4
[API v4.0] Publish new methods and message types
2018-10-12 11:58:46 +02:00
Jeff Wen
ca7eee8b0c
doc: fix typo 2018-09-04 16:55:51 +08:00
vito2005
e207ef665b
one more tutorial for node-telegram-bot-api
using your module the bot can send sms templates
2018-08-10 12:01:44 +03:00
Mohammed Sohail
cca75ec92a
Add documentation 2018-08-01 22:50:53 +05:30
Mohammed Sohail
fadf738da4
Add passport_data message type
Reference: Telegram API Documentation: https://core.telegram.org/bots/api#message
2018-08-01 22:31:43 +05:30
Mohammed Sohail
8b99ccb75c
Add sendAnimation method
Reference: Telegram API Documentation: https://core.telegram.org/bots/api#sendanimation
2018-08-01 22:29:09 +05:30
Mohammed Sohail
2d3421905c
Add animation message type
References: Telegram API Documentation: https://core.telegram.org/bots/api#message
2018-08-01 22:20:47 +05:30
Mohammed Sohail
67c738b0d3
Add editMessageMedia method
Reference: Telegram API Documentation: https://core.telegram.org/bots/api#editmessagemedia
2018-08-01 22:15:05 +05:30
mashed-potatoes
8ef560160c
Remove bitHound Score 2018-07-09 05:59:15 +05:00
Alexander Cerutti
b585957a0a doc: Add telegram-keyboard-wrapper to community section (#529)
pr-by: @alexandercerutti
2018-05-15 09:10:43 +03:00
Daniel Pérez Fernández
8b7d10e01b doc: Add link to tutorial [ES] (#545)
pr-by: @danielperez9430
2018-05-14 09:42:45 +03:00
Gocho Mugo
1224613fec
doc: Add link to tutorial (#533)
pr-by: https://github.com/neet
2018-05-14 09:35:01 +03:00
Gocho Mugo
0461c0bfe3
doc: Add missing full stop (#515) 2018-05-14 09:32:02 +03:00
Neetshin
71fbad31d9 Update tutorial articles link 2018-02-27 14:18:39 +05:30
Benny Neugebauer
091ef7a8a7
doc: Add missing full stop 2018-02-04 00:12:44 +01:00
Oleksandr Tryshchenko
435f06319e doc: Fixed type annotations for message id parameter (#491)
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/490
2018-01-11 12:21:14 +03:00
GochoMugo
119d892c34
release: v0.30.0 2017-12-21 14:32:33 +03:00
GochoMugo
1169f8e430
chore: Use npm script prepublishOnly instead of deprecated prepublish 2017-12-21 14:16:17 +03:00
GochoMugo
5cecffc34b
chore/deps: Downgrade eslint for Node v4 compatibility 2017-12-21 14:15:19 +03:00
GochoMugo
7e9e9b11b3
test: Fix previously-uncaught lint errors 2017-12-21 12:45:34 +03:00
GochoMugo
2bdd50fdc2
chore/deps: Update dependencies
Notes:

  Kept-back:
  ---------
  1. eslint-config-airbnb
  2. file-type
  3. istanbul
  4. mime
  5. mocha
2017-12-21 12:43:56 +03:00
GochoMugo
309696622d
doc: Showcase and update contributor list 2017-12-20 13:48:29 +03:00
GochoMugo
1f4c79ec8e
chore: Ignore package lock file 2017-12-20 12:41:03 +03:00
GochoMugo
8edf1fbc6d
doc: Update changelog 2017-12-20 12:28:11 +03:00
GochoMugo
55332c3c25
doc: Update changelog, version badge 2017-12-20 12:22:30 +03:00
GochoMugo
96c50ba1bd
doc: Improve deprecation messages 2017-12-20 12:12:01 +03:00
GochoMugo
4358f20dbb
doc: Minor fixes on documentation 2017-12-20 12:02:09 +03:00
GochoMugo
0781ae685d
src/telegram: Add TelegramBot#sendMediaGroup()
References:

  * Telegram API documentation: https://core.telegram.org/bots/api#sendmediagroup
2017-12-20 11:59:39 +03:00
Oleg
584610baaf doc: Add tutorial [RUS] (#477) 2017-12-20 11:07:40 +03:00
GochoMugo
1a08221174
src/telegram: Improve sending files (#471)
References:

  * PR: https://github.com/yagop/node-telegram-bot-api/pull/471
2017-12-20 11:03:00 +03:00
GochoMugo
d7197998dd
doc: Add note on specifying additional Telegram query options 2017-12-11 18:32:19 +03:00
GochoMugo
4051117ed0
src: Minor reorganisation, fixes 2017-12-11 18:24:22 +03:00
GochoMugo
f28416fbaf
src/telegram: Implement downloadFile() in terms of getFileStream() 2017-12-08 19:37:12 +03:00
GochoMugo
04e8b892aa
src/telegram: Emit 'info' on stream from TelegramBot#getFileStream() 2017-12-08 19:25:56 +03:00
GochoMugo
b968e893d3
src/telegram: Populate Stream#path from TelegramBot#getFileStream() 2017-12-08 19:18:55 +03:00
GochoMugo
b91409a2b6
test: Fix path to ssl key, cert 2017-12-07 13:05:48 +03:00
GochoMugo
455a93cacb
examples: Add notice of openshift 2 shutdown
References:

  * Issue: https://github.com/yagop/node-telegram-bot-api/issues/426
2017-12-07 12:35:37 +03:00
GochoMugo
17f839498e
chore: Re-organise examples 2017-12-07 12:30:44 +03:00
GochoMugo
d9692f45a9
src/telegram: Add TelegramBot#getFileStream()
References:

  * FR: https://github.com/yagop/node-telegram-bot-api/issues/442
2017-12-07 12:04:46 +03:00
Gocho Mugo
0870684d83
src/polling: Fix the Offset Infinite Loop bug (#265)
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/36
2017-12-05 15:18:18 +03:00
GochoMugo
8edb687283
src: Add fileOptions to remaining file-sending methods 2017-12-05 14:30:45 +03:00
GochoMugo
3b603b1dbd
src: Minor fix, complete TODO 2017-12-05 13:59:32 +03:00
GochoMugo
b774ff436f src: Minor fixes 2017-12-05 13:56:07 +03:00
GochoMugo
d6083e4327 src: Support file options, defaults in sending files 2017-12-05 13:39:17 +03:00
GochoMugo
fb1f4344b3
test: Disable tests on Node.js v0.12
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/365
2017-12-05 13:18:11 +03:00
GochoMugo
b1f0ebaf17
src/polling: Add options to TelegramBot#stopPolling()
Feature:

  * Simply, pass through options to TelegramBot#stopPolling(options)
    to TelegramBotPolling#stop(options)

References:

  * Related PR: https://github.com/yagop/node-telegram-bot-api/pull/456
2017-12-05 13:13:48 +03:00
GochoMugo
ce9ff57a63
src/telegram: Don't JSON-serialize parameter if already of String type 2017-11-27 08:51:54 +03:00
GochoMugo
012e7df35f
src: Support API v3.5 provider_data parameter 2017-11-27 08:15:41 +03:00
GochoMugo
57dec19bab
src: Support future additional Telegram parameters
References:

  * FR: https://github.com/yagop/node-telegram-bot-api/issues/454
2017-11-27 07:54:01 +03:00
GochoMugo
fce9244dfd
doc: Update help information
References:

  * Issue #219: https://github.com/yagop/node-telegram-bot-api/issues/219
  * Issue #273: https://github.com/yagop/node-telegram-bot-api/issues/273
  * Issue #304: https://github.com/yagop/node-telegram-bot-api/issues/304
2017-11-27 07:11:26 +03:00
GochoMugo
0008a39227 pr: Merge edited PR (#440) 2017-11-27 06:49:47 +03:00
GochoMugo
183b6bdb28
doc: Generate API reference, Update changelog 2017-11-27 06:48:22 +03:00
GochoMugo
816511b19f pr: Merge kamikazechaser/node-telegram-bot-api#feature/stickersets 2017-11-27 06:45:58 +03:00
GochoMugo
cfde217488
test: Fix lint error 2017-11-27 06:37:04 +03:00
GochoMugo
13472899e4 pr: Merge edited PR (#439) 2017-11-27 06:35:45 +03:00
GochoMugo
59378d381b
test: Add tests 2017-11-27 06:33:59 +03:00
GochoMugo
79118b9fae
doc: Minor fixes, Update changelog 2017-11-27 05:50:41 +03:00
GochoMugo
65384a11d4
pr: Merge kamikazechaser/node-telegram-bot-api#feature/livelocations 2017-11-27 05:41:22 +03:00
GochoMugo
1f61b82aa8
doc: Fix documented types for params chatId, userId
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/300
2017-11-27 05:25:53 +03:00
GochoMugo
633bd83a0a
src/telegram: JSON-serialize 'mask_position's
References:

  * Similar PR: https://github.com/yagop/node-telegram-bot-api/pull/468
2017-11-27 05:14:43 +03:00
drGOD
4586ebd10b src/telegram: JSON-serialize shipping_options in answerShippingQuery (#468) 2017-11-26 11:03:36 +03:00
Yago
fd337e91f2
Merge pull request #463 from saeedhei/patch-1
Persian Language added
2017-11-22 23:32:02 +01:00
Yago
20c5ab6710
Merge branch 'master' into patch-1 2017-11-22 23:31:48 +01:00
Yago
5510c07876
Merge branch 'master' into patch-1 2017-11-22 23:28:53 +01:00
Yago
3fbc6c85b0
Merge pull request #462 from Archakov06/patch-2
Add tutorial link RUS
2017-11-22 23:24:47 +01:00
Sedric Heidarizarei
757ba2476a
Persian Language added 2017-11-22 05:49:52 +03:30
Archakov Dennis
16045fda6e
Add tutorial link RUS 2017-11-22 00:55:11 +03:00
GochoMugo
ba4d207684
src: Improve performance when matching message types
Feature:

  Considering that the most encountered message type is (probably) 'text',
  we should match it as soon as possible; without wasting much time
  looping through less-likely-to-matched types.
2017-11-19 00:05:32 +03:00
GochoMugo
772609c334
doc: Update ParseError message; error might not be from Telegram 2017-11-18 23:55:05 +03:00
GochoMugo
ea420edad9
doc/help: Add link to bug '502 Bad Gateway'
References:

  * BR '502 Bad Gateway': https://github.com/yagop/node-telegram-bot-api/issues/377
2017-11-18 23:49:33 +03:00
GochoMugo
8c965d3a14
src: Improve default error logging of polling_error, webhook_error
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/377
2017-11-18 23:21:52 +03:00
MCSH
6263dcb007
examples: Fix game to answer callback query correctly
References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/418
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/449
2017-11-18 22:47:51 +03:00
Aaron Meese
e03ffe5d04 doc: Update README.md (#457) 2017-11-18 22:18:50 +03:00
GochoMugo
dc897d95e5
chore: Update npm script gen-doc to doc 2017-11-18 22:04:21 +03:00
GochoMugo
bbac07ad2c
doc: Document TelegramBot.errors, TelegramBot.messageTypes 2017-11-18 21:49:34 +03:00
GochoMugo
49df0c6e02
src/telegram: Add metadata argument in message event (and friends)
References:

  * FR: https://github.com/yagop/node-telegram-bot-api/issues/409
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/413
2017-11-18 21:44:06 +03:00
GochoMugo
3722c7182c
src/telegram: Fix TelegramBot#answerCallbackQuery() signature
Bug:

  `callbackQueryId` is a required argument. All other options
  are optional.

References:

  * Telegram API doc: https://core.telegram.org/bots/api#answercallbackquery
  * Blame: https://github.com/yagop/node-telegram-bot-api/pull/368
2017-11-18 20:31:01 +03:00
GochoMugo
9cf36a3b20
pkg: Add support for Node v9 2017-11-16 21:03:18 +03:00
GochoMugo
6b21ca3570
doc: Update contributing guidelines
References:

  * Issue not in English: https://github.com/yagop/node-telegram-bot-api/issues/460
2017-11-16 15:40:43 +03:00
GochoMugo
b6349de67e
doc: Document TelegramBot#on()
References:

  * Issue: https://github.com/yagop/node-telegram-bot-api/issues/436
2017-11-16 15:33:22 +03:00
GochoMugo
7f41992e62
pkg: Bump minor version (v0.28.0 -> v0.29.0)
See `CHANGELOG.md`.
2017-10-22 19:36:08 +03:00
GochoMugo
1475881a37
doc: Update changelog 2017-10-22 19:28:28 +03:00
GochoMugo
4f50f7350c
src/telegram: Add API v3.2 methods
Notes:

    Add methods:
      * TelegramBot#createNewStickerSet
      * TelegramBot#addStickerToSet
      * TelegramBot#setStickerPositionInSet
      * TelegramBot#deleteStickerFromSet

    Tests are missing!

References:

    * FR: https://github.com/yagop/node-telegram-bot-api/issues/407
2017-10-16 13:07:58 +03:00
Mohammed Sohail
4d90529492
[API v3.4] Support sticker sets 2017-10-14 04:55:25 +05:30
Mohammed Sohail
b25bc6eddb
[Doc] Generate documentation 2017-10-14 04:36:07 +05:30
Mohammed Sohail
7315fcff3e
[Fix] Minor copypasta typo 2017-10-13 22:28:15 +05:30
Mohammed Sohail
962ce2af3c
[API v3.4] Support live locations 2017-10-13 22:24:43 +05:30
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
f4f015a621
src/telegram: Use $NTBA_FIX_319 to apply fix for #319
Notes:

  The permanent fix introduces backwards-incompatible changes, which
  require a major version bump. Until we release v1,
  environment variable `${NTBA_FIX_319}` can be used to apply
  the fix.

References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/319
2017-08-25 18:51:51 +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
28160c70cd
doc: Fix broken link in change-log 2017-08-15 09:31:06 +03:00
37 changed files with 8088 additions and 2434 deletions

View File

@ -5,9 +5,10 @@
"new-cap": 0,
"prefer-arrow-callback": 0,
"no-param-reassign": [2,{"props":false}],
"max-len": [2, 150],
"max-len": [2, 200],
"arrow-body-style": 0,
"comma-dangle": 0
"comma-dangle": 0,
"indent": ["error", 2]
},
"plugins": [
"mocha"

View File

@ -5,7 +5,7 @@ For example, if your PR passes all tests, you would mark the option as so:
Note the 'x' in between the square brackets '[]'
-->
- [ ] All tests pass
- [ ] I have run `npm run gen-doc`
- [ ] I have run `npm run doc`
### Description

2
.gitignore vendored
View File

@ -2,7 +2,9 @@ node_modules
coverage/
npm-debug.log
.package.json
package-lock.json
output.md
output/
lib/
lib-doc/
.DS_Store

View File

@ -1,11 +1,15 @@
language: node_js
node_js:
- "12"
- "10"
- "8"
- "7"
- "6"
- "5"
- "4"
- "0.12"
#
# create required bash scripts to run builds on pull requests in the future
#
#script:
# - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./travis/run_on_pull_requests; fi'
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./travis/run_on_non_pull_requests; fi'
after_success:
- bash <(curl -s https://codecov.io/bash)
cache:

View File

@ -3,10 +3,422 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased][Unreleased]
## [0.68.0][0.68.0] - UNRELEASE
1. Support Telegram Bot API 9.1 (@danielperez9430)
* sendChecklist
* editMessageChecklist
* getMyStarBalance
2. Support Telegram Bot API 9.0 (@danielperez9430)
* readBusinessMessage
* deleteBusinessMessages
* setBusinessAccountName
* setBusinessAccountUsername
* setBusinessAccountBio
* setBusinessAccountProfilePhoto
* removeBusinessAccountProfilePhoto
* setBusinessAccountGiftSettings
* getBusinessAccountStarBalance
* transferBusinessAccountStars
* getBusinessAccountGifts
* convertGiftToStars
* upgradeGift
* transferGift
* postStory
* editStory
* deleteStory
* giftPremiumSubscription
3. Support Telegram Bot API 8.2 and 8.3 (@danielperez9430)
* verifyUser
* verifyChat
* removeUserVerification
* removeChatVerification
4. Support Telegram Bot API 8.0 and 8.1
* savePreparedInlineMessage (@IsmailBinMujeeb & @danielperez9430)
* setUserEmojiStatus (@danielperez9430)
* editUserStarSubscription (@danielperez9430)
* getAvailableGifts (@danielperez9430)
* sendGift (@danielperez9430)
5. Support Telegram Bot API 7.10 (@danielperez9430)
* Update: `purchased_paid_media`
6. Support Telegram Bot API 7.6 (@danielperez9430)
* sendPaidMedia
## [0.67.0][0.67.0] - 2024-05-30
1. Support Telegram Bot API 7.4 (@danielperez9430)
* refundStarPayment
## [0.66.0][0.66.0] - 2024-05-03
1. Support Telegram Bot API 7.2 & 7.3 (@danielperez9430)
* getBusinessConnection
* replaceStickerInSet
2. Support for updates: (@danielperez9430)
* business_connection
* business_message
* edited_business_message
* deleted_business_messages
3. Minor fixes: (@danielperez9430)
* getUserChatBoosts
## [0.65.1][0.65.1] - 2024-03-09
1. Support for updates (@danielperez9430)
* message_reaction
* message_reaction_count
* chat_boost
* removed_chat_boost
## [0.65.0][0.65.0] - 2024-02-20
1. Support Telegram Bot API v7.1
* deleteMessages (@Sp3ricka)
* copyMessages (@xjx0106 & @Sp3ricka)
* setMessageReaction (@Sp3ricka)
* forwardMessages (@danielperez9430)
* getUserChatBoosts (@danielperez9430)
2. Minor changes: (@danielperez9430)
* Refactor methods order
* Fix copyMessages & setMessageReaction methods
* Added missing tests
* Fix tests for methods copyMessages & getMyDefaulAdministratorRights
## [0.64.0][0.64.0] - 2023-10-25
1. Replace `request` with a maintained version (@danielperez9430)
* Change `request` to `@cypress/request`
* Change `request-promise` to `@cypress/request-promise`
## [0.63.0][0.63.0] - 2023-08-23
1. Support Telegram Bot API v6.8 (@danielperez9430)
* unpinAllGeneralForumTopicMessages
## [0.62.0][0.62.0] - 2023-03-19
1. Support Telegram Bot API v6.6 & v6.7 (@danielperez9430)
* setMyDescription
* getMyDescription
* setMyShortDescription
* getMyShortDescription
* setCustomEmojiStickerSetThumbnail
* setStickerSetTitle
* deleteStickerSet
* setStickerEmojiList
* setStickerKeywords
* setStickerMaskPosition
## [0.61.0][0.61.0] - 2022-12-30
1. Support Telegram Bot API v6.4 (@danielperez9430)
* editGeneralForumTopic
* closeGeneralForumTopic
* reopenGeneralForumTopic
* hideGeneralForumTopic
* unhideGeneralForumTopic
2. Minor changes: (@danielperez9430)
* The parameters `name` and `icon_custom_emoji_id` of the method `editForumTopic` are now optional.
* Fix add thumb in sendAudio, sendVideo and sendVideoNote
* Fix getMyCommands and setMyCommands
* Suggested tip amounts stringify in sendInvoice
## [0.60.0][0.60.0] - 2022-10-06
1. Support Telegram Bot API v6.3 (@danielperez9430)
* createForumTopic
* closeForumTopic
* reopenForumTopic
* deleteForumTopic
* unpinAllForumTopicMessages
* getForumTopicIconStickers
2. Fix test getMyDefaultAdministratorRights (@danielperez9430)
3. Fix parse entities - (@toniop99)
## [0.59.0][0.59.0] - 2022-08-15
1. Support Telegram Bot API v6.2 (@danielperez9430)
* getCustomEmojiStickers
2. Support test enviroment (@tinsaeDev & @kamikazechaser)
3. Remove dependencies: (@danielperez9430)
* Remove *bluebird* => Use NodeJS Native Promises
* Remove *depd* => Use node native deprecate util for warnings
* Remove contributor dev dependency and add list of contributors in the readme
4. Remove legacy methods: (@danielperez9430)
* getChatMembersCount
* kickChatMember
5. Docs: (@danielperez9430)
* Update the docs of the methods
* Order methods follow the Telegram bot API docs in src/telegram.js
* Update README
6. Fix: (@danielperez9430)
* addStickerToSet() -> Allow to send tgs_sticker + webm_sticker
* Remove mandatory param “start_parameter” from sendInvoice, because in the docs is a optional param
* getStickerSet test fix deprecated response value "contains_masks" change to "sticker_type"
* Fix some other tests
7. New Test: (@danielperez9430)
* deleteStickerFromSet
* setStickerPositionInSet
* getCustomEmojiStickers
## [0.58.0][0.58.0] - 2022-06-22
1. Support Bot API v6.1: (@danielperez9430)
* Add method *createInvoiceLink()*
2. Support for setStickerSetThumb (@elihaidv)
3. Add new test (@danielperez9430)
* createInvoiceLink
4. Test fixes (@danielperez9430)
* sendVideoNote
* createNewStickerSet
* setStickerSetThumb
* getChatMenuButton
* setWebHook
5. Bug fixes (@danielperez9430)
* answerWebAppQuery
* Support for send thumb in sendAudio
## [0.57.0][0.57.0] - 2022-04-23
Added:
1. Support Bot API v6: (@danielperez9430)
* Add method *setChatMenuButton()*
* Add method *getChatMenuButton()*
* Add method *setMyDefaultAdministratorRights()*
* Add method *getMyDefaultAdministratorRights()*
* Add method *answerWebAppQuery()*
* Renamed the fields voice_chat_scheduled, voice_chat_started, voice_chat_ended, and voice_chat_participants_invited to video_chat_scheduled, video_chat_started, video_chat_ended, and video_chat_participants_invited
Tests:
* answerWebAppQuery
* setChatMenuButton
* getChatMenuButton
* setMyDefaultAdministratorRights
* getMyDefaultAdministratorRights
## [0.56.0][0.56.0] - 2021-12-07
Added:
1. Support Bot API v5.5: (@danielperez9430)
* Add method *banChatSenderChat()*
* Add method *unbanChatSenderChat()*
Fixes:
* Tests for support with new invite link format
## [0.55.0][0.55.0] - 2021-11-06
Added:
1. Support Bot API v5.4: (@danielperez9430)
* Add method *approveChatJoinRequest()*
* Add method *declineChatJoinRequest()*
* Add support for new updates:
* *chat_join_request*
Fixes:
* Method *editMessageMedia*: Now you can send a local file (`"attach://" + filePatch`)
## [0.54.0][0.54.0] - 2021-06-29
Added:
1. Support Bot API v5.3: (@danielperez9430)
* Add method *deleteMyCommands()*
* Add method *banChatMember()*
* Add method *getChatMemberCount()*
New Test:
* deleteMyCommands
* banChatMember
* getChatMemberCount
Deprecated:
* Method *kickChatMember()*
* Method *getChatMembersCount()*
## [0.53.0][0.53.0] - 2021-04-26
Added:
1. Support Bot API v5.2:(@danielperez9430)
* Add support for new messageTypes:
* *voice_chat_scheduled*
## [0.52.0][0.52.0] - 2021-03-20
Added:
1. Support Bot API v5.1: (by @danielperez9430)
* Add method *createChatInviteLink()*
* Add method *editChatInviteLink()*
* Add method *revokeChatInviteLink()*
* Add support for new messageTypes:
* *voice_chat_started*
* *voice_chat_ended*
* *voice_chat_participants_invited*
* *message_auto_delete_timer_changed*
* *chat_invite_link*
* *chat_member_updated*
* Add support for new updates:
* *my_chat_member*
* *chat_member*
New Test: (by @danielperez9430)
* createChatInviteLink
* editChatInviteLink
* revokeChatInviteLink
## [0.51.0][0.51.0] - 2020-11-04
Added:
1. Support Bot API v5.0: (by @danielperez9430)
* Add method *copyMessage()*
* Add method *unpinAllChatMessages()*
* Add method *close()*
* Add method *logOut()*
Changed: (by @danielperez9430)
* Remove trailing-spaces
* Fix Bugs in Test
New Test: (by @danielperez9430)
* copyMessage
* unpinAllChatMessages
## [0.50.0][0.50.0] - 2020-05-2020
Added:
1. Support Bot API v4.8: (by @danielperez9430)
* Add methods: *sendDice()*
2. Support Bot API v4.7: (by @danielperez9430)
* Add methods: *getMyCommands()*,*setMyCommands()*
3. Support Bot API v4.5: (by @danielperez9430)
* Add methods: *setChatAdministratorCustomTitle()*
4. Support Bot API v4.4: (by @danielperez9430)
* Add methods: *setChatPermissions()*
5. Support for poll_answer (by @JieJiSS)
6. Add request options in file stream (by @zhangpanyi )
Changed: (by @danielperez9430)
* New message type: *dice*
* Fix Bugs in tests
* Fix regex compare (by @ledamint)
* Fix listening for error events when downloading files (by @Kraigo)
New Test: (by @danielperez9430)
* sendDice
* getMyCommands
* setMyCommands
* setChatAdministratorCustomTitle
* setChatPermissions
## [0.40.0][0.40.0] - 2019-05-04
Added:
1. Support Bot API v4.2: (by @kamikazechaser)
* Add methods: *TelegramBot#sendPoll()*, *TelegramBot#stopPoll()*
* Support events: *poll*
2. Support Bot API v4.0: (by @kamikazechaser)
* Add methods: *TelegramBot#editMessageMedia()*, *TelegramBot#sendAnimation()*
* Support new message types: *passport_data*, *animation*
* * *
## [0.30.0][0.30.0] - 2017-12-21
Added:
1. Support Bot API v3.5: (by @GochoMugo)
* Allow `provider_data` parameter in *TelegramBot#sendInvoice*
* Add method *TelegramBot#sendMediaGroup()*
2. Support Bot API v3.4: (by @kamikazechaser)
* Add methods *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (#439)
* Add methods *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (#440)
3. Add methods:
* *TelegramBot#getFileStream* (#442) (by @GochoMugo, requested-by @Xaqron)
4. Add options to *TelegramBot#stopPolling()* (by @GochoMugo)
5. Add `metadata` argument in `message` event (and friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
6. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo)
7. Add support for Node.js v9 (by @GochoMugo)
8. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo)
Changed:
1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo)
2. Improve default error logging of `polling_error` and `webhook_error` (#377)
3. Update dependencies
Deprecated:
1. Sending files: *(See [usage guide][usage-sending-files])* (by @hufan-akari, @GochoMugo)
* Error will **not** be thrown if `Buffer` is used and file-type could **not** be detected.
* Filename will **not** be set to `data.${ext}` if `Buffer` is used
* Content type will **not** default to `null` or `undefined`
Fixed:
1. Fix the offset infinite loop bug (#265, #36) (by @GochoMugo)
2. Fix game example (#449, #418) (by @MCSH)
* * *
## [0.29.0][0.29.0] - 2017-10-22
Added:
1. Add Bot API v3.2 methods:
* (#429) *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked)
* (#430) *TelegramBot#uploadStickerFile* (by @CapacitorSet)
* *TelegramBot#createNewStickerSet*, *TelegramBot#addStickerToSet*, *TelegramBot#setStickerPositionInSet*, *TelegramBot#deleteStickerFromSet* (by @GochoMugo)
2. Supports API v3.3
Deprecated:
1. Auto-enabling Promise cancellation (#319) (by @GochoMugo)
* * *
@ -15,10 +427,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
Added:
1. (#361) Support Bot API v3.1 (by @Lord-Protector, @kamikazechaser)
1. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo)
1. Add *TelegramBot#removeTextListener()* (by @GochoMugo)
1. (#342) Add game example (by @MCSH)
1. (#315) List 'bot-brother' project in community section in README (by @saeedhei)
2. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo)
3. Add *TelegramBot#removeTextListener()* (by @GochoMugo)
4. (#342) Add game example (by @MCSH)
5. (#315) List 'bot-brother' project in community section in README (by @saeedhei)
Changed:
@ -27,9 +439,8 @@ Changed:
Fixed:
1. (#325) Fix global regexp state reset (by @Sirius-A)
1. (#363) Fix download file path on windows (by @kucherenkovova)
1. (#346) Fix anchor webhook link in docs (by @Coac)
2. (#363) Fix download file path on windows (by @kucherenkovova)
3. (#346) Fix anchor webhook link in docs (by @Coac)
* * *
@ -39,15 +450,13 @@ Added:
1. (#287) Add Express WebHook example (by @kamikazechaser)
Fixed:
1. (#291) Improve docs (by @preco21)
1. (#298) Fix running on Node v5 (by @jehy)
1. (#307) Fix badge links in README (by @JaakkoLipsanen)
1. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo)
1. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus)
2. (#298) Fix running on Node v5 (by @jehy)
3. (#307) Fix badge links in README (by @JaakkoLipsanen)
4. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo)
5. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus)
* * *
@ -56,19 +465,19 @@ Fixed:
Added:
1. Add constructor options:
* (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux)
1. Add methods:
* (#74) *TelegramBot#removeReplyListener()* (by @githugger)
1. (#283) Add proper error handling (by @GochoMugo)
1. (#272) Add health-check endpoint (by @mironov)
* `options.webHook.healthEndpoint`
1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts'
* (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux)
2. Add methods:
* (#74) *TelegramBot#removeReplyListener()* (by @githugger)
3. (#283) Add proper error handling (by @GochoMugo)
4. (#272) Add health-check endpoint (by @mironov)
* `options.webHook.healthEndpoint`
5. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts'
param (by @evolun)
1. Document `options.webHook.host` (by @GochoMugo)
1. (#264) Add Bot API version to README (by @kamikazechaser)
1. Add examples:
- (#271) WebHook on Heroku (by @TheBeastOfCaerbannog)
- (#274) WebHook on Zeit Now (by @Ferrari)
6. Document `options.webHook.host` (by @GochoMugo)
7. (#264) Add Bot API version to README (by @kamikazechaser)
8. Add examples:
- (#271) WebHook on Heroku (by @TheBeastOfCaerbannog)
- (#274) WebHook on Zeit Now (by @Ferrari)
Changed:
@ -87,7 +496,6 @@ Fixed:
polling (by @GochoMugo, reported-by @dcparga)
1. Fix links in documentation (by @Ni2c2k)
* * *
## [0.26.0][0.26.0] - 2017-01-20
@ -95,32 +503,32 @@ Fixed:
Added:
1. Add *TelegramBot* constructor options:
* `options.https`
* `options.baseApiUrl`
* `options.filepath`
1. Add methods:
* *TelegramBot#stopPolling()*
* *TelegramBot#isPolling()*
* *TelegramBot#openWebHook()*
* *TelegramBot#closeWebHook()*
* *TelegramBot#hasOpenWebHook()*
* *TelegramBot#deleteWebHook()*
* *TelegramBot#getWebHookInfo()*
* `options.https`
* `options.baseApiUrl`
* `options.filepath`
2. Add methods:
* *TelegramBot#stopPolling()*
* *TelegramBot#isPolling()*
* *TelegramBot#openWebHook()*
* *TelegramBot#closeWebHook()*
* *TelegramBot#hasOpenWebHook()*
* *TelegramBot#deleteWebHook()*
* *TelegramBot#getWebHookInfo()*
Changed:
1. Use POST requests by default
1. Ensure all relevant methods return Promises
1. Document auto-deletion of webhook during polling
1. Deprecate support for Node.js v0.12
1. Fix consistency of methods signatures
1. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()*
* Deprecate *TelegramBot#initPolling()*
2. Ensure all relevant methods return Promises
3. Document auto-deletion of webhook during polling
4. Deprecate support for Node.js v0.12
5. Fix consistency of methods signatures
6. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()*
* Deprecate *TelegramBot#initPolling()*
Fixed:
1. Handle error during formatting `formData`
1. Fix ES6 syntax
2. Fix ES6 syntax
*Credits/Blames: Unless explicitly stated otherwise, above work was
done by @GochoMugo*
@ -132,22 +540,26 @@ done by @GochoMugo*
Added:
1. Supports the API v2.3 updates (by @kamikazechaser)
1. Add *TelegramBot* constructor option:
* `options.request`: proxy extra request options (by @tarmolov)
* `options.onlyFirstMatch` (by @GingerPlusPlus)
1. Add methods:
* *TelegramBot#sendVenue()* (by Tketa)
* *TelegramBot#sendContact()* (by @GochoMugo)
* *TelegramBot#getGameHighScores()* (by @jishnu7)
2. Add *TelegramBot* constructor option:
* `options.request`: proxy extra request options (by @tarmolov)
* `options.onlyFirstMatch` (by @GingerPlusPlus)
3. Add methods:
* *TelegramBot#sendVenue()* (by Tketa)
* *TelegramBot#sendContact()* (by @GochoMugo)
* *TelegramBot#getGameHighScores()* (by @jishnu7)
Fixed:
1. Fix request performance issue (by @preco21)
1. Fix typos (by oflisback)
2. Fix typos (by oflisback)
[usage-sending-files]:https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files-options
[0.25.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.25.0
[0.26.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.26.0
[0.27.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.27.0
[0.27.1]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.27.1
[Unreleased]:https://github.com/yagop/node-telegram-bot-api/compare/v0.27.1...master
[0.28.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.28.0
[0.29.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.29.0
[0.30.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.30.0
[Unreleased]:https://github.com/yagop/node-telegram-bot-api/compare/v0.30.0...master

View File

@ -10,18 +10,29 @@ Before proceeding any further, read the following documents:
## General Information
### Creating a Github issue:
1. Ensure that your issue does **not** already exist. [Do a search](https://github.com/yagop/node-telegram-bot-api/issues).
2. Browse through [StackOverflow](https://stackoverflow.com/search?q=telegram+nodejs) and other similar platforms.
3. Should you open your issue, ensure you use the English language for
the wider target audience.
4. Be patient please.
### Updating API Reference i.e. generating `doc/api.md`
Run:
```bash
$ npm run gen-doc
$ npm run doc
```
### Running tests
Please read `test/README.md` for more information.
### Transpiling ES2015 for older Node.js versions
We use babel to transpile the code:

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2017 Yago
Copyright (c) 2019 Yago
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,22 +1,34 @@
# Node.js Telegram Bot API
<h1 align="center">Node.js Telegram Bot API</h1>
[![Bot API](https://img.shields.io/badge/Bot%20API-v.3.1.0-00aced.svg)](https://core.telegram.org/bots/api)
[![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api)
[![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master)
[![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master)
[![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api)
[![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/💬%20Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api)
[![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬%20Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez)
<div align="center">
Node.js module to interact with official [Telegram Bot API](https://core.telegram.org/bots/api). A bot token is needed, to obtain one, talk to [@botfather](https://telegram.me/BotFather) and create a new bot.
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
## Install
```bash
npm install --save node-telegram-bot-api
[![Bot API](https://img.shields.io/badge/Bot%20API-v.9.0-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![npm package](https://img.shields.io/npm/v/node-telegram-bot-api?logo=npm&style=flat-square)](https://www.npmjs.org/package/node-telegram-bot-api)
[![Coverage Status](https://img.shields.io/codecov/c/github/yagop/node-telegram-bot-api?style=flat-square&logo=codecov)](https://codecov.io/gh/yagop/node-telegram-bot-api)
[![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/💬%20Telegram-Channel-blue.svg?style=flat-square)](https://telegram.me/node_telegram_bot_api)
[![https://t.me/+_IC8j_b1wSFlZTVk](https://img.shields.io/badge/💬%20Telegram-Group-blue.svg?style=flat-square)](https://t.me/+_IC8j_b1wSFlZTVk)
[![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬%20Telegram-Yago_Perez-blue.svg?style=flat-square)](https://telegram.me/Yago_Perez)
</div>
## 📦 Install
```sh
npm i node-telegram-bot-api
```
## Usage
<br/>
> ✍️ **Note:** If you use Typescript you can install this package that contains type definitions for this library
>```sh
>npm install --save-dev @types/node-telegram-bot-api
>```
## 🚀 Usage
```js
const TelegramBot = require('node-telegram-bot-api');
@ -50,39 +62,58 @@ bot.on('message', (msg) => {
});
```
## Documentation
## 📚 Documentation
* [Usage][usage]
* [Examples][examples]
* [Tutorials][tutorials]
* [Help Information][help]
* API Reference ([release][api-release] / [development][api-dev] / [experimental][api-experimental])
* API Reference: ([api-release](../master/doc/api.md) / [development][api-dev] / [experimental][api-experimental])
* [Contributing to the Project][contributing]
* [Experimental Features][experimental]
_**Note**: Development is done against the **master** branch.
Code for the latest release resides on the **release** branch
_**Note**: Development is done against the **development** branch.
Code for the latest release resides on the **master** branch.
Experimental features reside on the **experimental** branch._
## Community
## 💭 Community
We thank all the developers in the Open-Source community who continuously
take their time and effort in advancing this project.
See our [list of contributors][contributors].
We have a [Telegram channel][tg-channel] where we post updates on
the Project. Head over and subscribe!
Some things built using this library, and might interest you:
We also have a [Telegram group][tg-group] to discuss issues related to this library.
* [tgfancy](https://github.com/GochoMugo/tgfancy): A Fancy, Higher-Level Wrapper for Telegram Bot API
Some things built using this library that might interest you:
* [tgfancy](https://github.com/GochoMugo/tgfancy): A fancy, higher-level wrapper for Telegram Bot API
* [node-telegram-bot-api-middleware](https://github.com/idchlife/node-telegram-bot-api-middleware): Middleware for node-telegram-bot-api
* [teleirc](https://github.com/FruitieX/teleirc): A simple Telegram ↔ IRC gateway
* [bot-brother](https://github.com/SerjoPepper/bot-brother): Node.js library to help you easily create telegram bots
* [redbot](https://github.com/guidone/node-red-contrib-chatbot): A Node-RED plugin to create telegram bots visually
* [node-telegram-keyboard-wrapper](https://github.com/alexandercerutti/node-telegram-keyboard-wrapper): A wrapper to improve keyboards structures creation through a more easy-to-see way (supports Inline Keyboards, Reply Keyboard, Remove Keyboard and Force Reply)
* [beetube-bot](https://github.com/kodjunkie/beetube-bot): A telegram bot for music, videos, movies, EDM tracks, torrent downloads, files and more.
* [telegram-inline-calendar](https://github.com/VDS13/telegram-inline-calendar): Date and time picker and inline calendar for Node.js telegram bots.
* [telegram-captcha](https://github.com/VDS13/telegram-captcha): Telegram bot to protect Telegram groups from automatic bots.
## 👥 Contributors
<p align="center">
<a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">
<img src="https://contrib.rocks/image?repo=yagop/node-telegram-bot-api" />
</a>
</p>
## License
**The MIT License (MIT)**
Copyright (c) 2017 Yago
Copyright © 2019 Yago
[usage]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/usage.md
[examples]:https://github.com/yagop/node-telegram-bot-api/tree/master/examples
@ -92,5 +123,7 @@ Copyright (c) 2017 Yago
[api-release]:https://github.com/yagop/node-telegram-bot-api/tree/release/doc/api.md
[api-experimental]:https://github.com/yagop/node-telegram-bot-api/tree/experimental/doc/api.md
[contributing]:https://github.com/yagop/node-telegram-bot-api/tree/master/CONTRIBUTING.md
[contributors]:https://github.com/yagop/node-telegram-bot-api/graphs/contributors
[experimental]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/experimental.md
[tg-channel]:https://telegram.me/node_telegram_bot_api
[tg-group]:https://t.me/+nc3A9Hs1S81mYzdk

View File

@ -16,3 +16,4 @@
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery

3293
doc/api.md

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,8 @@ Sources:
1. [How do I run my bot behind a proxy?](#proxy)
1. [Can you add feature X to the library?](#new-feature)
1. [Is this scalable?](#scalable)
1. [How do I listen for messages in a chat group?](#messages-in-chat)
1. [How do I know when a user blocks the bot?](#blocked-bot)
<a name="gifs"></a>
### How do I send GIFs?
@ -67,7 +69,9 @@ Sources:
<a name="error-meanings"></a>
### What does this error mean?
*Not done. PRs welcome!*
* [502 Bad Gateway](https://github.com/yagop/node-telegram-bot-api/issues/377)
*Not complete. PRs welcome!*
Sources:
@ -106,6 +110,7 @@ Sources:
* Issue [#122](https://github.com/yagop/node-telegram-bot-api/issues/122)
* Issue [#253](https://github.com/yagop/node-telegram-bot-api/issues/253)
* Issue [#766](https://github.com/yagop/node-telegram-bot-api/issues/766)
<a name="new-feature"></a>
### Can you add feature X to the library?
@ -125,4 +130,22 @@ Sources:
* Issue [#219](https://github.com/yagop/node-telegram-bot-api/issues/219)
<a name="messages-in-chat"></a>
### How do I listen for messages in a chat group?
*Not done. PRs welcome!*
Sources:
* Issue [#304](https://github.com/yagop/node-telegram-bot-api/issues/304)
<a name="blocked-bot"></a>
### How do I know when a user blocks the bot?
*Not done. PRs welcome!*
Sources:
* Issue [#273](https://github.com/yagop/node-telegram-bot-api/issues/273)
[questions]:https://github.com/yagop/node-telegram-bot-api/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20

View File

@ -1,5 +1,12 @@
# Tutorials
* [node-telegram-bot-api-tutorial by @hosein2398](https://github.com/hosein2398/node-telegram-bot-api-tutorial)
* [node-telegram-bot-api-persian-language by @saeedhei](https://github.com/saeedhei/node-telegram-bot-api-persian-language)
* [Node.JS: Делаем своего Telegram бота [RUS]](https://archakov.im/post/telegram-bot-on-nodejs)
* [YouTube: Пишем Telegram бота на NodeJS [RUS]](https://www.youtube.com/watch?v=RS1nmDMf69U&list=PL6AOr-PZtK-mM2QC1ixyfa5CtJZGK61aN)
* [Node.jsでTelegramのチャットボットを作る - Qiita](https://qiita.com/neetshin/items/0e2f6fa3ade41adb77bc)
* [Guía: Creación de bots de Telegram en Nodejs [ES]](https://tecnonucleous.com/creacion-de-bots-de-telegram-en-nodejs/)
* [node-telegram-bot-api-tutorial:a telegram bot helper to send templates by sms](https://github.com/vito2005/chatManagerTelegramBot)
* [Telegram bot using blockchain services](https://ilanolkies.com/post/Telegram-bot-using-blockchain-services)
* [How to set webhooks using express local server and NGROK](https://github.com/leobloise/node-telegram-bot-api-wb-tutorial)
> Send a PR with useful links **not** listed above

View File

@ -1,24 +1,31 @@
# Usage
* [Events](#events)
* [WebHooks](#webhooks)
* [Sending files](#sending-files)
* [Error handling](#error-handling)
- [Usage](#usage)
- [Events](#events)
- [WebHooks](#webhooks)
- [Sending files](#sending-files)
- [File Options (metadata)](#file-options-metadata)
- [Performance Issue](#performance-issue)
- [Error handling](#error-handling)
- [Polling errors](#polling-errors)
- [WebHook errors](#webhook-errors)
<a name="events"></a>
## Events
*TelegramBot* is an event-emitter that emits the following events:
*TelegramBot* is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
that emits the following events:
1. `message`: Received a new incoming [Message][message] of any kind
1. Depending on the properties of the [Message][message], one of these
events will **ALSO** be emitted: `text`, `audio`, `document`, `photo`,
events may **ALSO** be emitted: `text`, `audio`, `document`, `photo`,
`sticker`, `video`, `voice`, `contact`, `location`,
`new_chat_members`, `left_chat_member`, `new_chat_title`,
`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`game`, `pinned_message`, `migrate_from_chat_id`, `migrate_to_chat_id`,
`game`, `pinned_message`, `poll`, `dice`, `migrate_from_chat_id`, `migrate_to_chat_id`,
`channel_chat_created`, `supergroup_chat_created`,
`successful_payment`, `invoice`, `video_note`
1. **Arguments**: `message` ([Message][message]), `metadata` (`{ type?:string }`)
1. `new_chat_participant`, `left_chat_participant` are **deprecated**
1. `callback_query`: Received a new incoming [Callback Query][callback-query]
1. `inline_query`: Received a new incoming [Inline Query][inline-query]
@ -32,8 +39,14 @@
1. `edited_channel_post_caption`
1. `shipping_query`: Received a new incoming shipping query
1. `pre_checkout_query`: Received a new incoming pre-checkout query
1. `polling_error`: Error occurred during polling. See [polling errors](#polling-errors).
1. `webhook_error`: Error occurred handling a webhook request. See [webhook errors](#webhook-errors).
1. `poll`: Received a new incoming poll
2. `poll_answer`: A user has changed their answer in a non-anonymous poll (Only polls sent by the bot)
3. `chat_member`: A chat member's status was updated in a chat
4. `my_chat_member`: The bot's chat member status was updated in a chat
5. `chat_join_request`: A request to join the chat has been sent (The bot must have the can_invite_users administrator right)
5. `polling_error`: Error occurred during polling. See [polling errors](#polling-errors).
6. `webhook_error`: Error occurred handling a webhook request. See [webhook errors](#webhook-errors).
7. `error`: Unexpected error occurred, usually fatal!
**Tip:** Its much better to listen a specific event rather than on
`message` in order to stay safe from the content.
@ -113,6 +126,63 @@ const url = 'https://telegram.org/img/t_logo.png';
bot.sendPhoto(chatId, url);
```
If you wish to explicitly specify the filename or
[MIME type](http://en.wikipedia.org/wiki/Internet_media_type),
you may pass an additional argument as file options, like so:
```js
const fileOptions = {
// Explicitly specify the file name.
filename: 'customfilename',
// Explicitly specify the MIME type.
contentType: 'audio/mpeg',
};
bot.sendAudio(chatId, data, {}, fileOptions);
```
**NOTE:** You **MUST** provide an empty object (`{}`) in place of
*Additional Telegram query options*, if you have **no** query options
to specify. For example,
```js
// WRONG!
// 'fileOptions' will be taken as additional Telegram query options!!!
bot.sendAudio(chatId, data, fileOptions);
// RIGHT!
bot.sendAudio(chatId, data, {}, fileOptions);
```
<a name="sending-files-options"></a>
### File Options (metadata)
When sending files, the library automatically resolves
the `filename` and `contentType` properties.
**For now, this has to be manually activated using environment
variable `NTBA_FIX_350`.**
In order of highest-to-lowest precedence in searching for
a value, when resolving the `filename`:
*(`fileOptions` is the Object argument passed to the method.
The "file" argument passed to the method can be a `Stream`,
`Buffer` or `filepath`.)*
1. Is `fileOptions.filename` explictly defined?
1. Does `Stream#path` exist?
1. Is `filepath` provided?
1. Default to `"filename"`
And the `contentType`:
1. Is `fileOptions.contentType` explictly-defined?
1. Does `Stream#path` exist?
1. Try detecting file-type from the `Buffer`
1. Is `filepath` provided?
1. Is `fileOptions.filename` explicitly defined?
1. Default to `"application/octet-stream"`
<a name="sending-files-performance"></a>
### Performance Issue

View File

@ -39,7 +39,7 @@ bot.onText(/\/start/, function onPhotoText(msg) {
// Handle callback queries
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
bot.answerCallbackQuery(callbackQuery.id, url, true, { url });
bot.answerCallbackQuery(callbackQuery.id, { url });
});
// Render the HTML game

View File

@ -6,7 +6,7 @@
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const request = require('request');
const request = require('@cypress/request');
const options = {
polling: true
};
@ -62,8 +62,8 @@ bot.onText(/\/editable/, function onEditableText(msg) {
[
{
text: 'Edit Text',
// we shall check for this value when we listen
// for "callback_query"
// we shall check for this value when we listen
// for "callback_query"
callback_data: 'edit'
}
]

View File

@ -8,9 +8,8 @@ const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const url = 'https://<PUBLIC-URL>';
const port = process.env.PORT;
const TelegramBot = require('..');
const TelegramBot = require('../..');
const express = require('express');
const bodyParser = require('body-parser');
// No need to pass any parameters as we will handle the updates with Express
const bot = new TelegramBot(TOKEN);
@ -21,7 +20,7 @@ bot.setWebHook(`${url}/bot${TOKEN}`);
const app = express();
// parse the updates to JSON
app.use(bodyParser.json());
app.use(express.json());
// We are receiving updates at the route below!
app.post(`/bot${TOKEN}`, (req, res) => {

View File

@ -5,7 +5,7 @@
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const TelegramBot = require('../..');
const options = {
webHook: {
// Port to which you should bind is assigned to $PORT variable

View File

@ -5,12 +5,12 @@
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const TelegramBot = require('../..');
const options = {
webHook: {
port: 443,
key: `${__dirname}/key.pem`, // Path to file with PEM private key
cert: `${__dirname}/crt.pem` // Path to file with PEM certificate
key: `${__dirname}/../ssl/key.pem`, // Path to file with PEM private key
cert: `${__dirname}/../ssl/crt.pem` // Path to file with PEM certificate
}
};
// This URL must route to the port set above (i.e. 443)

View File

@ -6,7 +6,7 @@
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const TelegramBot = require('../..');
const options = {
webHook: {
// Just use 443 directly

View File

@ -1,11 +1,23 @@
/**
* This example demonstrates setting up webhook
* on the OpenShift platform.
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* NOTE:
*
* Openshift 2 has been shut down.
*
* This example is kept here for historical/educational purposes.
* No changes are expected to be made to the source code below.
*
* See https://github.com/yagop/node-telegram-bot-api/issues/426 for
* more information.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const TelegramBot = require('../..');
// See https://developers.openshift.com/en/node-js-environment-variables.html
const options = {
webHook: {

View File

@ -5,7 +5,7 @@
*/
const majorVersion = parseInt(process.versions.node.split('.')[0], 10);
if (majorVersion <= 5) {
const deprecate = require('depd')('node-telegram-bot-api');
const deprecate = require('./src/utils').deprecate;
deprecate('Node.js v5.x and below will no longer be supported in the future');
module.exports = require('./lib/telegram');
} else {

View File

@ -1,6 +1,6 @@
{
"name": "node-telegram-bot-api",
"version": "0.28.0",
"version": "0.68.0",
"description": "Telegram Bot API",
"main": "./index.js",
"directories": {
@ -14,9 +14,10 @@
"bot"
],
"scripts": {
"gen-doc": "jsdoc2md --files src/telegram.js --template doc/api.hbs > doc/api.md",
"gen-doc": "echo 'WARNING: `npm run gen-doc` is deprecated. Use `npm run doc` instead.' && npm run doc",
"doc": "jsdoc2md --files src/telegram.js --template doc/api.hbs > doc/api.md",
"build": "babel -d ./lib src",
"prepublish": "npm run build && npm run gen-doc",
"prepublishOnly": "npm run build && npm run gen-doc",
"eslint": "eslint ./src ./test ./examples",
"mocha": "mocha",
"pretest": "npm run build",
@ -28,41 +29,39 @@
"node": ">=0.12"
},
"dependencies": {
"array.prototype.findindex": "^2.0.0",
"bl": "^1.1.2",
"bluebird": "^3.3.4",
"debug": "^2.2.0",
"depd": "^1.1.0",
"eventemitter3": "^2.0.2",
"@cypress/request": "^3.0.8",
"@cypress/request-promise": "^5.0.0",
"array.prototype.findindex": "^2.0.2",
"bl": "^1.2.3",
"debug": "^3.2.7",
"eventemitter3": "^3.0.0",
"file-type": "^3.9.0",
"mime": "^1.3.4",
"pump": "^1.0.1",
"request": "^2.69.0",
"request-promise": "^4.1.1"
"mime": "^1.6.0",
"pump": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-eslint": "^6.1.2",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-es2015-destructuring": "^6.6.5",
"babel-plugin-transform-es2015-parameters": "^6.7.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.5.0",
"babel-plugin-transform-es2015-spread": "^6.6.5",
"babel-plugin-transform-object-rest-spread": "^6.6.5",
"babel-plugin-transform-strict-mode": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.7.2",
"contributor": "^0.1.25",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-strict-mode": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"concat-stream": "^1.6.0",
"eslint": "^2.13.1",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-mocha": "^4.8.0",
"is": "^3.1.0",
"eslint-plugin-mocha": "^4.11.0",
"is": "^3.2.1",
"is-ci": "^1.0.10",
"istanbul": "^1.1.0-alpha.1",
"jsdoc-to-markdown": "^2.0.1",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.2.0",
"node-static": "^0.7.9"
"jsdoc-to-markdown": "^3.0.3",
"mocha": "^3.5.3",
"mocha-lcov-reporter": "^1.3.0",
"node-static": "^0.7.10"
},
"repository": {
"type": "git",
@ -71,349 +70,5 @@
"bugs": {
"url": "https://github.com/yagop/node-telegram-bot-api/issues"
},
"homepage": "https://github.com/yagop/node-telegram-bot-api",
"contributors": [
{
"name": "Anton Mironov",
"email": "ant.mironov@gmail.com",
"url": "https://github.com/mironov",
"contributions": 1,
"additions": 51,
"deletions": 15,
"hireable": true
},
{
"name": "Daniil Yastremskiy",
"email": "Catharsis@post.cz",
"url": "https://github.com/TheBeastOfCaerbannog",
"contributions": 1,
"additions": 36,
"deletions": 0,
"hireable": true
},
{
"name": null,
"email": null,
"url": "https://github.com/Ni2c2k",
"contributions": 1,
"additions": 4,
"deletions": 4,
"hireable": null
},
{
"name": "Alexander Tarmolov",
"email": "tarmolov@gmail.com",
"url": "https://github.com/tarmolov",
"contributions": 1,
"additions": 5,
"deletions": 0,
"hireable": null
},
{
"name": "Plusb Preco",
"email": "plusb21@gmail.com",
"url": "https://github.com/preco21",
"contributions": 1,
"additions": 1,
"deletions": 0,
"hireable": null
},
{
"name": "Ola Flisbäck",
"email": null,
"url": "https://github.com/oflisback",
"contributions": 1,
"additions": 3,
"deletions": 3,
"hireable": true
},
{
"name": null,
"email": null,
"url": "https://github.com/GingerPlusPlus",
"contributions": 1,
"additions": 6,
"deletions": 2,
"hireable": null
},
{
"name": "Sergey Bogdanov",
"email": "sergey.bogdanov@gmail.com",
"url": "https://github.com/desunit",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Mikhail Burshteyn",
"email": null,
"url": "https://github.com/m-burst",
"contributions": 1,
"additions": 12,
"deletions": 5,
"hireable": null
},
{
"name": "Horus Lugo",
"email": "horusgoul@gmail.com",
"url": "https://github.com/HorusGoul",
"contributions": 1,
"additions": 108,
"deletions": 1,
"hireable": true
},
{
"name": "Serhii Dmytruk",
"email": "dmitruksergey@gmail.com",
"url": "https://github.com/serhiidmytruk",
"contributions": 1,
"additions": 35,
"deletions": 1,
"hireable": null
},
{
"name": "Conor Fennell",
"email": null,
"url": "https://github.com/conorfennell",
"contributions": 1,
"additions": 50,
"deletions": 1,
"hireable": null
},
{
"name": "Aleksandr L.",
"email": "w.siteee@gmail.com",
"url": "https://github.com/w-site",
"contributions": 1,
"additions": 24,
"deletions": 0,
"hireable": null
},
{
"name": "Matthew Brandly",
"email": "matt@brandly.me",
"url": "https://github.com/brandly",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Anton",
"email": null,
"url": "https://github.com/Feverqwe",
"contributions": 1,
"additions": 23,
"deletions": 5,
"hireable": null
},
{
"name": "Patricio López Juri",
"email": "patricio@lopezjuri.com",
"url": "https://github.com/mrpatiwi",
"contributions": 1,
"additions": 49,
"deletions": 2,
"hireable": true
},
{
"name": "Guido García",
"email": "palmerabollo@gmail.com",
"url": "https://github.com/palmerabollo",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": true
},
{
"name": "Sebastian Troć",
"email": "sebastian.troc@gucman.pl",
"url": "https://github.com/SebastianTroc",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Mohammed Sohail",
"email": "sohail@forfuture.tech",
"url": "https://github.com/kamikazechaser",
"contributions": 2,
"additions": 20,
"deletions": 5,
"hireable": true
},
{
"name": "Jishnu Mohan",
"email": "jishnu7@gmail.com",
"url": "https://github.com/jishnu7",
"contributions": 2,
"additions": 84,
"deletions": 0,
"hireable": true
},
{
"name": "Jérémy Gotteland",
"email": null,
"url": "https://github.com/Tketa",
"contributions": 2,
"additions": 81,
"deletions": 3,
"hireable": null
},
{
"name": "Alex Godko",
"email": "koloboid@gmail.com",
"url": "https://github.com/koloboid",
"contributions": 2,
"additions": 2,
"deletions": 2,
"hireable": true
},
{
"name": "Dardan Neziri",
"email": "dard.ne@gmail.com",
"url": "https://github.com/knock-in",
"contributions": 2,
"additions": 22,
"deletions": 16,
"hireable": true
},
{
"name": "Cristian Baldi",
"email": "bld.cris.96@gmail.com",
"url": "https://github.com/crisbal",
"contributions": 2,
"additions": 26,
"deletions": 1,
"hireable": true
},
{
"name": "Vitaly Aminev",
"email": null,
"url": "https://github.com/AVVS",
"contributions": 2,
"additions": 1065,
"deletions": 1001,
"hireable": true
},
{
"name": null,
"email": "plo.cav@gmail.com",
"url": "https://github.com/evolun",
"contributions": 2,
"additions": 7,
"deletions": 3,
"hireable": null
},
{
"name": "Iiro Jäppinen",
"email": null,
"url": "https://github.com/iiroj",
"contributions": 2,
"additions": 40,
"deletions": 0,
"hireable": null
},
{
"name": "TJ Horner",
"email": "me@tjhorner.com",
"url": "https://github.com/tjhorner",
"contributions": 2,
"additions": 223,
"deletions": 1,
"hireable": null
},
{
"name": "Rafael Kr",
"email": null,
"url": "https://github.com/RafaelKr",
"contributions": 3,
"additions": 3,
"deletions": 2,
"hireable": null
},
{
"name": "Vítor Augusto da Silva Vasconcellos",
"email": "vasvas10@gmail.com",
"url": "https://github.com/HeavenVolkoff",
"contributions": 2,
"additions": 12,
"deletions": 0,
"hireable": true
},
{
"name": "Rey",
"email": null,
"url": "https://github.com/reyy",
"contributions": 2,
"additions": 34,
"deletions": 25,
"hireable": null
},
{
"name": "Ivan Skorokhodov",
"email": "iskorokhodov@gmail.com",
"url": "https://github.com/universome",
"contributions": 3,
"additions": 219,
"deletions": 5,
"hireable": null
},
{
"name": "Riddler",
"email": null,
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"hireable": true
},
{
"name": null,
"email": "exlmotodev@gmail.com",
"url": "https://github.com/EXL",
"contributions": 4,
"additions": 4,
"deletions": 4,
"hireable": true
},
{
"name": "Yago",
"email": "yago@yago.me",
"url": "https://github.com/yagop",
"contributions": 194,
"additions": 3014,
"deletions": 1173,
"hireable": true
},
{
"name": "Ilias Ismanalijev",
"email": "hello@illyism.com",
"url": "https://github.com/Illyism",
"contributions": 7,
"additions": 140,
"deletions": 10,
"hireable": true
},
{
"name": "Chris54721",
"email": null,
"url": "https://github.com/chris54721",
"contributions": 5,
"additions": 22,
"deletions": 6,
"hireable": null
},
{
"name": "Gocho Mugo",
"email": "mugo@forfuture.co.ke",
"url": "https://github.com/GochoMugo",
"contributions": 80,
"additions": 4590,
"deletions": 2377,
"hireable": true
}
]
}
"homepage": "https://github.com/yagop/node-telegram-bot-api"
}

View File

@ -10,6 +10,12 @@ exports.BaseError = class BaseError extends Error {
super(`${code}: ${message}`);
this.code = code;
}
toJSON() {
return {
code: this.code,
message: this.message,
};
}
};
@ -24,7 +30,10 @@ exports.FatalError = class FatalError extends exports.BaseError {
const error = (typeof data === 'string') ? null : data;
const message = error ? error.message : data;
super('EFATAL', message);
if (error) this.stack = error.stack;
if (error) {
this.stack = error.stack;
this.cause = error;
}
}
};

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
const errors = require('./errors');
const debug = require('debug')('node-telegram-bot-api');
const deprecate = require('depd')('node-telegram-bot-api');
const deprecate = require('./utils').deprecate;
const ANOTHER_WEB_HOOK_USED = 409;
@ -49,7 +50,7 @@ class TelegramBotPolling {
/**
* Stop polling
* @param {Object} [options]
* @param {Object} [options] Options
* @param {Boolean} [options.cancel] Cancel current request
* @param {String} [options.reason] Reason for stopping polling
* @return {Promise}
@ -79,6 +80,18 @@ class TelegramBotPolling {
return !!this._lastRequest;
}
/**
* Handle error thrown during polling.
* @private
* @param {Error} error
*/
_error(error) {
if (!this.bot.listeners('polling_error').length) {
return console.error('error: [polling_error] %j', error); // eslint-disable-line no-console
}
return this.bot.emit('polling_error', error);
}
/**
* Invokes polling (with recursion!)
* @return {Promise} promise of the current request
@ -93,18 +106,59 @@ class TelegramBotPolling {
updates.forEach(update => {
this.options.params.offset = update.update_id + 1;
debug('updated offset: %s', this.options.params.offset);
this.bot.processUpdate(update);
try {
this.bot.processUpdate(update);
} catch (err) {
err._processing = true;
throw err;
}
});
return null;
})
.catch(err => {
debug('polling error: %s', err.message);
if (this.bot.listeners('polling_error').length) {
this.bot.emit('polling_error', err);
} else {
console.error(err); // eslint-disable-line no-console
if (!err._processing) {
return this._error(err);
}
return null;
delete err._processing;
/*
* An error occured while processing the items,
* i.e. in `this.bot.processUpdate()` above.
* We need to mark the already-processed items
* to avoid fetching them again once the application
* is restarted, or moves to next polling interval
* (in cases where unhandled rejections do not terminate
* the process).
* See https://github.com/yagop/node-telegram-bot-api/issues/36#issuecomment-268532067
*/
if (!this.bot.options.badRejection) {
return this._error(err);
}
const opts = {
offset: this.options.params.offset,
limit: 1,
timeout: 0,
};
return this.bot.getUpdates(opts).then(() => {
return this._error(err);
}).catch(requestErr => {
/*
* We have been unable to handle this error.
* We have to log this to stderr to ensure devops
* understands that they may receive already-processed items
* on app restart.
* We simply can not rescue this situation, emit "error"
* event, with the hope that the application exits.
*/
/* eslint-disable no-console */
const bugUrl = 'https://github.com/yagop/node-telegram-bot-api/issues/36#issuecomment-268532067';
console.error('error: Internal handling of The Offset Infinite Loop failed');
console.error(`error: Due to error '${requestErr}'`);
console.error('error: You may receive already-processed updates on app restart');
console.error(`error: Please see ${bugUrl} for more information`);
/* eslint-enable no-console */
return this.bot.emit('error', new errors.FatalError(err));
});
})
.finally(() => {
if (this._abort) {

View File

@ -4,8 +4,6 @@ const https = require('https');
const http = require('http');
const fs = require('fs');
const bl = require('bl');
const Promise = require('bluebird');
class TelegramBotWebHook {
/**
@ -52,12 +50,16 @@ class TelegramBotWebHook {
if (this.isOpen()) {
return Promise.resolve();
}
return new Promise(resolve => {
return new Promise((resolve, reject) => {
this._webServer.listen(this.options.port, this.options.host, () => {
debug('WebHook listening on port %s', this.options.port);
this._open = true;
return resolve();
});
this._webServer.once('error', (err) => {
reject(err);
});
});
}
@ -97,7 +99,7 @@ class TelegramBotWebHook {
*/
_error(error) {
if (!this.bot.listeners('webhook_error').length) {
return console.error(error); // eslint-disable-line no-console
return console.error('error: [webhook_error] %j', error); // eslint-disable-line no-console
}
return this.bot.emit('webhook_error', error);
}

3
src/utils.js Normal file
View File

@ -0,0 +1,3 @@
const util = require('util');
// Native deprecation warning
exports.deprecate = (msg) => util.deprecate(() => { }, msg, 'node-telegram-bot-api')();

View File

@ -10,9 +10,14 @@ export TEST_USER_ID=<USER_ID>
# Group Id which to use in some of the tests, e.g. for TelegramBot#getChat()
export TEST_GROUP_ID=<GROUP_ID>
# Game short name which to use in some of the tests, e.g. TelegramBot#sendGame()
# Game short name to use in some tests, e.g. TelegramBot#sendGame()
# Defaults to "medusalab_test".
export TEST_GAME_SHORT_NAME=<GAME_SHORT_NAME>
# Sticker set name to use in some tests, e.g. TelegramBot#getStickerSet()
# Defaults to "pusheen".
export TEST_STICKER_SET_NAME=<STICKER_SET_NAME>
# Payment provider token to be used
export TEST_PROVIDER_TOKEN=<YOUR_PROVIDER_TOKEN>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
test/data/photo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
test/data/sticker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
test/data/sticker_thumb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const TelegramBot = require('..');
const paths = {
audio: path.join(__dirname, 'data/audio.mp3'),
};
describe('#_formatSendData', function sendfileSuite() {
const bot = new TelegramBot('token');
const type = 'file';
before(function beforeSuite() {
process.env.NTBA_FIX_350 = 1;
});
after(function afterSuite() {
delete process.env.NTBA_FIX_350;
});
describe('using fileOptions', function sendfileOptionsSuite() {
const stream = fs.createReadStream(paths.audio);
const nonPathStream = fs.createReadStream(paths.audio);
const buffer = fs.readFileSync(paths.audio);
const nonDetectableBuffer = fs.readFileSync(__filename);
const filepath = paths.audio;
const files = [stream, nonPathStream, buffer, nonDetectableBuffer, filepath];
delete nonPathStream.path;
describe('filename', function filenameSuite() {
it('(1) fileOptions.filename', function test() {
const filename = 'custom-filename';
files.forEach((file) => {
const [{ [type]: data }] = bot._formatSendData(type, file, { filename });
assert.equal(data.options.filename, filename);
});
});
it('(2) Stream#path', function test() {
if (!stream.path) {
this.skip('Stream#path unsupported');
return;
}
const [{ [type]: data }] = bot._formatSendData(type, stream);
assert.equal(data.options.filename, path.basename(paths.audio));
});
it('(3) filepath', function test() {
const [{ [type]: data }] = bot._formatSendData(type, filepath);
assert.equal(data.options.filename, path.basename(paths.audio));
});
it('(4) final default', function test() {
[nonPathStream, buffer, nonDetectableBuffer].forEach((file) => {
const [{ [type]: data }] = bot._formatSendData(type, file);
assert.equal(data.options.filename, 'filename');
});
});
});
describe('contentType', function contentTypeSuite() {
it('(1) fileOpts.contentType', function test() {
const contentType = 'application/custom-type';
files.forEach((file) => {
const [{ [type]: data }] = bot._formatSendData(type, file, { contentType });
assert.equal(data.options.contentType, contentType);
});
});
it('(2) Stream#path', function test() {
if (!stream.path) {
this.skip('Stream#path unsupported');
return;
}
const [{ [type]: data }] = bot._formatSendData(type, stream);
assert.equal(data.options.contentType, 'audio/mpeg');
});
it('(3) Buffer file-type', function test() {
const [{ [type]: data }] = bot._formatSendData(type, buffer);
assert.equal(data.options.contentType, 'audio/mpeg');
});
it('(4) filepath', function test() {
const [{ [type]: data }] = bot._formatSendData(type, filepath);
assert.equal(data.options.contentType, 'audio/mpeg');
});
it('(5) fileOptions.filename', function test() {
[nonPathStream, nonDetectableBuffer].forEach((file) => {
const [{ [type]: data }] = bot._formatSendData(type, file, {
filename: 'image.gif',
});
assert.equal(data.options.contentType, 'image/gif');
});
});
it('(6) Final default', function test() {
[nonPathStream, nonDetectableBuffer].forEach((file) => {
const [{ [type]: data }] = bot._formatSendData(type, file);
assert.equal(data.options.contentType, 'application/octet-stream');
});
});
});
});
it('should handle buffer path from fs.readStream', function test() {
let file;
try {
file = fs.createReadStream(Buffer.from(paths.audio));
} catch (ex) {
// Older Node.js versions do not support passing a Buffer
// representation of the path to fs.createReadStream()
if (ex instanceof TypeError) {
Promise.resolve();
return;
}
}
const [{ [type]: data }] = bot._formatSendData('file', file);
assert.equal(data.options.filename, path.basename(paths.audio));
});
it('should not accept file-paths if disallowed with constructor option', function test() {
const tgbot = new TelegramBot('token', { filepath: false });
const [formData, fileId] = tgbot._formatSendData('file', paths.audio);
assert.ok(fileId);
assert.ok(!formData);
});
it('should allow stream.path that can not be parsed', function test() {
const stream = fs.createReadStream(paths.audio);
stream.path = '/?id=123'; // for example, 'http://example.com/?id=666'
assert.doesNotThrow(function assertDoesNotThrow() {
bot._formatSendData('file', stream);
});
});
});

View File

@ -30,6 +30,13 @@ exports = module.exports = {
* @return {Promise}
*/
isPollingMockServer,
/**
* Return true if the string is a URI to a file
* on Telegram servers.
* @param {String} uri
* @return {Boolean}
*/
isTelegramFileURI,
/**
* Send a message to the webhook at the specified port and path.
* @param {Number} port
@ -74,8 +81,7 @@ exports = module.exports = {
const assert = require('assert');
const http = require('http');
const Promise = require('bluebird');
const request = require('request-promise');
const request = require('@cypress/request-promise');
const statics = require('node-static');
const servers = {};
@ -217,3 +223,8 @@ function handleRatelimit(bot, methodName, suite) {
};
return bot;
}
function isTelegramFileURI(uri) {
return /https?:\/\/.*\/file\/bot.*\/.*/.test(uri);
}