Constructor
new ApiClient(token, optionsopt, webhookResponseopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
token | string | Bot token | |
options | TelegramOptions | <optional> | Options |
webhookResponse | http. | <optional> | Response object from HTTP server for reply via webhook if enabled |
- Source
Members
webhookReply
Setter for webhookReply
Use this property to control reply via webhook feature.
- Source
webhookReply
Getter for webhookReply
Use this property to control reply via webhook feature.
- Source
Methods
(async) callApi(method, dataopt, extraopt) → {Promise.<(object|boolean|number)>}
Method for direct call telegram bots api methods
Takes an optional AbortSignal
object that allows to cancel the API call if desired.
For example:
const controller = new AbortController();
const signal = controller.signal;
ctx.telegram.callApi ('getMe', {}, { signal })
.then(console.log)
.catch(err => {
if (err instanceof AbortError) {
console.log('API call aborted')
} else throw err
})
controller.abort(); // Abort request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
method | string | Telegram API method name | |
data | object | <optional> | Object with method parameters |
extra | CallApiExtra | <optional> | Extra parameters |
- Source
Returns:
- Type:
- Promise.<(object|boolean|number)>