class Tourmaline::Client
inherits Reference
#
The Client
class is the base class for all Tourmaline based bots.
Extend this class to create your own bots, or create an
instance of Client
and add event handlers to it.
Included modules
Tourmaline::Client::Api
Tourmaline::Logger
Constants#
DEFAULT_API_URL = "https://api.telegram.org/"
#
"https://api.telegram.org/"
Constructors#
.new(bot_token : String, endpoint = DEFAULT_API_URL, default_parse_mode : ParseMode = ParseMode::Markdown, pool_capacity = 200, initial_pool_size = 20, pool_timeout = 0.1, proxy = nil, proxy_uri = nil, proxy_host = nil, proxy_port = nil, proxy_user = nil, proxy_pass = nil)
#
(bot_token : String, endpoint = DEFAULT_API_URL, default_parse_mode : ParseMode = ParseMode::Markdown, pool_capacity = 200, initial_pool_size = 20, pool_timeout = 0.1, proxy = nil, proxy_uri = nil, proxy_host = nil, proxy_port = nil, proxy_user = nil, proxy_pass = nil)
Create a new instance of Tourmaline::Client
.
Named Arguments#
bot_token
- the bot token you should've received from
@BotFather
endpoint
- the API endpoint to use for requests; default is
https://api.telegram.org
, but for TDLight methods to work you may consider hosting your own instance or using one of the official ones such ashttps://telegram.rest
default_parse_mode
- the default parse mode to use for messages; default is
ParseMode::None
(no formatting) pool_capacity
- the maximum number of concurrent HTTP connections to use
initial_pool_size
- the number of HTTP::Client instances to create on init
pool_timeout
- How long to wait for a new client to be available if the pool is full before throwing a
TimeoutError
proxy
- an instance of
HTTP::Proxy::Client
to use; if set, overrides the followingproxy_
args proxy_uri
- a URI to use when connecting to the proxy; can be a
URI
instance or a String proxy_host
- if no
proxy_uri
is provided, this will be the host for the URI proxy_port
- if no
proxy_uri
is provided, this will be the port for the URI proxy_user
- a username to use for a proxy that requires authentication
proxy_pass
- a password to use for a proxy that requires authentication
Class methods#
.build_inline_keyboard_markup(*args, columns = nil, **options, &block : InlineKeyboardMarkupBuilder -> )
#
(*args, columns = nil, **options, &block : InlineKeyboardMarkupBuilder -> )
.build_reply_keyboard_markup(*args, columns = nil, **options, &block : ReplyKeyboardMarkupBuilder -> )
#
(*args, columns = nil, **options, &block : ReplyKeyboardMarkupBuilder -> )
Methods#
#bot : User
#
: User
Gets the name of the Client at the time the Client was
started. Refreshing can be done by setting
@bot
to get_me
.
#bot? : User?
#
: User?
Gets the name of the Client at the time the Client was
started. Refreshing can be done by setting
@bot
to get_me
.
#build_inline_keyboard_markup(*args, columns = nil, **options, &block : InlineKeyboardMarkupBuilder -> )
#
(*args, columns = nil, **options, &block : InlineKeyboardMarkupBuilder -> )
#build_reply_keyboard_markup(*args, columns = nil, **options, &block : ReplyKeyboardMarkupBuilder -> )
#
(*args, columns = nil, **options, &block : ReplyKeyboardMarkupBuilder -> )
#request(type : U.class, method, params = {} of String => String) forall U
#
(type : U.class, method, params = {} of String => String) forall U
Sends a request to the Telegram Client API. Returns the response, parsed as a U
.
#request_raw(method : String, params = {} of String => String)
#
(method : String, params = {} of String => String)
Sends a request to the Telegram Client API. Returns the raw response.
#serve(path = "/", host = "127.0.0.1", port = 8081, ssl_certificate_path = nil, ssl_key_path = nil, no_middleware_check = false)
#
(path = "/", host = "127.0.0.1", port = 8081, ssl_certificate_path = nil, ssl_key_path = nil, no_middleware_check = false)