node-telegram-bot-api
Advanced tools
Comparing version 0.27.0 to 0.27.1
<!-- | ||
This template includes two sections: | ||
This template includes three sections: | ||
1. Bug reporting | ||
@@ -7,3 +7,3 @@ 2. Feature request | ||
Please remove whichever section that does not apply to your issue | ||
Please remove sections that do not apply to your issue | ||
--> | ||
@@ -10,0 +10,0 @@ |
@@ -8,3 +8,5 @@ # Change Log | ||
Added: | ||
1. (#315) List 'bot-brother' project in community section in README (by @saeedhei) | ||
@@ -14,6 +16,24 @@ | ||
## [0.27.0][0.27.0] - 2016-02-10 | ||
## [0.27.1][0.27.1] - 2017-04-07 | ||
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) | ||
* * * | ||
## [0.27.0][0.27.0] - 2017-02-10 | ||
Added: | ||
1. Add constructor options: | ||
@@ -54,3 +74,3 @@ * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) | ||
## [0.26.0][0.26.0] - 2016-01-20 | ||
## [0.26.0][0.26.0] - 2017-01-20 | ||
@@ -114,2 +134,3 @@ Added: | ||
[0.27.0]:https://github.com/yagop/node-telegram-bot-api/releases/tag/v0.27.0 | ||
[Unreleased]:https://github.com/yagop/node-telegram-bot-api/compare/v0.27.0...master | ||
[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 |
@@ -8,13 +8,9 @@ # Contributing | ||
1. [code of conduct][coc] | ||
1. [software license][license] | ||
1. [Code of Conduct][coc] | ||
1. [License][license] | ||
[coc]:https://github.com/yagop/node-telegram-bot-api/blob/master/CODE_OF_CONDUCT.md | ||
[license]:https://github.com/yagop/node-telegram-bot-api/blob/master/LICENSE.md | ||
## General Information | ||
### Updating API Reference i.e. generating `doc/api.md` | ||
### General Information | ||
**Updating API Reference i.e. generating `doc/api.md`:** | ||
Run: | ||
@@ -26,16 +22,8 @@ | ||
### Running tests | ||
--- | ||
**Running tests:** | ||
Please read `test/README.md` for more information. | ||
### Transpiling ES2015 for older Node.js versions | ||
--- | ||
**Transpiling ES6 for older Node.js versions:** | ||
We use babel to transpile the code: | ||
@@ -47,6 +35,3 @@ | ||
--- | ||
> E=mc² | ||
[coc]:https://github.com/yagop/node-telegram-bot-api/blob/master/CODE_OF_CONDUCT.md | ||
[license]:https://github.com/yagop/node-telegram-bot-api/blob/master/LICENSE.md |
# API Reference | ||
**Note:** If you are looking for available [events](usage.md#events) or usage of api, please refer [`usage.md`](usage.md). | ||
<a name="TelegramBot"></a> | ||
@@ -4,0 +6,0 @@ |
130
doc/help.md
@@ -6,29 +6,14 @@ # Help Information | ||
* * * | ||
<a name="pitfalls"></a> | ||
## Common Pitfalls | ||
1. [Failing to receive reply with `ReplyToMessage`](#reply-to-message) | ||
--- | ||
<a name="reply-to-message"></a> | ||
**Failing to receive reply with `ReplyToMessage`** | ||
### Failing to receive reply with `ReplyToMessage` | ||
The user has to **manually reply** to your message, by tapping on the | ||
bot's message and select *Reply*. | ||
The user has to **manually reply** to your message, by tapping on the bot's message and select *Reply*. | ||
Sources: | ||
* Issue #113: https://github.com/yagop/node-telegram-bot-api/issues/113 | ||
* Issue [#113](https://github.com/yagop/node-telegram-bot-api/issues/113) | ||
* * * | ||
<a name="faqs"></a> | ||
@@ -39,4 +24,2 @@ ## Frequently Asked Questions | ||
[questions]:https://github.com/yagop/node-telegram-bot-api/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20 | ||
1. [How do I send GIFs?](#gifs) | ||
@@ -52,7 +35,4 @@ 1. [Why and When do I need a certificate when using WebHooks?](#webhook-cert) | ||
--- | ||
<a name="gifs"></a> | ||
**How do I send GIFs?** | ||
### How do I send GIFs? | ||
@@ -63,5 +43,4 @@ You might be trying to send your animated GIFs using *TelegramBot#sendPhoto()*. | ||
```js | ||
bot.sendDocument(chatId, "cat.gif"); | ||
bot.sendDocument(chatId, 'cat.gif'); | ||
``` | ||
@@ -71,115 +50,84 @@ | ||
* Issue #11: https://github.com/yagop/node-telegram-bot-api/issues/11 | ||
* Issue [#11](https://github.com/yagop/node-telegram-bot-api/issues/11) | ||
--- | ||
<a name="webhook-cert"></a> | ||
**Why and When do I need a certificate when using WebHooks?** | ||
### Why and When do I need a certificate when using WebHooks? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #63: https://github.com/yagop/node-telegram-bot-api/issues/63 | ||
* Issue #125: https://github.com/yagop/node-telegram-bot-api/issues/125 | ||
* Issue [#63](https://github.com/yagop/node-telegram-bot-api/issues/63) | ||
* Issue [#125](https://github.com/yagop/node-telegram-bot-api/issues/125) | ||
--- | ||
<a name="leave-chat"></a> | ||
**How do I know when a user leaves a chat?** | ||
### How do I know when a user leaves a chat? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #248: https://github.com/yagop/node-telegram-bot-api/issues/248 | ||
* Issue [#248](https://github.com/yagop/node-telegram-bot-api/issues/248) | ||
--- | ||
<a name="error-meanings"></a> | ||
**What does this error mean?** | ||
### What does this error mean? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #73: https://github.com/yagop/node-telegram-bot-api/issues/73 | ||
* Issue #99: https://github.com/yagop/node-telegram-bot-api/issues/99 | ||
* Issue #101: https://github.com/yagop/node-telegram-bot-api/issues/101 | ||
* Issue #107: https://github.com/yagop/node-telegram-bot-api/issues/107 | ||
* Issue #156: https://github.com/yagop/node-telegram-bot-api/issues/156 | ||
* Issue #170: https://github.com/yagop/node-telegram-bot-api/issues/170 | ||
* Issue #244: https://github.com/yagop/node-telegram-bot-api/issues/244 | ||
* Issue [#73](https://github.com/yagop/node-telegram-bot-api/issues/73) | ||
* Issue [#99](https://github.com/yagop/node-telegram-bot-api/issues/99) | ||
* Issue [#101](https://github.com/yagop/node-telegram-bot-api/issues/101) | ||
* Issue [#107](https://github.com/yagop/node-telegram-bot-api/issues/107) | ||
* Issue [#156](https://github.com/yagop/node-telegram-bot-api/issues/156) | ||
* Issue [#170](https://github.com/yagop/node-telegram-bot-api/issues/170) | ||
* Issue [#244](https://github.com/yagop/node-telegram-bot-api/issues/244) | ||
--- | ||
<a name="reply-keyboard"></a> | ||
**How do I know the selected option in reply keyboard?** | ||
### How do I know the selected option in reply keyboard? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #108: https://github.com/yagop/node-telegram-bot-api/issues/108 | ||
* Issue [#108](https://github.com/yagop/node-telegram-bot-api/issues/108) | ||
--- | ||
<a name="ordered-sending"></a> | ||
**How do I send multiple message in correct sequence?** | ||
### How do I send multiple message in correct sequence? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #240: https://github.com/yagop/node-telegram-bot-api/issues/240 | ||
* Issue [#240](https://github.com/yagop/node-telegram-bot-api/issues/240) | ||
--- | ||
<a name="proxy"></a> | ||
**How do I run my bot behind a proxy?** | ||
### How do I run my bot behind a proxy? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
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 [#122](https://github.com/yagop/node-telegram-bot-api/issues/122) | ||
* Issue [#253](https://github.com/yagop/node-telegram-bot-api/issues/253) | ||
--- | ||
<a name="new-feature"></a> | ||
**Can you add feature X to the library?** | ||
### Can you add feature X to the library? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #238: https://github.com/yagop/node-telegram-bot-api/issues/238 | ||
* Issue [#238](https://github.com/yagop/node-telegram-bot-api/issues/238) | ||
--- | ||
<a name="scalable"></a> | ||
**Is this scalable?** | ||
### Is this scalable? | ||
*Not Done. Send PR please!* | ||
*Not done. PRs welcome!* | ||
Sources: | ||
* Issue #219: https://github.com/yagop/node-telegram-bot-api/issues/219 | ||
* Issue [#219](https://github.com/yagop/node-telegram-bot-api/issues/219) | ||
--- | ||
[questions]:https://github.com/yagop/node-telegram-bot-api/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20 |
# Usage | ||
1. [Events](#events) | ||
1. [WebHooks](#WebHooks) | ||
1. [Sending files](#sending-files) | ||
1. [Error handling](#error-handling) | ||
* [Events](#events) | ||
* [WebHooks](#WebHooks) | ||
* [Sending files](#sending-files) | ||
* [Error handling](#error-handling) | ||
* * * | ||
<a name="events"></a> | ||
@@ -42,13 +38,2 @@ ## Events | ||
[update]:https://core.telegram.org/bots/api#update | ||
[message]:https://core.telegram.org/bots/api#message | ||
[callback-query]:https://core.telegram.org/bots/api#callbackquery | ||
[inline-query]:https://core.telegram.org/bots/api#inlinequery | ||
[chosen-inline-result]:https://core.telegram.org/bots/api#choseninlineresult | ||
[inline-mode]:https://core.telegram.org/bots/api#inline-mode | ||
* * * | ||
<a name="webhooks"></a> | ||
@@ -74,4 +59,4 @@ ## WebHooks | ||
```js | ||
bot.setWebHook("public-url.com", { | ||
certificate: "path/to/crt.pem", // Path to your crt.pem | ||
bot.setWebHook('public-url.com', { | ||
certificate: 'path/to/crt.pem', // Path to your crt.pem | ||
}); | ||
@@ -84,8 +69,2 @@ ``` | ||
[issue-63]:https://github.com/yagop/node-telegram-bot-api/issues/63 | ||
* * * | ||
<a name="sending-files"></a> | ||
@@ -99,3 +78,3 @@ ## Sending files | ||
```js | ||
bot.sendAudio(chatId, "path/to/audio.mp3"); | ||
bot.sendAudio(chatId, 'path/to/audio.mp3'); | ||
``` | ||
@@ -107,3 +86,3 @@ | ||
```js | ||
const stream = fs.createReadStream("path/to/audio.mp3"); | ||
const stream = fs.createReadStream('path/to/audio.mp3'); | ||
bot.sendAudio(chatId, stream); | ||
@@ -116,3 +95,3 @@ ``` | ||
```js | ||
const buffer = fs.readFileSync("path/to/audio.mp3"); // sync! that's sad! :-( Just making a point! | ||
const buffer = fs.readFileSync('path/to/audio.mp3'); // sync! that's sad! :-( Just making a point! | ||
bot.sendAudio(chatId, buffer); | ||
@@ -133,3 +112,3 @@ ``` | ||
```js | ||
const url = "https://telegram.org/img/t_logo.png"; | ||
const url = 'https://telegram.org/img/t_logo.png'; | ||
bot.sendPhoto(chatId, url); | ||
@@ -139,3 +118,3 @@ ``` | ||
<a name="sending-files-performance"></a> | ||
### Performance Issue: | ||
### Performance Issue | ||
@@ -160,3 +139,2 @@ To support providing file-paths to methods that send files involves | ||
<a name="error-handling"></a> | ||
@@ -180,3 +158,3 @@ ## Error handling | ||
```js | ||
bot.sendMessage(nonExistentUserId, 'text').catch(error => { | ||
bot.sendMessage(nonExistentUserId, 'text').catch((error) => { | ||
console.log(error.code); // => 'ETELEGRAM' | ||
@@ -188,3 +166,3 @@ console.log(error.response.body); // => { ok: false, error_code: 400, description: 'Bad Request: chat not found' } | ||
<a name="polling-errors"></a> | ||
#### Polling errors | ||
## Polling errors | ||
@@ -207,3 +185,3 @@ An error may occur during polling. It is up to you to handle it | ||
<a name="webhook-errors"></a> | ||
#### WebHook errors | ||
## WebHook errors | ||
@@ -220,1 +198,9 @@ Just like with [polling errors](#polling-errors), you decide on how to | ||
``` | ||
[update]:https://core.telegram.org/bots/api#update | ||
[message]:https://core.telegram.org/bots/api#message | ||
[callback-query]:https://core.telegram.org/bots/api#callbackquery | ||
[inline-query]:https://core.telegram.org/bots/api#inlinequery | ||
[chosen-inline-result]:https://core.telegram.org/bots/api#choseninlineresult | ||
[inline-mode]:https://core.telegram.org/bots/api#inline-mode | ||
[issue-63]:https://github.com/yagop/node-telegram-bot-api/issues/63 |
/** | ||
* If running on Nodejs 4.x and below, we load the transpiled code. | ||
* If running on Nodejs 5.x and below, we load the transpiled code. | ||
* Otherwise, we use the ES6 code. | ||
* We are deprecating support for Node.js v4.x and below. | ||
* We are deprecating support for Node.js v5.x and below. | ||
*/ | ||
const majorVersion = parseInt(process.versions.node.split('.')[0], 10); | ||
if (majorVersion <= 4) { | ||
if (majorVersion <= 5) { | ||
const deprecate = require('depd')('node-telegram-bot-api'); | ||
deprecate('Node.js v4.x and below will no longer be supported in the future'); | ||
deprecate('Node.js v5.x and below will no longer be supported in the future'); | ||
module.exports = require('./lib/telegram'); | ||
@@ -11,0 +11,0 @@ } else { |
@@ -27,7 +27,6 @@ 'use strict'; | ||
this.options.params.offset = typeof this.options.params.offset === 'number' ? this.options.params.offset : 0; | ||
this.options.params.timeout = typeof this.options.params.timeout === 'number' ? this.options.params.timeout : 10; | ||
if (typeof this.options.timeout === 'number') { | ||
deprecate('`options.polling.timeout` is deprecated. Use `options.polling.params` instead.'); | ||
this.options.params.timeout = this.options.timeout; | ||
} else { | ||
this.options.params.timeout = 10; | ||
} | ||
@@ -34,0 +33,0 @@ this._lastUpdate = 0; |
The MIT License (MIT) | ||
Copyright (c) 2015 Yago | ||
Copyright (c) 2017 Yago | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "node-telegram-bot-api", | ||
"version": "0.27.0", | ||
"version": "0.27.1", | ||
"description": "Telegram Bot API", | ||
@@ -418,2 +418,2 @@ "main": "./index.js", | ||
] | ||
} | ||
} |
@@ -1,30 +0,32 @@ | ||
[![Bot API](http://img.shields.io/badge/Bot API-v2.3.1-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/💬 Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api) | ||
[![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬 Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez) | ||
# Node.js Telegram Bot API | ||
[![Bot API](http://img.shields.io/badge/Bot%20API-v2.3.1-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) | ||
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. | ||
**Installation:** | ||
## Install | ||
```sh | ||
npm install node-telegram-bot-api | ||
```bash | ||
npm install --save node-telegram-bot-api | ||
``` | ||
**Sample Usage:** | ||
## Usage | ||
```js | ||
var TelegramBot = require('node-telegram-bot-api'); | ||
const TelegramBot = require('node-telegram-bot-api'); | ||
// replace the value below with the Telegram token you receive from @BotFather | ||
var token = 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
const token = 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
// Create a bot that uses 'polling' to fetch new updates | ||
var bot = new TelegramBot(token, { polling: true }); | ||
const bot = new TelegramBot(token, {polling: true}); | ||
// Matches "/echo [whatever]" | ||
bot.onText(/\/echo (.+)/, function (msg, match) { | ||
bot.onText(/\/echo (.+)/, (msg, match) => { | ||
// 'msg' is the received Message from Telegram | ||
@@ -34,4 +36,4 @@ // 'match' is the result of executing the regexp above on the text content | ||
var chatId = msg.chat.id; | ||
var resp = match[1]; // the captured "whatever" | ||
const chatId = msg.chat.id; | ||
const resp = match[1]; // the captured "whatever" | ||
@@ -44,21 +46,17 @@ // send back the matched "whatever" to the chat | ||
// messages. | ||
bot.on('message', function (msg) { | ||
var chatId = msg.chat.id; | ||
bot.on('message', (msg) => { | ||
const chatId = msg.chat.id; | ||
// send a message to the chat acknowledging receipt of their message | ||
bot.sendMessage(chatId, "Received your message"); | ||
bot.sendMessage(chatId, 'Received your message'); | ||
}); | ||
``` | ||
* * * | ||
## Documentation | ||
* [Usage][usage] | ||
* [Examples][examples] | ||
* [Help Information][help] | ||
* API Reference ([release][api-release] / [development][api-dev]) | ||
* [Contributing to the Project][contributing] | ||
* [Usage][usage] | ||
* [Examples][examples] | ||
* [Help Information][help] | ||
* API Reference ([release][api-release] / [development][api-dev]) | ||
* [Contributing to the Project][contributing] | ||
@@ -68,16 +66,4 @@ _**Note**: Development is done against the **master** branch. Code for the latest release | ||
## Community | ||
[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 | ||
[help]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/help.md | ||
[api-dev]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/api.md | ||
[api-release]:https://github.com/yagop/node-telegram-bot-api/tree/release/doc/api.md | ||
[contributing]:https://github.com/yagop/node-telegram-bot-api/tree/master/CONTRIBUTING.md | ||
* * * | ||
## Our Community | ||
We have a [Telegram channel][tg-channel] where we post updates on | ||
@@ -91,14 +77,16 @@ the Project. Head over and subscribe! | ||
* [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 | ||
## License | ||
* * * | ||
## License Information | ||
**The MIT License (MIT)** | ||
Copyright (c) 2015 Yago | ||
Copyright (c) 2017 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 | ||
[help]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/help.md | ||
[api-dev]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/api.md | ||
[api-release]:https://github.com/yagop/node-telegram-bot-api/tree/release/doc/api.md | ||
[contributing]:https://github.com/yagop/node-telegram-bot-api/tree/master/CONTRIBUTING.md | ||
[tg-channel]:https://telegram.me/node_telegram_bot_api |
@@ -18,7 +18,6 @@ const debug = require('debug')('node-telegram-bot-api'); | ||
this.options.params.offset = (typeof this.options.params.offset === 'number') ? this.options.params.offset : 0; | ||
this.options.params.timeout = (typeof this.options.params.timeout === 'number') ? this.options.params.timeout : 10; | ||
if (typeof this.options.timeout === 'number') { | ||
deprecate('`options.polling.timeout` is deprecated. Use `options.polling.params` instead.'); | ||
this.options.params.timeout = this.options.timeout; | ||
} else { | ||
this.options.params.timeout = 10; | ||
} | ||
@@ -25,0 +24,0 @@ this._lastUpdate = 0; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191296
3042
89