NAME
Bot::ChatBots::Telegram::Role::Source - Telegram Source Role
SYNOPSIS
package Some::Thing;
use Moo;
with 'Bot::ChatBots::Telegram::Role::Source';
...
DESCRIPTION
This role is meant to be consumed by Bot::ChatBots::Telegram::WebHook and Bot::ChatBots::Telegram::LongPoll.
ACCESSORS
This role defines the accessors in the following subsections.
sender
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.
token
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".
METHODS
This method defines the methods in the following subsections.
has_token
say 'yes!' if $obj->has_token;
Predicate function to assess whether a "token" is present or not.
normalize_record
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_typeis eitherMessageorCallbackQueryand absent otherwise.In the
Messagecase, it is the expansion of thechatpart of thepayload.In the
CallbackQuerycase, it can be:the expansion of the
chatpart inside themessagepart of the Update data, ifmessageis present (Telegram documentation states this field is optional in the API), otherwisea simple anonymous hash where the
idfield is filled with thechat_instancefield from the payload. Whether this is meaningful or not is debatable.
data_type-
the Telegram type for the data pointed to by the optional field. For example, if the optional field in the Update is
edited_message, thendata_typewill beMessage. See https://core.telegram.org/bots/api#update for the mapping betweentypeanddata_type. payload-
the actual optional object pointed to by
type. For example, iftypeismessage, thenpayloadwill point to a hash with the contents explained at https://core.telegram.org/bots/api#message. sender-
whatever is contained in the
fromfield of thepayload source-
points to a hash containing the
technology(set totelegram) andtoken(either inherited, or set to whatever value is pointed by keyobject_tokeninsourceitself) type-
the field name of the optional part in a Telegram's Update, see https://core.telegram.org/bots/api#update (e.g.
message,edited_messageand so on).
SEE ALSO
AUTHOR
Flavio Poletti <polettix@cpan.org>
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.