mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 13:27:44 +00:00
Update doc
This commit is contained in:
parent
385590ef3f
commit
874feaf833
@ -32,7 +32,7 @@ bot.on('message', function (msg) {
|
|||||||
There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples).
|
There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples).
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content.
|
Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content.
|
||||||
TelegramBot emits `inline_query` when receives an [https://core.telegram.org/bots/api#inlinequery](Inline Query) and `chosen_inline_result` when receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode)
|
TelegramBot emits `inline_query` when receives an [https://core.telegram.org/bots/api#inlinequery](Inline Query) and `chosen_inline_result` when receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode)
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
|
19
README.md
19
README.md
@ -32,7 +32,8 @@ bot.on('message', function (msg) {
|
|||||||
There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples).
|
There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples).
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content.
|
Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content.
|
||||||
|
TelegramBot emits `inline_query` when receives an [https://core.telegram.org/bots/api#inlinequery](Inline Query) and `chosen_inline_result` when receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode)
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
### WebHooks
|
### WebHooks
|
||||||
@ -60,6 +61,7 @@ TelegramBot
|
|||||||
* [.setWebHook(url, [cert])](#TelegramBot+setWebHook)
|
* [.setWebHook(url, [cert])](#TelegramBot+setWebHook)
|
||||||
* [.getUpdates([timeout], [limit], [offset])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
* [.getUpdates([timeout], [limit], [offset])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
||||||
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
||||||
|
* [.answerInlineQuery(inlineQueryId, results, [options])](#TelegramBot+answerInlineQuery) ⇒ <code>Promise</code>
|
||||||
* [.forwardMessage(chatId, fromChatId, messageId)](#TelegramBot+forwardMessage) ⇒ <code>Promise</code>
|
* [.forwardMessage(chatId, fromChatId, messageId)](#TelegramBot+forwardMessage) ⇒ <code>Promise</code>
|
||||||
* [.sendPhoto(chatId, photo, [options])](#TelegramBot+sendPhoto) ⇒ <code>Promise</code>
|
* [.sendPhoto(chatId, photo, [options])](#TelegramBot+sendPhoto) ⇒ <code>Promise</code>
|
||||||
* [.sendAudio(chatId, audio, [options])](#TelegramBot+sendAudio) ⇒ <code>Promise</code>
|
* [.sendAudio(chatId, audio, [options])](#TelegramBot+sendAudio) ⇒ <code>Promise</code>
|
||||||
@ -138,6 +140,19 @@ Send text message.
|
|||||||
| text | <code>String</code> | Text of the message to be sent |
|
| text | <code>String</code> | Text of the message to be sent |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+answerInlineQuery"></a>
|
||||||
|
### telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ <code>Promise</code>
|
||||||
|
Send answers to an inline query.
|
||||||
|
|
||||||
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
|
**See**: https://core.telegram.org/bots/api#answerinlinequery
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| inlineQueryId | <code>String</code> | Unique identifier of the query |
|
||||||
|
| results | <code>Array.<InlineQueryResult></code> | An array of results for the inline query |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+forwardMessage"></a>
|
<a name="TelegramBot+forwardMessage"></a>
|
||||||
### telegramBot.forwardMessage(chatId, fromChatId, messageId) ⇒ <code>Promise</code>
|
### telegramBot.forwardMessage(chatId, fromChatId, messageId) ⇒ <code>Promise</code>
|
||||||
Forward messages of any kind.
|
Forward messages of any kind.
|
||||||
@ -212,7 +227,7 @@ Use this method to send video files, Telegram clients support mp4 videos (other
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| video | <code>String</code> | <code>stream.Stream</code> | A file path or Stream. Can also be a `file_id` previously uploaded. |
|
| video | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path or Stream. Can also be a `file_id` previously uploaded. |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+sendVoice"></a>
|
<a name="TelegramBot+sendVoice"></a>
|
||||||
|
@ -92,10 +92,10 @@ TelegramBot.prototype._processUpdate = function (update) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if(inline_query) {
|
} else if (inline_query) {
|
||||||
debug('Process Update inline_query %j', inline_query);
|
debug('Process Update inline_query %j', inline_query);
|
||||||
this.emit('inline_query', inline_query);
|
this.emit('inline_query', inline_query);
|
||||||
} else if(chosen_inline_result) {
|
} else if (chosen_inline_result) {
|
||||||
debug('Process Update chosen_inline_result %j', chosen_inline_result);
|
debug('Process Update chosen_inline_result %j', chosen_inline_result);
|
||||||
this.emit('chosen_inline_result', chosen_inline_result);
|
this.emit('chosen_inline_result', chosen_inline_result);
|
||||||
}
|
}
|
||||||
@ -217,15 +217,15 @@ TelegramBot.prototype.sendMessage = function (chatId, text, options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send answers to an inline query.
|
* Send answers to an inline query.
|
||||||
* @param {String} queryId Unique identifier of the query
|
* @param {String} inlineQueryId Unique identifier of the query
|
||||||
* @param {Array of InlineQueryResult} results An array of results for the inline query
|
* @param {InlineQueryResult[]} results An array of results for the inline query
|
||||||
* @param {Object} [options] Additional Telegram query options
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#answerinlinequery
|
* @see https://core.telegram.org/bots/api#answerinlinequery
|
||||||
*/
|
*/
|
||||||
TelegramBot.prototype.answerInlineQuery = function (inline_query_id, results, options) {
|
TelegramBot.prototype.answerInlineQuery = function (inlineQueryId, results, options) {
|
||||||
var form = options || {};
|
var form = options || {};
|
||||||
form.inline_query_id = inline_query_id;
|
form.inline_query_id = inlineQueryId;
|
||||||
form.results = JSON.stringify(results);
|
form.results = JSON.stringify(results);
|
||||||
return this._request('answerInlineQuery', {form: form});
|
return this._request('answerInlineQuery', {form: form});
|
||||||
};
|
};
|
||||||
@ -374,7 +374,7 @@ TelegramBot.prototype.sendSticker = function (chatId, sticker, options) {
|
|||||||
/**
|
/**
|
||||||
* Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
|
* Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {String|stream.Stream} video A file path or Stream.
|
* @param {String|stream.Stream|Buffer} video A file path or Stream.
|
||||||
* Can also be a `file_id` previously uploaded.
|
* Can also be a `file_id` previously uploaded.
|
||||||
* @param {Object} [options] Additional Telegram query options
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user