Bot-ChatBots-Telegram
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
eg/README.md view on Meta::CPAN
- `webhook`: same business logic as `longpoll` above, just a different
way of getting messages, i.e. being notified about them.
To use both, you need to generate a token for your bot through the
special Telegram bot `BotFather`. The token can be used directly on
the command line with the first program:
$ ./longpoll $TOKEN
The second program needs a place to be installed and run, as well as
exposing an HTTPS type of endpoint, so you need to do an extra mile
to see it at work.
lib/Bot/ChatBots/Telegram/Guide/Tutorial.pod view on Meta::CPAN
$ export BOT_PROTO='https'
The I<best> would be to obtain a publicly recognised certificate. You can
reuse something that you already have, buy something, or take a look at
L<"Let's Encrypt"|https://letsencrypt.org/> to get one free.
Telegram will not insist on this, anyway, and it is also possible to
generate a self-signed certificate and then hand it over to Telegram. On
the other hand, it I<will> insist on the certificate and the domain or IP
address of your endpoint to match, so you will have to generate your
certificate depending on it, e.g. using the following command:
$ openssl req -x509 -nodes \
-newkey rsa:2048 \
-sha256 \
-days 365 \
-subj "/C=IT/ST=Roma/L=Roma/O=Pinco Pals/CN=$BOT_IP" \
-keyout server.key \
-out server.crt
Hence, C<server.key> and C<server.crt> will be hanging around in the
directory you are using, keep this in mind!
You can fiddle with the C<-subj> part of course, as long as you make sure
that the C<CN> part matches the IP address or domain name you chose for
your bot endpoint.
=head3 Decide a path and set C<BOT_PATH>
This is really up to you. If you are expanding a previous program, using
a reverse proxy, or just want to go deeper than the root path, you can
just do so:
$ export BOT_PATH='...'
You can also decide to leave this part empty.
lib/Bot/ChatBots/Telegram/LongPoll.pod view on Meta::CPAN
return $record; # follow on..
}
=head1 DESCRIPTION
This is an updates receiver and dispatcher for the Telegram
infrastructure. It connects to Telegram's API for I<long-poll> style (i.e.
pulling updates continuously), so it's somehow inefficient but should let
you get started in all conditions in which you can at least browse the
Internet (webhook require that your endpoint lives in a routable place).
At the base, you have to provide I<at least> the L</token> and the
L</processor>. The former is needed to connect to Telegram and get
updates, the latter is what will be invoked for each update that is
received.
When you have an object, you have to L</start> to get the ball rolling.
You can also pass C<start> in the constructor, this will start the
L<Mojo::IOLoop> directly (so you can use it in case you don't have other
stuff to do).
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.105 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )