Lint Teapot::Bot with perlcritic

* Use List::Util' any instead of grep in Base.pm
* Use croak() in Base.pm
This commit is contained in:
eleksir
2020-10-31 13:20:27 +03:00
parent a480786afa
commit 97eddd414d
35 changed files with 227 additions and 164 deletions

View File

@@ -4,38 +4,38 @@ verbose = 8
# minorify some of warnings that are not really critical
[-InputOutput::RequireCheckedClose]
# what can we handle in case of error?
# What can we handle in case of error?
[-Modules::ProhibitExcessMainComplexity]
# noone cares
# Noone cares
[-Subroutines::ProhibitExcessComplexity]
# noone cares
# Noone cares
[-Subroutines::ProhibitExplicitReturnUndef]
# but it's very handy sometimes!
# But it's very handy sometimes!
[-ValuesAndExpressions::ProhibitMagicNumbers]
# this policy makes too much false positives
[-RegularExpressions::RequireLineBoundaryMatching]
# we use /m as needed
# We use /m as needed
[-RegularExpressions::RequireExtendedFormatting]
# we do not use extended formatting of regex, they still not THAT complex
# We do not use extended formatting of regex, they still not THAT complex
[-RegularExpressions::RequireDotMatchAnything]
# huh?
[-RegularExpressions::ProhibitEscapedMetacharacters]
# looks like it pointless
# Looks like it pointless
[-ControlStructures::ProhibitCascadingIfElse]
# I like long ifelse chains
# I like long if..else chains
[-ControlStructures::ProhibitPostfixControls]
# in short lines we can afford ourselves to use postfix controls
# but ofcorse we shoul avoid such constructions in long lines
# In short lines we can afford ourselves to use postfix controls
# but ofcorse we should avoid such constructions in long lines.
[-Subroutines::ProhibitSubroutinePrototypes]
# Contrary to Perl::Critic we consider prototypes as useful, even if
@@ -43,9 +43,9 @@ verbose = 8
# hints.
[-CodeLayout::RequireTidyCode]
# impossible to complete, because of on higher linting levels ## no critic
# Impossible to complete, because of on higher linting levels "## no critic..."
# require be per-case on same line where critique is, but tidy align them
# one line down
# one line down.
[-CodeLayout::ProhibitParensWithBuiltins]
# duh...
@@ -55,7 +55,7 @@ verbose = 8
# the recomended use of q{} looks too complex: my $var = q{};
[-ValuesAndExpressions::ProhibitNoisyQuotes]
# other people, other opinions: "," is better readable than qw(,)
# Other people, other opinions: "," is better readable than qw(,)
[-BuiltinFunctions::ProhibitSleepViaSelect]
# We do not wish to use too much external modules.
@@ -67,14 +67,22 @@ verbose = 8
# Noone care, really
[-ControlStructures::ProhibitUnlessBlocks]
# they should not be too complex - only one condition should be checked,
# They should not be too complex - only one condition should be checked,
# that's all
[-Miscellanea::ProhibitTies]
# Just allow it. It's very handy stuff and extremely simple and safe enugh to use.
[-ValuesAndExpressions::RequireNumberSeparators]
# not really
# Not really
[-InputOutput::RequireBracedFileHandleWithPrint]
# we prefer not to use braced file handles
# We prefer not to use braced file handles
[-Documentation::PodSpelling]
# It doesn't help, but emits annoying errors
[Documentation::RequirePodSections]
# Considering this as "soft" requirement. For modules that is (or will be)
# stand-alone libs well formed documentation is highly desired.
lib_sections = NAME | VERSION | DESCRIPTION | AUTHOR | LICENSE AND COPYRIGHT

View File

@@ -1,5 +1,6 @@
requires 'Carp';
requires 'Log::Any';
requires 'List::Util';
requires 'Cwd::utf8';
requires 'DB_File';
requires 'Digest::MD5';

View File

