class

Hamilton::Bot

Inherits Reference < Object

Hamilton::Bot implementation variant.

Constructors

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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
new(*, offset : Int32 = 0, timeout : Int32 = 20, api : Hamilton::Api, handler : Hamilton::Handler | Hamilton::Handler::HandlerProc)
Source

Instance methods

api

API instance to be used inside the Bot.

Source
api=(api : Hamilton::Api)

API instance to be used inside the Bot.

Source
handler

Chain of handlers.

Source

Chain of handlers.

Source
listen

Start listening for the updates with long pooling.

Source
log

Logger instance.

Source
log=(log : Log)

Logger instance.

Source
offset

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

Source
offset=(offset : Int32)

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

Source
stop

Stop listening for the updates.

One of the ways to call it is:

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

Timeout in seconds for long polling.

Source
timeout=(timeout : Int32)

Timeout in seconds for long polling.

Source