Telebot::Plugin::Telegram - Telegram API plugin
# { # message => 'Telebot::Handler::Message', # poll => 'My::Bot::Handler::Poll', # } my $handlers = $app->tg->handlers(); # 'Telebot::Handler::Message' my $message_handler = $app->tg->handler('message'); # 'z8HcRt7Z6wj3E7bwk2pOZx4s' my $token = $app->tg->gentoken(); # 'https://api.telegram.org/botTOKEN/getMe' my $url = $app->tg->url('getMe'); # Requests to API my $response = $app->tg->request(getMe => {}); my $response = $app->tg->request(sendMessage => { chat_id => 777, text => 'Hello, Telegram', }); # c('message', 'poll') my $allowed_updates = $app->tg->allowed_updates; # c({ # command => 'start', # bot => 'megabot', # }, { # command => 'stop', # bot => undef, # }) $app->tg->extract_commands( 'Please /start@megabot and /stop', [{ type => 'command', offset => 7, length => 14, }, { type => 'command', offset => 26, length => 5, }] );
Telebot::Plugin::Telegram - plugin for working with Telegram API.
Telebot::Plugin::Telegram implements the following helpers.
Returns hash of registered handlers of update and it's parts. Key - update or name of update field, value - name of handler module.
Returns name of handler module for update or update part.
Returns generated token (random string from alphabet symbols and digits)
Returns URL for requesting Telegram API method
Performs request to Telegram API
Return Mojo::Collection of allowed updates (set of updates which Telegram sends to bot's webhook).
Extract from text bot commands and return them as Mojo::Collection
Returns config of plugin.
Telebot::Plugin::Telegram inherits all methods from Mojolicious::Plugin and implements the following new ones.
my $tg = $plugin->register(Mojolicious->new);
Register plugin in Mojolicious application and define helpers.
Copyright (C) 2022, Igor Lobanov. This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
https://github.com/igorlobanov/telebot, Mojolicious::Guides, https://mojolicious.org, https://core.telegram.org/bots/api.
To install Telebot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Telebot
CPAN shell
perl -MCPAN -e shell install Telebot
For more information on module installation, please visit the detailed CPAN module installation guide.