class
Hamilton::Bot
- Hamilton::Bot
- Reference
- Object
Overview
Hamilton::Bot implementation variant.
Defined in:
bot.crConstructors
- .new(*, offset = 0, timeout = 20, token : String, url : String = "https://api.telegram.org", env : Symbol = :prod, &handler : Hamilton::Handler::HandlerProc) : self
- .new(*, offset = 0, timeout = 20, api : Hamilton::Api, &handler : Hamilton::Handler::HandlerProc) : self
- .new(*, offset = 0, timeout = 20, token, url = "https://api.telegram.org", env = :prod, handlers : Indexable(Hamilton::Handler), &handler : Hamilton::Handler::HandlerProc) : self
- .new(*, offset = 0, timeout = 20, api : Hamilton::Api, handlers : Indexable(Hamilton::Handler), &handler : Hamilton::Handler::HandlerProc) : self
- .new(*, offset = 0, timeout = 20, token, url = "https://api.telegram.org", env = :prod, handlers : Indexable(Hamilton::Handler)) : self
- .new(*, offset = 0, timeout = 20, api : Hamilton::Api, handlers : Indexable(Hamilton::Handler)) : self
- .new(*, offset : Int32 = 0, timeout : Int32 = 20, api : Hamilton::Api, handler : Hamilton::Handler | Hamilton::Handler::HandlerProc)
Instance Method Summary
-
#api : Hamilton::Api
API instance to be used inside the Bot.
-
#api=(api : Hamilton::Api)
API instance to be used inside the Bot.
-
#handler : Hamilton::Handler | Hamilton::Handler::HandlerProc
Chain of handlers.
-
#handler=(handler : Hamilton::Handler | Hamilton::Handler::HandlerProc)
Chain of handlers.
-
#listen
Start listening for the updates with long pooling.
-
#log : Log
Logger instance.
-
#log=(log : Log)
Logger instance.
-
#offset : Int32
Offset of the updates, i.e.
-
#offset=(offset : Int32)
Offset of the updates, i.e.
-
#stop
Stop listening for the updates.
-
#timeout : Int32
Timeout in seconds for long polling.
-
#timeout=(timeout : Int32)
Timeout in seconds for long polling.
Instance methods inherited from class Reference
==(other : Hamilton::Any)
==
Instance methods inherited from class Object
===(other : Hamilton::Any)
===
Constructor Detail
Creates a bot provided #offset, #timeout, api instance created from token and url for env, and the given block as handler.
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.
Creates a bot provided #offset, #timeout, #api, and a handler chain constructed from the handlers
array and the given block.
Creates a bot provided #offset, #timeout, api instance created from token and url for env, and the handlers array as handler chain.
Instance Method Detail
Offset of the updates, i.e. the number of the first update to be handled.
Stop listening for the updates.
One of the ways to call it is:
Signal::INT.trap do
puts bot.stop
end