Bot-ChatBots-Telegram
view release on metacpan or search on metacpan
lib/Bot/ChatBots/Telegram.pod view on Meta::CPAN
use Log::Any qw< $log >;
use Log::Any::Adapter;
use Mojolicious::Lite;
Log::Any::Adapter->set(MojoLog => logger => app->log);
plugin 'Bot::ChatBots::Telegram' => instances => [
[
'WebHook',
processor => \&processor,
register => 1,
token => $ENV{TOKEN},
unregister => 1,
url => 'https://example.com:8443/mybot',
],
# more can follow here...
];
app->start;
sub processor {
my $record = shift;
# do whatever you want with $record, e.g. set a quick response
$record->{send_response} = 'your thoughs are important for us!';
return $record;
}
# You can also add Bot::ChatBots::Telegram::LongPoll sources if you want
=head1 DESCRIPTION
This module allows you to to define L<Bot::ChatBots> for
L<Telegram|https://telegram.org/>, a messaging application. For an
introduction and tutorial, see
L<Bot::ChatBots::Telegram::Guide::Tutorial>.
Strictly speaking, this I<module> is a L<Mojolicious> plugin that allows
you to load and use L<Bot::ChatBots::Telegram::WebHook> (see L</SYNOPSIS>
for a quick example). On the other hand, the I<distribution> also contains
other modules that allow you to interact with Telegram, e.g.
L<Bot::Chatbots::Telegram::LongPoll>.
These modules rely upon L<Log::Any> for emitting logging information; you
are encouraged to read that module's documentation for further
information. For what we are concerned, you have to remember that all logs
will be lost unless you configure L<Log::Any>, e.g. to send messages on
standard output you can do this:
use Log::Any::Adapter qw< Stderr >;
If using the web hook, then you will probably want to send the logs
together with L<Mojolicious>'s logs, like this:
use Mojolicious::Lite;
use Log::Any::Adapter;
Log::Any::Adapter->set(MojoLog => logger => app->log);
The configuration above relies on the presence of
L<Log::Any::Adapter::MojoLog>.
=head1 METHODS
All the heavylifting is done by L<Bot::ChatBots::MojoPlugin>.
=head1 BUGS AND LIMITATIONS
Report bugs through GitHub (patches welcome).
=head1 SEE ALSO
L<Bot::ChatBots>, L<Bot::ChatBots::Telegram::WebHook>,
L<Bot::ChatBots::Telegram::LongPoll>, L<WWW::Telegram::BotAPI>.
=head1 AUTHOR
Flavio Poletti <polettix@cpan.org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2016, 2018 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it
under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
( run in 0.819 second using v1.01-cache-2.11-cpan-39bf76dae61 )