@@ -15,7 +15,11 @@ __END__
=head1 NAME
Teapot::Bot - A base class to make your very own Telegram bot
Teapot::Bot
=head1 DESCRIPTION
A base class to make your very own Telegram bot
=head1 VERSION
@@ -70,6 +74,13 @@ and you've got yourself a stew, baby! Or a bot, anyway.
Note that for the bot to see messages that do not start with a leading '/', you will need to use
the C<'/setprivacy'> command on Telegram's C<@botfather> interface to change the privacy settings.
=head1 DEPENDENCIES
IO::Socket::SSL
Log::Any
Mojolicious
Test::Exception
=head1 EXAMPLES
This distribution's C<ex/> directory contains some complete examples that may be
@@ -79,7 +90,7 @@ instructive to look at.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -10,9 +10,9 @@ use warnings;
use Mojo::IOLoop;
use Mojo::UserAgent;
use Carp qw/croak cluck confess/; # use croak where we return error up to app that supply something wrong
# use cluck where we want to say that something bad but non-critical happen in
# lower layer (Mojo loop)
# use confess where we want to say that fatal error happen in lower layer (Mojo loop)
# use cluck where we want to say that something bad but non-critical happen in
# lower layer (Mojo loop)
# use confess where we want to say that fatal error happen in lower layer (Mojo loop)
use Log::Any;
use Data::Dumper;
@@ -22,13 +22,13 @@ $Teapot::Bot::Brain::VERSION = '0.021';
# base class for building telegram robots with Mojolicious
has longpoll_time => 60;
has ua => sub { Mojo::UserAgent->new->inactivity_timeout(shift->longpoll_time + 15) };
has token => sub { croak "you need to supply your own token"; };
has ua => sub { Mojo::UserAgent->new->inactivity_timeout(shift->longpoll_time + 15) };
has token => sub { croak 'You need to supply your own token'; };
has tasks => sub { [] };
has listeners => sub { [] };
has tasks => sub { [] };
has listeners => sub { [] };
has log => sub { Log::Any->get_logger };
has log => sub { Log::Any->get_logger };
sub add_repeating_task {
@@ -43,7 +43,7 @@ sub add_repeating_task {
Mojo::IOLoop->recurring(0.1 => sub {
my $loop = shift;
my $now = time();
return unless ($now - $last_check) >= $seconds;
return if ($now - $last_check) < $seconds;
$last_check = $now;
$task->($self);
});
@@ -67,7 +67,7 @@ sub add_listener {
}
sub init {
die "init was not overridden!";
croak 'init() was not overridden!';
}
@@ -84,7 +84,7 @@ sub think {
sub getMe {
my $self = shift;
my $token = $self->token || croak "no token?";
my $token = $self->token || croak 'No token supplied to getMe()?';
my $url = "https://api.telegram.org/bot${token}/getMe";
my $api_response = $self->_post_request($url);
@@ -93,7 +93,7 @@ sub getMe {
return Teapot::Bot::Object::User->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -103,12 +103,12 @@ sub getChatMember {
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied" unless $args->{chat_id};
croak "no user_id supplied" unless $args->{user_id};
croak 'No chat_id supplied to getChatMember()' unless $args->{chat_id};
croak 'No user_id supplied to getChatMember()' unless $args->{user_id};
$send_args->{chat_id} = $args->{chat_id};
$send_args->{user_id} = $args->{user_id};
my $token = $self->token || croak "no token?";
my $token = $self->token || croak 'No token supplied to getChatMember?';
my $url = "https://api.telegram.org/bot${token}/getChatMember";
my $api_response = $self->_post_request($url, $send_args);
@@ -117,7 +117,7 @@ sub getChatMember {
return Teapot::Bot::Object::ChatMember->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -127,10 +127,10 @@ sub getChat {
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied" unless $args->{chat_id};
croak 'No chat_id supplied to getChat()' unless $args->{chat_id};
$send_args->{chat_id} = $args->{chat_id};
my $token = $self->token || croak "no token?";
my $token = $self->token || croak 'No token supplied to getChat()?';
my $url = "https://api.telegram.org/bot${token}/getChat";
my $api_response = $self->_post_request($url, $send_args);
@@ -139,7 +139,7 @@ sub getChat {
return Teapot::Bot::Object::Chat->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -149,10 +149,10 @@ sub sendMessage {
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied in sendMessage" unless $args->{chat_id};
croak 'No chat_id supplied in sendMessage()' unless $args->{chat_id};
$send_args->{chat_id} = $args->{chat_id};
croak "no text supplied in sendMessage" unless $args->{text};
croak 'No text supplied in sendMessage()' unless $args->{text};
$send_args->{text} = $args->{text};
# these are optional, send if they are supplied
@@ -164,14 +164,18 @@ sub sendMessage {
# check reply_markup is the right kind
if (exists $args->{reply_markup}) {
my $reply_markup = $args->{reply_markup};
croak "Incorrect reply_markup in sendMessage" if ( ref($reply_markup) ne 'Teapot::Bot::Object::InlineKeyboardMarkup' &&
if ( ref($reply_markup) ne 'Teapot::Bot::Object::InlineKeyboardMarkup' &&
ref($reply_markup) ne 'Teapot::Bot::Object::ReplyKeyboardMarkup' &&
ref($reply_markup) ne 'Teapot::Bot::Object::ReplyKeyboardRemove' &&
ref($reply_markup) ne 'Teapot::Bot::Object::ForceReply' );
ref($reply_markup) ne 'Teapot::Bot::Object::ReplyKeyboardRemove' &&
ref($reply_markup) ne 'Teapot::Bot::Object::ForceReply' ) {
croak 'Incorrect reply_markup in sendMessage()';
}
$send_args->{reply_markup} = $reply_markup;
}
my $token = $self->token || croak "no token in sendMessage?";
my $token = $self->token || croak 'No token supplied to sendMessage()?';
my $url = "https://api.telegram.org/bot${token}/sendMessage";
my $api_response = $self->_post_request($url, $send_args);
@@ -179,7 +183,7 @@ sub sendMessage {
return Teapot::Bot::Object::Message->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -188,19 +192,19 @@ sub forwardMessage {
my $self = shift;
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied in forwardMessage" unless $args->{chat_id};
croak 'No chat_id supplied in forwardMessage()' unless $args->{chat_id};
$send_args->{chat_id} = $args->{chat_id};
croak "no from_chat_id supplied in forwardMessage" unless $args->{from_chat_id};
$send_args->{from_chat_id} = $args->{from_chat_id};
croak 'No from_chat_id supplied in forwardMessage()' unless $args->{from_chat_id};
$send_args->{from_chat_id} = $args->{from_chat_id};
croak "no message_id supplied in forwardMessage" unless $args->{message_id};
$send_args->{message_id} = $args->{message_id};
croak 'No message_id supplied in forwardMessage()' unless $args->{message_id};
$send_args->{message_id} = $args->{message_id};
# these are optional, send if they are supplied
$send_args->{disable_notification} = $args->{disable_notification} if exists $args->{disable_notification};
my $token = $self->token || croak "no token in forwardMessage?";
my $token = $self->token || croak 'No token supplied to forwardMessage()?';
my $url = "https://api.telegram.org/bot${token}/forwardMessage";
my $api_response = $self->_post_request($url, $send_args);
@@ -208,7 +212,7 @@ sub forwardMessage {
return Teapot::Bot::Object::Message->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -218,14 +222,14 @@ sub sendPhoto {
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied" unless $args->{chat_id};
croak 'No chat_id supplied to sendPhoto()' unless $args->{chat_id};
$send_args->{chat_id} = $args->{chat_id};
# photo can be a string (which might be either a URL for telegram servers
# to fetch, or a file_id string) or a file on disk to upload - we need
# to handle that last case here as it changes the way we create the HTTP
# request
croak "no photo supplied in sendPhoto" unless $args->{photo};
croak 'No photo supplied in sendPhoto()' unless $args->{photo};
if (-e $args->{photo}) {
$send_args->{photo} = { photo => { file => $args->{photo} } };
}
@@ -233,7 +237,7 @@ sub sendPhoto {
$send_args->{photo} = $args->{photo};
}
my $token = $self->token || croak "no token in sendPhoto?";
my $token = $self->token || croak 'No token in sendPhoto()?';
my $url = "https://api.telegram.org/bot${token}/sendPhoto";
my $api_response = $self->_post_request($url, $send_args);
@@ -241,7 +245,7 @@ sub sendPhoto {
return Teapot::Bot::Object::Message->create_from_hash($api_response, $self);
}
else {
return {"error" => 1};
return {'error' => 1};
}
}
@@ -251,7 +255,7 @@ sub sendChatAction {
my $args = shift || {};
my $send_args = {};
croak "no chat_id supplied in sendChatAction" unless $args->{chat_id};
croak 'No chat_id supplied in sendChatAction()' unless $args->{chat_id};
$send_args->{chat_id} = $args->{chat_id};
unless (defined $args->{action}) {
@@ -290,7 +294,7 @@ sub sendChatAction {
$send_args->{action} = 'typing';
}
my $token = $self->token || croak "no token in sendChatAction?";
my $token = $self->token || croak 'No token in sendChatAction()?';
my $url = "https://api.telegram.org/bot${token}/sendChatAction";
my $api_response = $self->_post_request ($url, $send_args);
@@ -317,7 +321,7 @@ sub _add_getUpdates_handler {
my ($ua, $tx) = @_;
my $res = $tx->res->json;
my $items = $res->{result};
foreach my $item (@$items) {
foreach my $item (@{$items}) {
$last_update_id = $item->{update_id};
$self->_process_message($item);
}
@@ -347,7 +351,7 @@ sub _process_message {
# if we got to this point without creating a response, it must be a type we
# don't handle yet
if (! $update) {
cluck "Do not know how to handle this update: " . Dumper($item);
cluck 'Do not know how to handle this update: ' . Dumper($item);
}
foreach my $listener (@{ $self->listeners }) {
@@ -371,12 +375,12 @@ sub _post_request {
}
elsif ($res->is_error) {
# This can be non-fatal error: api change.
cluck "Failed to post: " . $res->message;
cluck 'Failed to post: ' . $res->message;
return 0; # to handle this as false in upper layers
}
else {
# This must be something fatal for sure, because either is_success or is_error must be set by Mojo
confess "Not sure what went wrong";
confess 'Not sure what went wrong';
}
}
@@ -560,7 +564,7 @@ Note that not all methods have yet been implemented.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -17,7 +17,7 @@ has 'mime_type';
has 'file_size';
sub fields {
return { scalar => [qw/file_id width height duration file_name mime_type file_size/],
return { scalar => [qw/file_id width height duration file_name mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/],
};
}
@@ -33,13 +33,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::Animation - The base class for Telegram message 'Animation' type.
Teapot::Bot::Object::Animation - The base class for Telegram message 'Animation' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'Animation' type.
See L<https://core.telegram.org/bots/api#animation> for details of the
attributes available for L<Teapot::Bot::Object::Animation> objects.
@@ -48,7 +49,7 @@ attributes available for L<Teapot::Bot::Object::Animation> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -14,7 +14,7 @@ has 'file_size';
has 'thumb'; #PhotoSize
sub fields {
return { scalar => [qw/file_id duration performer title mime_type file_size/],
return { scalar => [qw/file_id duration performer title mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/],
};
}
@@ -36,6 +36,7 @@ Teapot::Bot::Object::Audio - The base class for Telegram 'Audio' type objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Audio' type objects.
See L<https://core.telegram.org/bots/api#audio> for details of the
attributes available for L<Teapot::Bot::Object::Audio> objects.
@@ -44,7 +45,7 @@ attributes available for L<Teapot::Bot::Object::Audio> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -2,28 +2,30 @@ package Teapot::Bot::Object::Base;
# ABSTRACT: The base class for all Teapot::Bot::Object objects.
use Mojo::Base -base;
use List::Util qw/any/;
use Carp qw/croak/;
$Teapot::Bot::Object::Base::VERSION = '0.021';
has '_brain'; # a reference to our brain
sub arrays { qw// } # override if needed
sub arrays { return qw// } # override if needed
sub _field_is_array {
my $self = shift;
my $field = shift;
if (grep /^$field$/, $self->arrays) {
if (any { /^$field$/ } $self->arrays) {
return 1;
}
return;
}
sub array_of_arrays { qw// } #override if needed
sub array_of_arrays { return qw// } #override if needed
sub _field_is_array_of_arrays {
my $self = shift;
my $field = shift;
if (grep /^$field$/, $self->array_of_arrays) {
if (any { /^$field$/ } $self->array_of_arrays) {
return 1;
}
return;
@@ -35,7 +37,7 @@ sub _field_is_array_of_arrays {
sub create_from_hash {
my $class = shift;
my $hash = shift;
my $brain = shift || die "no brain supplied";
my $brain = shift || croak 'No brain supplied to create_from_hash()';
my $obj = $class->new(_brain => $brain);
# deal with each type of field
@@ -60,7 +62,7 @@ sub create_from_hash {
$obj->$field($val);
}
elsif ($obj->_field_is_array_of_arrays) {
die "not yet implemented for scalars";
croak 'Not yet implemented for scalars';
}
else {
my $val = $hash->{$field};
@@ -81,7 +83,7 @@ sub create_from_hash {
$obj->$field(\@sub_array);
}
elsif ($obj->_field_is_array_of_arrays) {
die "not yet implemented for scalars";
croak 'Not yet implemented for scalars';
}
else {
$obj->$field($type->create_from_hash($hash->{$field}, $brain));
@@ -129,7 +131,7 @@ __END__
=head1 NAME
Teapot::Bot::Object::Base - The base class for all Telegram::Bot::Object objects.
Teapot::Bot::Object::Base - The base class for all Telegram::Bot::Object objects
=head1 VERSION
@@ -137,6 +139,8 @@ version 0.021
=head1 DESCRIPTION
The base class for all Telegram::Bot::Object objects.
This class should not be instantiated itself. Instead, instantiate a sub-class.
You should generally not need to instantiate objects of sub-classes of L<Teapot::Bot::Object::Base>,
@@ -170,7 +174,7 @@ Return this object as a hashref.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -1,9 +1,8 @@
package Teapot::Bot::Object::CallbackGame;
$Teapot::Bot::Object::CallbackGame::VERSION = '0.021';
# ABSTRACT: The base class for Telegram message 'CallbackGame' type.
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::CallbackGame::VERSION = '0.021';
# https://core.telegram.org/bots/api#callbackgame
# "A placeholder, currently holds no information. Use BotFather to set up your game"
@@ -22,13 +21,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::CallbackGame - The base class for Telegram message 'CallbackGame' type.
Teapot::Bot::Object::CallbackGame - The base class for Telegram message 'CallbackGame' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'CallbackGame' type.
See L<https://core.telegram.org/bots/api#callbackgame> for details of the
attributes available for L<Teapot::Bot::Object::CallbackGame> objects.
@@ -37,7 +37,7 @@ attributes available for L<Teapot::Bot::Object::CallbackGame> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -62,6 +62,7 @@ Teapot::Bot::Object::Chat - The base class for Telegram 'Chat' type objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Chat' type objects.
See L<https://core.telegram.org/bots/api#chat> for details of the
attributes available for L<Teapot::Bot::Object::Chat> objects.
@@ -80,7 +81,7 @@ Returns true if this is a chat is a group.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -53,6 +53,7 @@ Teapot::Bot::Object::ChatMember - The base class for Telegram 'ChatMember' type
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'ChatMember' type objects.
See L<https://core.telegram.org/bots/api#chatmember> for details of the
attributes available for L<Teapot::Bot::Object::ChatMember> objects.
@@ -61,7 +62,7 @@ attributes available for L<Teapot::Bot::Object::ChatMember> objects.
Sergei Fedosov <eleksir@gmail.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2020 by Sergei Fedosov <eleksir@gmail.com>

View File

@@ -25,7 +25,7 @@ sub fields {
'scalar' => [qw/can_send_messages can_send_media_messages can_send_polls
can_send_other_messages can_add_web_page_previews can_change_info
can_invite_users can_pin_messages/]
};
};
}
1;
@@ -45,6 +45,7 @@ Teapot::Bot::Object::ChatPermissions - The base class for Telegram 'ChatPermissi
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'ChatPermissions' type objects.
See L<https://core.telegram.org/bots/api#chatpermissions> for details of the
attributes available for L<Teapot::Bot::Object::ChatPermissions> objects.
@@ -53,7 +54,7 @@ attributes available for L<Teapot::Bot::Object::ChatPermissions> objects.
Sergei Fedosov <eleksir@gmail.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2020 Sergei Fedosov <eleksir@gmail.com>.

View File

@@ -10,8 +10,8 @@ has 'big_file_id';
sub fields {
return {
'scalar' => [qw/small_file_id big_file_id/],
};
'scalar' => [qw/small_file_id big_file_id/],
};
}
1;
@@ -31,6 +31,7 @@ Teapot::Bot::Object::ChatPhoto - The base class for Telegram 'ChatPhoto' type ob
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'ChatPhoto' type objects.
See L<https://core.telegram.org/bots/api#chatphoto> for details of the
attributes available for L<Teapot::Bot::Object::ChatPhoto> objects.
@@ -39,7 +40,7 @@ attributes available for L<Teapot::Bot::Object::ChatPhoto> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -11,7 +11,8 @@ has 'last_name';
has 'user_id';
sub fields {
return { scalar => [qw/phone_number first_name last_name user_id/],
return {
scalar => [qw/phone_number first_name last_name user_id/],
};
}
@@ -25,22 +26,23 @@ __END__
=head1 NAME
Teapot::Bot::Object::Contact - The base class for Telegram 'Contact' objects.
Teapot::Bot::Object::Contact - The base class for Telegram 'Contact' objects
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Contact' objects.
See L<https://core.telegram.org/bots/api#chat> for details of the
See L<https://core.telegram.org/bots/api#contact> for details of the
attributes available for L<Teapot::Bot::Object::Contact> objects.
=head1 AUTHOR
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -14,7 +14,8 @@ has 'mime_type';
has 'file_size';
sub fields {
return { scalar => [qw/file_id file_name mime_type file_size/],
return {
scalar => [qw/file_id file_name mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/]
};
}
@@ -36,6 +37,7 @@ Teapot::Bot::Object::Document - The base class for Telegram 'Document' objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Document' objects.
See L<https://core.telegram.org/bots/api#document> for details of the
attributes available for L<Teapot::Bot::Object::Document> objects.
@@ -44,7 +46,7 @@ attributes available for L<Teapot::Bot::Object::Document> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -30,6 +30,7 @@ Teapot::Bot::Object::EncryptedCredentials - The base class for Telegram 'Encrypt
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'EncryptedCredentials' type objects.
See L<https://core.telegram.org/bots/api#encryptedcredentials> for details of the
attributes available for L<Teapot::Bot::Object::EncryptedCredentials> objects.
@@ -38,7 +39,7 @@ attributes available for L<Teapot::Bot::Object::EncryptedCredentials> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -36,6 +36,7 @@ Teapot::Bot::Object::EncryptedPassportElement - The base class for Telegram 'Enc
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'EncryptedPassportElement' type objects.
See L<https://core.telegram.org/bots/api#encryptedpassportelement> for details of the
attributes available for L<Teapot::Bot::Object::EncryptedPassportElement> objects.
@@ -46,7 +47,7 @@ Note that this type is not yet fully implemented.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -17,7 +17,8 @@ has 'text_entities'; #Array of MessageEntity
has 'animation'; #Animation
sub fields {
return { scalar => [qw/title description text/],
return {
scalar => [qw/title description text/],
'Teapot::Bot::Object::PhotoSize' => [qw/photo/],
'Teapot::Bot::Object::MessageEntity' => [qw/text_entities/],
'Teapot::Bot::Object::Animation' => [qw/animation/],
@@ -36,13 +37,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::Game - The base class for Telegram message 'Game' type.
Teapot::Bot::Object::Game - The base class for Telegram message 'Game' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'Game' type.
See L<https://core.telegram.org/bots/api#game> for details of the
attributes available for L<Teapot::Bot::Object::Game> objects.
@@ -51,7 +53,7 @@ attributes available for L<Teapot::Bot::Object::Game> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -17,11 +17,11 @@ has 'callback_game'; # CallbackGame
has 'pay';
sub fields {
return { 'scalar' => [qw/text url callback_data switch_inline_query
switch_inline_query_current_chat switch_inline_query_current_chat
pay/],
'Teapot::Bot::Object::LoginUrl' => [qw/login_url/],
'Teapot::Bot::Object::CallbackGame'=> [qw/callback_game/],
return { 'scalar' => [qw/text url callback_data switch_inline_query
switch_inline_query_current_chat switch_inline_query_current_chat
pay/],
'Teapot::Bot::Object::LoginUrl' => [qw/login_url/],
'Teapot::Bot::Object::CallbackGame' => [qw/callback_game/],
};
}
@@ -42,6 +42,7 @@ Teapot::Bot::Object::InlineKeyboardButton - The base class for Telegram 'InlineK
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'InlineKeyboardButton' type objects.
See L<https://core.telegram.org/bots/api#inlinekeyboardbutton> for details of the
attributes available for L<Teapot::Bot::Object::InlineKeyboardButton> objects.
@@ -50,7 +51,7 @@ attributes available for L<Teapot::Bot::Object::InlineKeyboardButton> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -9,12 +9,11 @@ $Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.021';
has 'inline_keyboard';
sub fields {
return { 'Teapot::Bot::Object::InlineKeyboardButton' => [qw/inline_keyboard/],
};
return { 'Teapot::Bot::Object::InlineKeyboardButton' => [qw/inline_keyboard/] };
}
sub array_of_arrays {
qw/inline_keyboard/;
return qw/inline_keyboard/;
}
1;
@@ -34,6 +33,7 @@ Teapot::Bot::Object::InlineKeyboardMarkup - The base class for Telegram 'InlineK
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'InlineKeyboardMarkup' type objects.
See L<https://core.telegram.org/bots/api#inlinekeyboardmarkup> for details of the
attributes available for L<Teapot::Bot::Object::InlineKeyboardMarkup> objects.
@@ -42,7 +42,7 @@ attributes available for L<Teapot::Bot::Object::InlineKeyboardMarkup> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -12,8 +12,7 @@ has 'currency';
has 'total_amount';
sub fields {
return { scalar => [qw/title description start_parameter currency total_amount/],
};
return { scalar => [qw/title description start_parameter currency total_amount/] };
}
1;
@@ -33,6 +32,7 @@ Teapot::Bot::Object::Invoice - The base class for Telegram 'Invoice' type object
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Invoice' type objects.
See L<https://core.telegram.org/bots/api#invoice> for details of the
attributes available for L<Teapot::Bot::Object::Invoice> objects.
@@ -41,7 +41,7 @@ attributes available for L<Teapot::Bot::Object::Invoice> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -9,8 +9,7 @@ has 'longitude';
has 'latitude';
sub fields {
return { scalar => [qw/longitude latitude/],
};
return { scalar => [qw/longitude latitude/] };
}
1;
@@ -23,13 +22,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::Location - The base class for Telegram message 'Location' type.
Teapot::Bot::Object::Location - The base class for Telegram message 'Location' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'Location' type.
See L<https://core.telegram.org/bots/api#location> for details of the
attributes available for L<Teapot::Bot::Object::Location> objects.
@@ -38,7 +38,7 @@ attributes available for L<Teapot::Bot::Object::Location> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -31,6 +31,7 @@ Teapot::Bot::Object::LoginUrl - The base class for Telegram 'LoginUrl' type obje
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'LoginUrl' type objects.
See L<https://core.telegram.org/bots/api#loginurl> for details of the
attributes available for L<Teapot::Bot::Object::LoginUrl> objects.
@@ -39,7 +40,7 @@ attributes available for L<Teapot::Bot::Object::LoginUrl> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -152,31 +152,38 @@ __END__
=head1 NAME
Teapot::Bot::Object::Message - The base class for the Telegram type "Message".
Teapot::Bot::Object::Message - The base class for the Telegram type "Message"
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for the Telegram type "Message".
See L<https://core.telegram.org/bots/api#message> for details of the
attributes available for L<Teapot::Bot::Object::Message> objects.
=head1 METHODS
=head2
=head2 reply
A convenience method to reply to a message with text.
Will return the L<Teapot::Bot::Object::Message> object representing the message
sent.
=head2 typing
Sends notification to chat that bot is "typing" something.
Returns nothing that should be checked.
=head1 AUTHOR
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -15,9 +15,9 @@ has 'language'; # Optional. For “pre” only, the programming language of the
sub fields {
return {
'scalar' => [qw/type offset length url language/],
'Teapot::Bot::Object::User' => [qw/user/],
};
'scalar' => [qw/type offset length url language/],
'Teapot::Bot::Object::User' => [qw/user/],
};
}
1;
@@ -37,6 +37,7 @@ Teapot::Bot::Object::MessageEntity - The base class for Telegram 'MessageEntity'
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'MessageEntity' type objects.
See L<https://core.telegram.org/bots/api#messageentity> for details of the
attributes available for L<Teapot::Bot::Object::MessageEntity> objects.
@@ -45,7 +46,7 @@ attributes available for L<Teapot::Bot::Object::MessageEntity> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -11,8 +11,9 @@ has 'data'; # Array of EncryptedPassportElement
has 'credentials'; # EncryptedCredentials
sub fields {
return { 'Teapot::Bot::Object::EncryptedPassportElement' => [qw/data/],
'Teapot::Bot::Object::EncryptedCredentials' => [qw/credentials/],
return {
'Teapot::Bot::Object::EncryptedPassportElement' => [qw/data/],
'Teapot::Bot::Object::EncryptedCredentials' => [qw/credentials/],
};
}
@@ -37,6 +38,7 @@ Teapot::Bot::Object::PassportData - The base class for Telegram 'PassportData' t
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'PassportData' type objects.
See L<https://core.telegram.org/bots/api#passportdata> for details of the
attributes available for L<Teapot::Bot::Object::PassportData> objects.
@@ -45,7 +47,7 @@ attributes available for L<Teapot::Bot::Object::PassportData> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -12,8 +12,7 @@ has 'height';
has 'file_size';
sub fields {
return { scalar => [qw/file_id width height file_size/]
};
return { scalar => [qw/file_id width height file_size/] };
}
1;
@@ -26,13 +25,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::PhotoSize - The base class for Telegram message 'PhotoSize' type.
Teapot::Bot::Object::PhotoSize - The base class for Telegram message 'PhotoSize' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'PhotoSize' type.
See L<https://core.telegram.org/bots/api#photosize> for details of the
attributes available for L<Teapot::Bot::Object::PhotoSize> objects.
@@ -41,7 +41,7 @@ attributes available for L<Teapot::Bot::Object::PhotoSize> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -12,9 +12,9 @@ has 'options'; # Array of PollOption
has 'is_closed';
sub fields {
return { scalar => [qw/id question is_closed/],
'Teapot::Bot::Object::PollOption' => [qw/options /],
return {
scalar => [qw/id question is_closed/],
'Teapot::Bot::Object::PollOption' => [qw/options/],
};
}
@@ -39,6 +39,7 @@ Teapot::Bot::Object::Poll - The base class for Telegram 'Poll' type objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Poll' type objects
See L<https://core.telegram.org/bots/api#poll> for details of the
attributes available for L<Teapot::Bot::Object::Poll> objects.
@@ -47,7 +48,7 @@ attributes available for L<Teapot::Bot::Object::Poll> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -9,8 +9,7 @@ has 'text';
has 'voter_count';
sub fields {
return { scalar => [qw/text voter_count/],
};
return { scalar => [qw/text voter_count/] };
}
1;
@@ -30,6 +29,7 @@ Teapot::Bot::Object::PollOption - The base class for Telegram 'PollOption' type
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'PollOption' type objects.
See L<https://core.telegram.org/bots/api#polloption> for details of the
attributes available for L<Teapot::Bot::Object::PollOption> objects.
@@ -38,7 +38,7 @@ attributes available for L<Teapot::Bot::Object::PollOption> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -16,8 +16,8 @@ has 'set_name';
has 'file_size';
sub fields {
return { scalar => [qw/file_id width height emoji
set_name file_size /],
return {
scalar => [ qw/file_id width height emoji set_name file_size/ ],
'Teapot::Bot::Object::PhotoSize' => [ qw/thumb/ ],
};
}
@@ -32,13 +32,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::Sticker - The base class for Telegram message 'Sticker' type.
Teapot::Bot::Object::Sticker - The base class for Telegram message 'Sticker' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'Sticker' type.
See L<https://core.telegram.org/bots/api#sticker> for details of the
attributes available for L<Teapot::Bot::Object::Sticker> objects.
@@ -47,7 +48,7 @@ attributes available for L<Teapot::Bot::Object::Sticker> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -15,10 +15,10 @@ has 'telegram_payment_charge_id';
has 'provider_payment_charge_id';
sub fields {
return { scalar => [qw/currency total_amount invoice_payload shipping_option_id
telegram_payment_charge_id provider_payment_charge_id/],
# 'Teapot::Bot::Object::OrderInfo' => [qw/order_info/],
return {
scalar => [qw/currency total_amount invoice_payload shipping_option_id
telegram_payment_charge_id provider_payment_charge_id/],
# 'Teapot::Bot::Object::OrderInfo' => [qw/order_info/],
};
}
@@ -39,6 +39,7 @@ Teapot::Bot::Object::SuccessfulPayment - The base class for Telegram 'Successful
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'SuccessfulPayment' type objects.
See L<https://core.telegram.org/bots/api#successfulpayment> for details of the
attributes available for L<Teapot::Bot::Object::SuccessfulPayment> objects.
@@ -47,7 +48,7 @@ attributes available for L<Teapot::Bot::Object::SuccessfulPayment> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -17,7 +17,8 @@ has 'can_read_all_group_messages';# optional, only for getMe() method
has 'supports_inline_queries'; # optional, only for getMe() method
sub fields {
return { scalar => [qw/id is_bot first_name last_name username language_code can_join_groups
return {
scalar => [qw/id is_bot first_name last_name username language_code can_join_groups
can_read_all_group_messages supports_inline_queries/]
};
}
@@ -32,13 +33,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::User - The base class for Telegram message 'User' type.
Teapot::Bot::Object::User - The base class for Telegram message 'User' type
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram message 'User' type.
See L<https://core.telegram.org/bots/api#user> for details of the
attributes available for L<Teapot::Bot::Object::User> objects.
@@ -47,7 +49,7 @@ attributes available for L<Teapot::Bot::Object::User> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -13,9 +13,10 @@ has 'foursquare_id';
has 'foursquare_type';
sub fields {
return { 'scalar' => [qw/title address
foursquare_id foursquare_type/],
'Teapot::Bot::Object::Location' => [qw/location/] };
return {
'scalar' => [qw/title address foursquare_id foursquare_type/],
'Teapot::Bot::Object::Location' => [qw/location/]
};
}
@@ -36,6 +37,7 @@ Teapot::Bot::Object::Venue - The base class for Telegram 'LoginUrl' type objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'LoginUrl' type objects.
See L<https://core.telegram.org/bots/api#venue> for details of the
attributes available for L<Teapot::Bot::Object::Venue> objects.
@@ -44,7 +46,7 @@ attributes available for L<Teapot::Bot::Object::Venue> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -15,8 +15,8 @@ has 'mime_type';
has 'file_size';
sub fields {
return { scalar => [qw/file_id width height duration
mime_type file_size /],
return {
scalar => [qw/file_id width height duration mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/]
};
}
@@ -31,13 +31,14 @@ __END__
=head1 NAME
Teapot::Bot::Object::Video - The base class for Telegram 'Video' object.
Teapot::Bot::Object::Video - The base class for Telegram 'Video' object
=head1 VERSION
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Video' object.
See L<https://core.telegram.org/bots/api#video> for details of the
attributes available for L<Teapot::Bot::Object::Video> objects.
@@ -46,7 +47,7 @@ attributes available for L<Teapot::Bot::Object::Video> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -15,9 +15,9 @@ has 'thumb'; #PhotoSize
has 'file_size';
sub fields {
return { scalar => [qw/file_id length duration mime_type file_size/],
return {
scalar => [qw/file_id length duration mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb /],
};
}
@@ -38,6 +38,7 @@ Teapot::Bot::Object::VideoNote - The base class for Telegram 'VideoNote' type ob
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'VideoNote' type object.
See L<https://core.telegram.org/bots/api#videonote> for details of the
attributes available for L<Teapot::Bot::Object::VideoNote> objects.
@@ -46,7 +47,7 @@ attributes available for L<Teapot::Bot::Object::VideoNote> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.

View File

@@ -11,8 +11,7 @@ has 'mime_type';
has 'file_size';
sub fields {
return { scalar => [qw/file_id duration mime_type file_size/]
};
return { scalar => [qw/file_id duration mime_type file_size/] };
}
1;
@@ -32,6 +31,7 @@ Teapot::Bot::Object::Voice - The base class for Telegram 'Voice' type objects
version 0.021
=head1 DESCRIPTION
The base class for Telegram 'Voice' type objects.
See L<https://core.telegram.org/bots/api#voice> for details of the
attributes available for L<Teapot::Bot::Object::Voice> objects.
@@ -40,7 +40,7 @@ attributes available for L<Teapot::Bot::Object::Voice> objects.
Justin Hawkins <justin@eatmorecode.com>
=head1 COPYRIGHT AND LICENSE
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2019 by Justin Hawkins.