class Hamilton::Bot

Overview

Hamilton::Bot implementation variant.

Defined in:

bot.cr

Constructors

Instance Method Summary

Instance methods inherited from class Reference

==(other : Hamilton::Any) ==

Instance methods inherited from class Object

===(other : Hamilton::Any) ===

Constructor Detail

def self.new(*, offset = 0, timeout = 20, token : String, url : String = "https://api.telegram.org", env : Symbol = :prod, &handler : Hamilton::Handler::HandlerProc) : self #

Creates a bot provided #offset, #timeout, api instance created from token and url for env, and the given block as handler.


def self.new(*, offset = 0, timeout = 20, api : Hamilton::Api, &handler : Hamilton::Handler::HandlerProc) : self #

Creates a bot provided #offset, #timeout, #api, and the given block as handler.


def self.new(*, offset = 0, timeout = 20, token, url = "https://api.telegram.org", env = :prod, handlers : Indexable(Hamilton::Handler), &handler : Hamilton::Handler::HandlerProc) : self #

Creates a bot provided #offset, #timeout, api instance created from token and url for env, and a handler chain constructed from the handlers array and the given block.


def self.new(*, offset = 0, timeout = 20, api : Hamilton::Api, handlers : Indexable(Hamilton::Handler), &handler : Hamilton::Handler::HandlerProc) : self #

Creates a bot provided #offset, #timeout, #api, and a handler chain constructed from the handlers array and the given block.


def self.new(*, offset = 0, timeout = 20, token, url = "https://api.telegram.org", env = :prod, handlers : Indexable(Hamilton::Handler)) : self #

Creates a bot provided #offset, #timeout, api instance created from token and url for env, and the handlers array as handler chain.


def self.new(*, offset = 0, timeout = 20, api : Hamilton::Api, handlers : Indexable(Hamilton::Handler)) : self #

Creates a bot provided #offset, #timeout, #api, and the handlers array as handler chain.


def self.new(*, offset : Int32 = 0, timeout : Int32 = 20, api : Hamilton::Api, handler : Hamilton::Handler | Hamilton::Handler::HandlerProc) #

Instance Method Detail

def api : Hamilton::Api #

API instance to be used inside the Bot.


def api=(api : Hamilton::Api) #

API instance to be used inside the Bot.


Chain of handlers.


Chain of handlers.


def listen #

Start listening for the updates with long pooling.


def log : Log #

Logger instance.


def log=(log : Log) #

Logger instance.


def offset : Int32 #

Offset of the updates, i.e. the number of the first update to be handled.


def offset=(offset : Int32) #

Offset of the updates, i.e. the number of the first update to be handled.


def stop #

Stop listening for the updates.

One of the ways to call it is:

Signal::INT.trap do
  puts bot.stop
end

def timeout : Int32 #

Timeout in seconds for long polling.


def timeout=(timeout : Int32) #

Timeout in seconds for long polling.