Bot::ChatBots::Telegram::Role::Source - Telegram Source Role
package Some::Thing; use Moo; with 'Bot::ChatBots::Telegram::Role::Source'; ...
This role is meant to be consumed by Bot::ChatBots::Telegram::WebHook and Bot::ChatBots::Telegram::LongPoll.
This role defines the accessors in the following subsections.
my $sender = $obj->sender; $obj->sender(Bot::ChatBots::Telegram::Sender->new(token => $token));
Accessor for the Bot::ChatBots::Telegram::Sender object useful for managing communications to Telegram.
my $token = $obj->token; $obj->token($ENV{TOKEN});
Accessor for the token, used to access the Telegram service remotely. This also has an associated predicate function "has_token".
This method defines the methods in the following subsections.
say 'yes!' if $obj->has_token;
Predicate function to assess whether a "token" is present or not.
my $record = $self->normlize_record($input_record);
Perform some normalization on the record to give it a more "general" shape. Which is still in a state of flux, so a look to the code might be helpful.
So far you should find the following keys in the returned record:
chan
optional element containing data about the Chat where the Update came from. It is present when data_type is either Message or CallbackQuery and absent otherwise.
data_type
Message
CallbackQuery
In the Message case, it is the expansion of the chat part of the payload.
chat
payload
In the CallbackQuery case, it can be:
the expansion of the chat part inside the message part of the Update data, if message is present (Telegram documentation states this field is optional in the API), otherwise
message
a simple anonymous hash where the id field is filled with the chat_instance field from the payload. Whether this is meaningful or not is debatable.
id
chat_instance
the Telegram type for the data pointed to by the optional field. For example, if the optional field in the Update is edited_message, then data_type will be Message. See https://core.telegram.org/bots/api#update for the mapping between type and data_type.
edited_message
type
the actual optional object pointed to by type. For example, if type is message, then payload will point to a hash with the contents explained at https://core.telegram.org/bots/api#message.
sender
whatever is contained in the from field of the payload
from
source
points to a hash containing the technology (set to telegram) and token (either inherited, or set to whatever value is pointed by key object_token in source itself)
technology
telegram
token
object_token
the field name of the optional part in a Telegram's Update, see https://core.telegram.org/bots/api#update (e.g. message, edited_message and so on).
Bot::ChatBots.
Flavio Poletti <polettix@cpan.org>
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.
To install Bot::ChatBots::Telegram, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::ChatBots::Telegram
CPAN shell
perl -MCPAN -e shell install Bot::ChatBots::Telegram
For more information on module installation, please visit the detailed CPAN module installation guide.