Webhook constructor

Webhook(
  1. Telegram telegram,
  2. String url,
  3. HttpServer _server, {
  4. String? ipAddress,
  5. File? certificate,
  6. File? privateKey,
  7. int port = 443,
  8. int? serverPort,
  9. bool uploadCertificate = false,
  10. int maxConnections = 40,
  11. List<String>? allowedUpdates,
  12. bool? dropPendingUpdates,
  13. String? secretToken,
})

Setup webhook

Webhook server listens to port by default, set serverPort to override.

Set url as host name e.g. https://example.com.

Default port is 443, Telegram API supports 443, 80, 88, 8443. Provide privateKey and certificate pair for HTTPS configuration

Throws WebhookException if port is not supported by Telegram or maxConnections is less than 1 or greater than 100.

Implementation

Webhook(this.telegram, this.url, this._server,
    {this.ipAddress,
    this.certificate,
    this.privateKey,
    this.port = 443,
    this.serverPort,
    this.uploadCertificate = false,
    this.maxConnections = 40,
    this.allowedUpdates,
    this.dropPendingUpdates,
    this.secretToken}) {
  if (![443, 80, 88, 8443].contains(port)) {
    throw WebhookException(
        'Ports currently supported for Webhooks: 443, 80, 88, 8443.');
  }
  if (maxConnections > 100 || maxConnections < 1) {
    throw WebhookException('Connection limit must between 1 and 100.');
  }
}