new TelegramClient(token, generateMethodsopt, extraOptionsopt)
Construct a telegram bot client
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
token |
string | Telegram bot api token | ||
generateMethods |
boolean |
<optional> |
false | generate named properties for api methods (not recommended) |
extraOptions |
Object |
<optional> |
{} | extra options to be applied to to https.request |
- Source:
Extends
- EventEmitter
Methods
listen(allowedUpdates, setWebhookopt, urlopt)
Set a webhook to listen for updates. Self signed certificates are not supported. (not implemented yet)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
allowedUpdates |
Array.<string> | array of updates to poll for | ||
setWebhook |
boolean |
<optional> |
false | configure telegram to set the webhook with the given url |
url |
string |
<optional> |
url for telegram to send updates to |
- Source:
poll(allowedUpdates, interval, deleteWebhookopt)
Poll for updates. Updates are emitted as events
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
allowedUpdates |
Array.<string> | array of updates to poll for | ||
interval |
number | polling interval | ||
deleteWebhook |
boolean |
<optional> |
false | delete any previously set webook (not implemented) |
- Source:
Fires:
request(method, argsopt, cbopt)
Send an api request to telegram
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
method |
string | API method to call | ||
args |
Object |
<optional> |
{} | API call arguments |
cb |
TelegramClient~requestCallback |
<optional> |
The callback that handles the response |
- Source:
Type Definitions
requestCallback(err, response)
Parameters:
Name | Type | Description |
---|---|---|
err |
Error | |
response |
Object |
- Source:
Events
update
Update event
Type:
- object
- Source: