mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-31 06:16:07 +00:00
doc: Document TelegramBot#on()
References: * Issue: https://github.com/yagop/node-telegram-bot-api/issues/436
This commit is contained in:
19
doc/api.md
19
doc/api.md
@@ -13,6 +13,7 @@ TelegramBot
|
||||
* [TelegramBot](#TelegramBot)
|
||||
* [new TelegramBot(token, [options])](#new_TelegramBot_new)
|
||||
* _instance_
|
||||
* [.on(event, listener)](#TelegramBot+on)
|
||||
* [.startPolling([options])](#TelegramBot+startPolling) ⇒ <code>Promise</code>
|
||||
* ~~[.initPolling([options])](#TelegramBot+initPolling) ⇒ <code>Promise</code>~~
|
||||
* [.stopPolling()](#TelegramBot+stopPolling) ⇒ <code>Promise</code>
|
||||
@@ -116,6 +117,24 @@ Emits `message` when a message arrives.
|
||||
| [options.baseApiUrl] | <code>String</code> | <code>https://api.telegram.org</code> | API Base URl; useful for proxying and testing |
|
||||
| [options.filepath] | <code>Boolean</code> | <code>true</code> | Allow passing file-paths as arguments when sending files, such as photos using `TelegramBot#sendPhoto()`. See [usage information][usage-sending-files-performance] for more information on this option and its consequences. |
|
||||
|
||||
<a name="TelegramBot+on"></a>
|
||||
|
||||
### telegramBot.on(event, listener)
|
||||
Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events).
|
||||
This is the usual `emitter.on()` method.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**
|
||||
|
||||
- [Available events](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events)
|
||||
- https://nodejs.org/api/events.html#events_emitter_on_eventname_listener
|
||||
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| event | <code>String</code> |
|
||||
| listener | <code>function</code> |
|
||||
|
||||
<a name="TelegramBot+startPolling"></a>
|
||||
|
||||
### telegramBot.startPolling([options]) ⇒ <code>Promise</code>
|
||||
|
@@ -96,6 +96,14 @@ class TelegramBot extends EventEmitter {
|
||||
Promise = customPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events).
|
||||
* This is the usual `emitter.on()` method.
|
||||
* @param {String} event
|
||||
* @param {Function} listener
|
||||
* @see {@link https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events|Available events}
|
||||
* @see https://nodejs.org/api/events.html#events_emitter_on_eventname_listener
|
||||
*/
|
||||
on(event, listener) {
|
||||
if (_deprecatedMessageTypes.indexOf(event) !== -1) {
|
||||
const url = 'https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events';
|
||||
|
Reference in New Issue
Block a user