module Tourmaline::Client::WebhookMethods

Direct including types

Defined in:

tourmaline/client/webhook_methods.cr

Instance Method Summary

Instance Method Detail

def delete_webhook(drop_pending_updates = false) #

Use this method to remove webhook integration if you decide to switch back to getUpdates.


[View source]
def get_webhook_info #

Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using #getUpdates, will return an object with the url field empty.


[View source]
def serve(host = "127.0.0.1", port = 8081, ssl_certificate_path = nil, ssl_key_path = nil, no_middleware_check = false, &block : HTTP::Server::Context -> ) #

Start an HTTP server at the specified host and port that listens for updates using Telegram's webhooks. This is the reccommended way to handle bots in production.

Note: Don't forget to call #set_webhook first! This method does not do it for you.


[View source]
def serve(path = "/", host = "127.0.0.1", port = 8081, ssl_certificate_path = nil, ssl_key_path = nil, no_middleware_check = false) #

Start an HTTP server at the specified host and port that listens for updates using Telegram's webhooks. This is the reccommended way to handle bots in production.

Note: Don't forget to call #set_webhook first! This method does not do it for you.


[View source]
def set_webhook(url, ip_address = nil, certificate = nil, max_connections = nil, allowed_updates = nil, drop_pending_updates = false, secret_token = nil) #

Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns true on success.

If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.


[View source]
def stop_serving #

Stops the webhook HTTP server


[View source]
def unset_webhook #

Use this to unset the webhook and stop receiving updates to your bot.


[View source]