2/5 Lift up error to caller in Teapot lib, introduce can_talk() in Brain.pm
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PhotoSize ();
|
||||
|
||||
$Teapot::Bot::Object::Animation::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Animation::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -43,7 +43,7 @@ Teapot::Bot::Object::Animation - The base class for Telegram message 'Animation'
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'Animation' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Audio::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Audio::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -41,7 +41,7 @@ Teapot::Bot::Object::Audio - The base class for Telegram 'Audio' type objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Audio' type objects.
|
||||
|
||||
@@ -13,7 +13,7 @@ use List::Util qw/any/;
|
||||
|
||||
use Mojo::Base -base;
|
||||
|
||||
$Teapot::Bot::Object::Base::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Base::VERSION = '0.025';
|
||||
|
||||
has '_brain'; # a reference to our brain
|
||||
|
||||
@@ -187,7 +187,7 @@ Teapot::Bot::Object::Base - The base class for all Telegram::Bot::Object objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use 5.018; ## no critic (ProhibitImplicitImport)
|
||||
use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
$Teapot::Bot::Object::CallbackGame::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::CallbackGame::VERSION = '0.025';
|
||||
|
||||
# https://core.telegram.org/bots/api#callbackgame
|
||||
# "A placeholder, currently holds no information. Use BotFather to set up your game"
|
||||
@@ -30,7 +30,7 @@ Teapot::Bot::Object::CallbackGame - The base class for Telegram message 'Callbac
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'CallbackGame' type.
|
||||
|
||||
@@ -12,7 +12,7 @@ use Teapot::Bot::Object::Message ();
|
||||
use Teapot::Bot::Object::ChatPermissions ();
|
||||
use Teapot::Bot::Object::ChatLocation ();
|
||||
|
||||
$Teapot::Bot::Object::Chat::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Chat::VERSION = '0.025';
|
||||
|
||||
has 'id';
|
||||
has 'type';
|
||||
@@ -86,7 +86,7 @@ Teapot::Bot::Object::Chat - The base class for Telegram 'Chat' type objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Chat' type objects.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::User ();
|
||||
|
||||
$Teapot::Bot::Object::ChatInviteLink::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatInviteLink::VERSION = '0.025';
|
||||
|
||||
has 'invite_link';
|
||||
has 'creator';
|
||||
@@ -44,7 +44,7 @@ Teapot::Bot::Object::ChatInviteLink - The base class for Telegram message 'ChatI
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ChatInviteLink' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ChatLocation::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatLocation::VERSION = '0.025';
|
||||
|
||||
has 'location';
|
||||
has 'address';
|
||||
@@ -34,7 +34,7 @@ Teapot::Bot::Object::ChatLocation - The base class for Telegram message 'ChatLoc
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ChatLocation' type.
|
||||
|
||||
@@ -12,7 +12,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::User ();
|
||||
|
||||
|
||||
$Teapot::Bot::Object::ChatMember::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatMember::VERSION = '0.025';
|
||||
|
||||
# ChatMemberOwner
|
||||
has 'user';
|
||||
@@ -147,7 +147,7 @@ Teapot::Bot::Object::ChatMember - The base class for Telegram 'ChatMember' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'ChatMember' type objects.
|
||||
|
||||
@@ -13,7 +13,7 @@ use Teapot::Bot::Object::ChatMember ();
|
||||
use Teapot::Bot::Object::ChatInviteLink ();
|
||||
use Teapot::Bot::Object::Voice ();
|
||||
|
||||
$Teapot::Bot::Object::ChatMemberUpdated::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatMemberUpdated::VERSION = '0.025';
|
||||
|
||||
has 'chat';
|
||||
has 'from';
|
||||
@@ -50,7 +50,7 @@ Teapot::Bot::Object::ChatMemberUpdated - The base class for Telegram 'ChatMember
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'ChatMemberUpdated' type objects.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Carp qw(carp);
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Brain ();
|
||||
|
||||
$Teapot::Bot::Object::ChatPermissions::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatPermissions::VERSION = '0.025';
|
||||
|
||||
# all fields are optional
|
||||
# N.B. Some of the fields "overlaps" other, so in order to guess valid set of permissions you should check all of them
|
||||
@@ -38,11 +38,38 @@ sub fields {
|
||||
}
|
||||
|
||||
sub canTalk {
|
||||
my $self = shift;
|
||||
my $self;
|
||||
my $args = {};
|
||||
|
||||
# There is some magic happen if we call function as object, as we usually do here
|
||||
# But if we access function from usual-style wrapper that calls it directly from namespace it supply noy $self object
|
||||
# but string with its name, which is a bummer.
|
||||
while (my $o = shift @_) {
|
||||
if (ref ($o) ne '') {
|
||||
$self = $o;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
my $chatid = shift;
|
||||
|
||||
my $args->{chat_id} = $chatid;
|
||||
$args->{chat_id} = $chatid;
|
||||
my $can_talk = 0;
|
||||
my $ret;
|
||||
|
||||
if (! defined($self->token) || $self->token eq '') {
|
||||
$ret->{error} = 1;
|
||||
$ret->{message} = 'No token supplied to canTalk()';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
unless ($args->{chat_id}) {
|
||||
$ret->{error} = 1;
|
||||
$ret->{message} = 'No chat_id supplied to canTalk()';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($chatid < 0) {
|
||||
# group chat
|
||||
@@ -50,16 +77,23 @@ sub canTalk {
|
||||
|
||||
# on api error, keep silence
|
||||
if ($chatobj == 0 || $chatobj->{error}) {
|
||||
carp "Unable to get chat info for $chatid from telegram API";
|
||||
return $can_talk;
|
||||
my $emesg = "Unable to get chat info for $chatid from telegram API";
|
||||
$ret->{message} = $emesg;
|
||||
$ret->{error} = 1;
|
||||
$ret->{can_talk} = 0;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
my $myObj = Teapot::Bot::Brain->getMe ($self);
|
||||
|
||||
# on api error, keep silence
|
||||
if ($myObj == 0 || $myObj->{error}) {
|
||||
carp "Unable to get chat info for $chatid from telegram API";
|
||||
return $can_talk;
|
||||
my $emesg = "Unable to get chat info for $chatid from telegram API";
|
||||
$ret->{message} = $emesg;
|
||||
$ret->{error} = 1;
|
||||
$ret->{can_talk} = 0;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
my $myid = $myObj->id;
|
||||
@@ -68,8 +102,12 @@ sub canTalk {
|
||||
|
||||
# on api error, keep silence
|
||||
if ($me == 0 || $me->{error}) {
|
||||
carp 'Unable to get chat info for bot itself from telegram API';
|
||||
return $can_talk;
|
||||
my $emesg = 'Unable to get chat info for bot itself from telegram API';
|
||||
$ret->{message} = $emesg;
|
||||
$ret->{error} = 1;
|
||||
$ret->{can_talk} = 0;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($me->{'status'} eq 'administrator') {
|
||||
@@ -83,9 +121,13 @@ sub canTalk {
|
||||
$can_talk = 1;
|
||||
}
|
||||
|
||||
return $can_talk;
|
||||
$ret->{error} = 0;
|
||||
$ret->{can_talk} = $can_talk;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
@@ -100,7 +142,7 @@ Teapot::Bot::Object::ChatPermissions - The base class for Telegram 'ChatPermissi
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'ChatPermissions' type objects.
|
||||
@@ -114,7 +156,9 @@ attributes available for C<Teapot::Bot::Object::ChatPermissions> objects.
|
||||
|
||||
A convenience method to check if bot can talk in given conversation.
|
||||
|
||||
Returns true if the bot can talk in given conversation, otherwise false.
|
||||
Returns hash reference with can_talk true if the bot can talk in given conversation, otherwise false.
|
||||
Also set field error 1 if an error occurs during api interaction.
|
||||
And if error set to true message field also set plus can_talk set to false.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ChatPhoto::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ChatPhoto::VERSION = '0.025';
|
||||
|
||||
has 'small_file_id';
|
||||
has 'small_file_unique_id';
|
||||
@@ -35,7 +35,7 @@ Teapot::Bot::Object::ChatPhoto - The base class for Telegram 'ChatPhoto' type ob
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'ChatPhoto' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Contact::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Contact::VERSION = '0.025';
|
||||
|
||||
has 'phone_number';
|
||||
has 'first_name';
|
||||
@@ -36,7 +36,7 @@ Teapot::Bot::Object::Contact - The base class for Telegram 'Contact' objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Contact' objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Dice::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Dice::VERSION = '0.025';
|
||||
|
||||
has 'emoji';
|
||||
has 'value';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::Dice - The base class for Telegram message 'Dice' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'Dice' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PhotoSize ();
|
||||
|
||||
$Teapot::Bot::Object::Document::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Document::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -39,7 +39,7 @@ Teapot::Bot::Object::Document - The base class for Telegram 'Document' objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Document' objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.025';
|
||||
|
||||
has 'data';
|
||||
has 'hash';
|
||||
@@ -32,7 +32,7 @@ Teapot::Bot::Object::EncryptedCredentials - The base class for Telegram 'Encrypt
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'EncryptedCredentials' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.025';
|
||||
|
||||
# XXX Implement rest of this
|
||||
# https://core.telegram.org/bots/api#encryptedpassportelement
|
||||
@@ -38,7 +38,7 @@ Teapot::Bot::Object::EncryptedPassportElement - The base class for Telegram 'Enc
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'EncryptedPassportElement' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ForumTopicClosed::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ForumTopicClosed::VERSION = '0.025';
|
||||
|
||||
|
||||
sub fields {
|
||||
@@ -29,7 +29,7 @@ Teapot::Bot::Object::ForumTopicClosed - The base class for Telegram message 'Fo
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ForumTopicClosed' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ForumTopicCreated::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ForumTopicCreated::VERSION = '0.025';
|
||||
|
||||
has 'name';
|
||||
has 'icon_color';
|
||||
@@ -32,7 +32,7 @@ Teapot::Bot::Object::ForumTopicCreated - The base class for Telegram message 'F
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ForumTopicCreated' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ForumTopicReopened::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ForumTopicReopened::VERSION = '0.025';
|
||||
|
||||
|
||||
sub fields {
|
||||
@@ -29,7 +29,7 @@ Teapot::Bot::Object::ForumTopicReopened - The base class for Telegram message '
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ForumTopicReopened' type.
|
||||
|
||||
@@ -11,7 +11,7 @@ use Teapot::Bot::Object::PhotoSize ();
|
||||
use Teapot::Bot::Object::Animation ();
|
||||
use Teapot::Bot::Object::MessageEntity ();
|
||||
|
||||
$Teapot::Bot::Object::Game::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Game::VERSION = '0.025';
|
||||
|
||||
has 'title';
|
||||
has 'description';
|
||||
@@ -45,7 +45,7 @@ Teapot::Bot::Object::Game - The base class for Telegram message 'Game' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'Game' type.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::LoginUrl ();
|
||||
use Teapot::Bot::Object::CallbackGame ();
|
||||
|
||||
$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.025';
|
||||
|
||||
has 'text';
|
||||
has 'url';
|
||||
@@ -43,7 +43,7 @@ Teapot::Bot::Object::InlineKeyboardButton - The base class for Telegram 'InlineK
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'InlineKeyboardButton' type objects.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::InlineKeyboardButton ();
|
||||
|
||||
$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.025';
|
||||
|
||||
has 'inline_keyboard';
|
||||
|
||||
@@ -35,7 +35,7 @@ Teapot::Bot::Object::InlineKeyboardMarkup - The base class for Telegram 'InlineK
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'InlineKeyboardMarkup' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Invoice::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Invoice::VERSION = '0.025';
|
||||
|
||||
has 'title';
|
||||
has 'description';
|
||||
@@ -34,7 +34,7 @@ Teapot::Bot::Object::Invoice - The base class for Telegram 'Invoice' type object
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Invoice' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Location::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Location::VERSION = '0.025';
|
||||
|
||||
has 'longitude';
|
||||
has 'latitude';
|
||||
@@ -35,7 +35,7 @@ Teapot::Bot::Object::Location - The base class for Telegram message 'Location' t
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'Location' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::LoginUrl::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::LoginUrl::VERSION = '0.025';
|
||||
|
||||
has 'url';
|
||||
has 'forward_text';
|
||||
@@ -33,7 +33,7 @@ Teapot::Bot::Object::LoginUrl - The base class for Telegram 'LoginUrl' type obje
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'LoginUrl' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::MaskPosition::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::MaskPosition::VERSION = '0.025';
|
||||
|
||||
has 'point';
|
||||
has 'x_shift';
|
||||
@@ -33,7 +33,7 @@ Teapot::Bot::Object::MaskPosition - The base class for Telegram 'MaskPosition' t
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'MaskPosition' type objects.
|
||||
|
||||
@@ -40,7 +40,7 @@ use Teapot::Bot::Object::VideoChatStarted ();
|
||||
use Teapot::Bot::Object::VideoChatEnded ();
|
||||
use Teapot::Bot::Object::VideoChatParticipantsInvited ();
|
||||
|
||||
$Teapot::Bot::Object::Message::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Message::VERSION = '0.025';
|
||||
|
||||
# basic message stuff
|
||||
has 'message_id';
|
||||
@@ -163,54 +163,76 @@ sub arrays {
|
||||
return qw/photo entities caption_entities new_chat_members new_chat_photo/;
|
||||
}
|
||||
|
||||
|
||||
sub reply {
|
||||
my $self = shift;
|
||||
my $text = shift;
|
||||
|
||||
my $chatid = $self->chat->id;
|
||||
my $message_thread_id = eval {$self->message_thread_id};
|
||||
my $ret = '';
|
||||
|
||||
if (Teapot::Bot::Object::ChatPermissions->canTalk($self, $chatid)) {
|
||||
if (defined $message_thread_id && $message_thread_id ne '') {
|
||||
return $self->_brain->sendMessage({chat_id => $chatid, message_thread_id => $message_thread_id, text => $text});
|
||||
} else {
|
||||
return $self->_brain->sendMessage({chat_id => $chatid, text => $text});
|
||||
my $send_args->{chat_id} = $self->chat->id;
|
||||
my $message_thread_id = eval {$self->message_thread_id};
|
||||
|
||||
my $can_talk = $self->_brain->can_talk($send_args);
|
||||
|
||||
if ($can_talk->{error}) {
|
||||
$ret = $can_talk;
|
||||
} else {
|
||||
if ($can_talk->{can_talk}) {
|
||||
$send_args->{text} = $text;
|
||||
|
||||
if (defined $message_thread_id && $message_thread_id ne '') {
|
||||
$send_args->{$message_thread_id} = $message_thread_id;
|
||||
}
|
||||
|
||||
$ret = $self->_brain->sendMessage($send_args);
|
||||
}
|
||||
}
|
||||
|
||||
return {'error' => 1};
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub replyMd {
|
||||
my $self = shift;
|
||||
my $text = shift;
|
||||
|
||||
my $chatid = $self->chat->id;
|
||||
my $message_thread_id = eval {$self->message_thread_id};
|
||||
my $ret = '';
|
||||
|
||||
if (Teapot::Bot::Object::ChatPermissions->canTalk ($self, $chatid)) {
|
||||
my $send_args;
|
||||
$send_args->{text} = $text;
|
||||
$send_args->{parse_mode} = 'Markdown';
|
||||
$send_args->{chat_id} = $chatid;
|
||||
$send_args->{message_thread_id} = $message_thread_id if (defined $message_thread_id);
|
||||
return $self->_brain->sendMessage($send_args);
|
||||
my $send_args->{chat_id} = $self->chat->id;
|
||||
my $message_thread_id = eval {$self->message_thread_id};
|
||||
|
||||
my $can_talk = $self->_brain->can_talk($send_args);
|
||||
|
||||
if ($can_talk->{error}) {
|
||||
$ret = $can_talk;
|
||||
} else {
|
||||
if ($can_talk->{can_talk}) {
|
||||
$send_args->{text} = $text;
|
||||
$send_args->{parse_mode} = 'Markdown';
|
||||
$send_args->{message_thread_id} = $message_thread_id if (defined $message_thread_id);
|
||||
|
||||
$ret = $self->_brain->sendMessage($send_args);
|
||||
}
|
||||
}
|
||||
|
||||
return {'error' => 1};
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub typing {
|
||||
my $self = shift;
|
||||
|
||||
my $chatid = $self->chat->id;
|
||||
my $ret = '';
|
||||
my $send_args->{chat_id} = $self->chat->id;
|
||||
my $can_talk = $self->_brain->can_talk($send_args);
|
||||
|
||||
if (Teapot::Bot::Object::ChatPermissions->canTalk ($self, $chatid)) {
|
||||
return $self->_brain->sendChatAction({chat_id => $chatid});
|
||||
if ($can_talk->{error}) {
|
||||
$ret = $can_talk;
|
||||
} else {
|
||||
if ($can_talk->{can_talk}) {
|
||||
$ret = $self->_brain->sendChatAction($send_args);
|
||||
}
|
||||
}
|
||||
|
||||
return {'error' => 1};
|
||||
return $ret;
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -227,7 +249,7 @@ Teapot::Bot::Object::Message - The base class for the Telegram type "Message"
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for the Telegram type "Message".
|
||||
@@ -243,6 +265,9 @@ A convenience method to reply to a message with text.
|
||||
|
||||
Will return the C<Teapot::Bot::Object::Message> object representing the message
|
||||
sent.
|
||||
On error returns hash reference with error field set to 1, also set fields
|
||||
param, url and debug (which is result of Mojo::UserAgent->post->result->json)
|
||||
|
||||
|
||||
=head2 replyMd
|
||||
|
||||
@@ -250,12 +275,15 @@ A convenience method to reply to a message with markdown formatted text.
|
||||
|
||||
Will return the C<Teapot::Bot::Object::Message> object representing the message
|
||||
sent.
|
||||
On error returns hash reference with error field set to 1, also set fields
|
||||
param, url and debug (which is result of Mojo::UserAgent->post->result->json)
|
||||
|
||||
=head2 typing
|
||||
|
||||
Sends notification to chat that bot is "typing" something.
|
||||
|
||||
Returns nothing that should be checked.
|
||||
On error returns hash reference with error field set to 1, also set fields
|
||||
param, url and debug (which is result of Mojo::UserAgent->post->result->json)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::MessageAutoDeleteTimerChanged::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::MessageAutoDeleteTimerChanged::VERSION = '0.025';
|
||||
|
||||
has 'message_auto_delete_time';
|
||||
|
||||
@@ -32,7 +32,7 @@ Teapot::Bot::Object::MessageAutoDeleteTimerChanged - The base class for Telegram
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'MessageAutoDeleteTimerChanged' type objects.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::User ();
|
||||
|
||||
$Teapot::Bot::Object::MessageEntity::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::MessageEntity::VERSION = '0.025';
|
||||
|
||||
has 'type';
|
||||
has 'offset';
|
||||
@@ -39,7 +39,7 @@ Teapot::Bot::Object::MessageEntity - The base class for Telegram 'MessageEntity'
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'MessageEntity' type objects.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::EncryptedPassportElement ();
|
||||
use Teapot::Bot::Object::EncryptedCredentials ();
|
||||
|
||||
$Teapot::Bot::Object::PassportData::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::PassportData::VERSION = '0.025';
|
||||
|
||||
has 'data'; # Array of EncryptedPassportElement
|
||||
has 'credentials'; # EncryptedCredentials
|
||||
@@ -40,7 +40,7 @@ Teapot::Bot::Object::PassportData - The base class for Telegram 'PassportData' t
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'PassportData' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::PhotoSize::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::PhotoSize::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -34,7 +34,7 @@ Teapot::Bot::Object::PhotoSize - The base class for Telegram message 'PhotoSize'
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'PhotoSize' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PollOption ();
|
||||
|
||||
$Teapot::Bot::Object::Poll::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Poll::VERSION = '0.025';
|
||||
|
||||
has 'id';
|
||||
has 'question';
|
||||
@@ -52,7 +52,7 @@ Teapot::Bot::Object::Poll - The base class for Telegram 'Poll' type objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Poll' type objects
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::PollAnswer::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::PollAnswer::VERSION = '0.025';
|
||||
|
||||
has 'poll_id';
|
||||
has 'user';
|
||||
@@ -39,7 +39,7 @@ Teapot::Bot::Object::PollAnswer - The base class for Telegram 'PollAnswer' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'PollAnswer' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::PollOption::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::PollOption::VERSION = '0.025';
|
||||
|
||||
has 'text';
|
||||
has 'voter_count';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::PollOption - The base class for Telegram 'PollOption' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'PollOption' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::ProximityAlertTriggered::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::ProximityAlertTriggered::VERSION = '0.025';
|
||||
|
||||
has 'traveler'; # User
|
||||
has 'watcher'; # User
|
||||
@@ -35,7 +35,7 @@ Teapot::Bot::Object::ProximityAlertTriggered - The base class for Telegram messa
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'ProximityAlertTriggered' type.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PhotoSize ();
|
||||
use Teapot::Bot::Object::MaskPosition ();
|
||||
|
||||
$Teapot::Bot::Object::Sticker::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Sticker::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -46,7 +46,7 @@ Teapot::Bot::Object::Sticker - The base class for Telegram message 'Sticker' typ
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'Sticker' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
# use Teapot::Bot::Object::OrderInfo;
|
||||
|
||||
$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.025';
|
||||
|
||||
has 'currency';
|
||||
has 'total_amount';
|
||||
@@ -41,7 +41,7 @@ Teapot::Bot::Object::SuccessfulPayment - The base class for Telegram 'Successful
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'SuccessfulPayment' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::User::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::User::VERSION = '0.025';
|
||||
|
||||
has 'id';
|
||||
has 'is_bot';
|
||||
@@ -41,7 +41,7 @@ Teapot::Bot::Object::User - The base class for Telegram message 'User' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'User' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::Location ();
|
||||
|
||||
$Teapot::Bot::Object::Venue::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Venue::VERSION = '0.025';
|
||||
|
||||
has 'location'; #Location
|
||||
has 'title';
|
||||
@@ -41,7 +41,7 @@ Teapot::Bot::Object::Venue - The base class for Telegram 'LoginUrl' type objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'LoginUrl' type objects.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PhotoSize ();
|
||||
|
||||
$Teapot::Bot::Object::Video::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Video::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -43,7 +43,7 @@ Teapot::Bot::Object::Video - The base class for Telegram 'Video' object
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Video' object.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::VideoChatEnded::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::VideoChatEnded::VERSION = '0.025';
|
||||
|
||||
# This object represents a service message about a Video chat started in the chat. Currently holds no information.
|
||||
has 'duration';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatEnded - The base class for Telegram message 'Video
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'VideoChatEnded' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::User ();
|
||||
|
||||
$Teapot::Bot::Object::VideoChatParticipantsInvited::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::VideoChatParticipantsInvited::VERSION = '0.025';
|
||||
|
||||
# This object represents a service message about a Video chat started in the chat. Currently holds no information.
|
||||
has 'users';
|
||||
@@ -36,7 +36,7 @@ Teapot::Bot::Object::VideoChatParticipantsInvited - The base class for Telegram
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'VideoChatParticipantsInvited' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::VideoChatScheduled::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::VideoChatScheduled::VERSION = '0.025';
|
||||
|
||||
# This object represents a service message about a video chat started in the chat. Currently holds no information.
|
||||
has 'start_date';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatScheduled - The base class for Telegram message 'V
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'VideoChatScheduled' type.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::VideoChatStarted::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::VideoChatStarted::VERSION = '0.025';
|
||||
|
||||
# This object represents a service message about a Video chat started in the chat. Currently holds no information.
|
||||
has 'stub';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatStarted - The base class for Telegram message 'Vid
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram message 'VideoChatStarted' type.
|
||||
|
||||
@@ -9,7 +9,7 @@ use utf8;
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
use Teapot::Bot::Object::PhotoSize ();
|
||||
|
||||
$Teapot::Bot::Object::VideoNote::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::VideoNote::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -40,7 +40,7 @@ Teapot::Bot::Object::VideoNote - The base class for Telegram 'VideoNote' type ob
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'VideoNote' type object.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::Voice::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::Voice::VERSION = '0.025';
|
||||
|
||||
has 'file_id';
|
||||
has 'file_unique_id';
|
||||
@@ -34,7 +34,7 @@ Teapot::Bot::Object::Voice - The base class for Telegram 'Voice' type objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'Voice' type objects.
|
||||
|
||||
@@ -8,7 +8,7 @@ use utf8;
|
||||
|
||||
use Mojo::Base 'Teapot::Bot::Object::Base';
|
||||
|
||||
$Teapot::Bot::Object::WebAppData::VERSION = '0.024';
|
||||
$Teapot::Bot::Object::WebAppData::VERSION = '0.025';
|
||||
|
||||
has 'data';
|
||||
has 'button_text';
|
||||
@@ -31,7 +31,7 @@ Teapot::Bot::Object::WebAppData - The base class for Telegram 'WebAppData' type
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 0.024
|
||||
version 0.025
|
||||
|
||||
=head1 DESCRIPTION
|
||||
The base class for Telegram 'WebAppData' type objects.
|
||||
|
||||
Reference in New Issue
Block a user