Classes

Opengram

Type Definitions

LaunchConfig

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
dropPendingUpdatesboolean<optional>
false

If sets to true, dropping all pending updates which were sent when bots bot not was started

pollingPollingConfig<optional>

Polling configuration

webhookWebhookConfig<optional>

Webhook configuration

allowedUpdatesArray.<UpdateType><optional>

Array of allowed updates for webhook. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.

LaunchWebhookOptions

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
pathstring<optional>
'/opengram'

Path the server should listen to. By default - /opengram or with enabled useSecretPath - /opengram/<secret>

secretstring

A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

If not specified, generates an automatic

OpengramOptions

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
telegramTelegramOptions

Telegram options

usernamestring<optional>

Bot username, used if you don't call bot.launch()

channelModeboolean<optional>
false

If true, channel posts can be matched as text update type

retryAfternumber<optional>
1

Interval for retrying long-polling requests in seconds

handlerTimeoutInfinity | number<optional>
2000

Maximum interval waiting update processing with long-polling, before getting new updates. Pass Infinity to always wait for processing complete. Pass 0 (zero) for disable waiting

contextTypeOpengramContext<optional>

Custom context class

PollingConfig

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
stopCallbackfunction<optional>

Function called when bot fully stopped. If you call bot.stop() it be rewritten with other function and never called, for using with bot.stop, you can pass callback into bot.stop argument, for example bot.stop(() => console.log('Stopped'))

allowedUpdatesUpdateType | Array.<UpdateType><optional>

Array of allowed updates or update name For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.

limitnumber<optional>
100

Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.

timeoutnumber<optional>
30

Timeout in seconds for long polling. Defaults to 30

StartWebhookOptions

Type:
  • object
Properties
NameTypeAttributesDescription
pathstring

Path the server should listen to.

secretstring<optional>

A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

WebhookCallbackOptions

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
pathstring<optional>
'/'

Path the server should listen to.

secretstring<optional>

A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

WebhookConfig

Type:
  • object
Properties
NameTypeAttributesDefaultDescription
useSecretPathboolean<optional>
true

Enable legacy mode by using the secret in the URL instead of the secret header.

domainstring

Your external server domain For example - example.com, https://exmaple.com, http://exmaple.com. Used for Opengram.telegram.setWebhook

optionsLaunchWebhookOptions

Webhook options object. See Opengram#startWebhook for more information

tlsOptionsobject

Options for TLS. See Opengram#startWebhook for more information

cbfunction

Next handler function, called when webhook handler not match path string or request method. See Opengram#startWebhook for more information

portnumber

Port number. See Opengram#startWebhook for more information

hoststring

Hostname. See Opengram#startWebhook for more information

ipAddressstring<optional>

The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS

maxConnectionsnumber<optional>
40

The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.