diff --git a/lib/Teapot/Bot.pm b/lib/Teapot/Bot.pm index c16a8dc..b8bd228 100644 --- a/lib/Teapot/Bot.pm +++ b/lib/Teapot/Bot.pm @@ -1,11 +1,10 @@ package Teapot::Bot; -$Teapot::Bot::VERSION = '0.021'; + use strict; use warnings; - +$Teapot::Bot::VERSION = '0.021'; # ABSTRACT: A base class to make your very own Telegram bot - 1; __END__ diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index aee8343..5aa92f2 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -1,7 +1,6 @@ package Teapot::Bot::Brain; -$Teapot::Bot::Brain::VERSION = '0.021'; -# ABSTRACT: A base class to make your very own Telegram bot +# ABSTRACT: A base class to make your very own Telegram bot use Mojo::Base -base; @@ -16,6 +15,8 @@ use Data::Dumper; use Teapot::Bot::Object::Message; +$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) }; @@ -50,6 +51,7 @@ sub add_repeating_task { # kick it off $repeater->(); + return; } @@ -58,6 +60,7 @@ sub add_listener { my $coderef = shift; push @{ $self->listeners }, $coderef; + return; } sub init { @@ -71,6 +74,7 @@ sub think { $self->_add_getUpdates_handler; Mojo::IOLoop->start unless Mojo::IOLoop->is_running; + return; } @@ -106,7 +110,6 @@ sub sendMessage { # check reply_markup is the right kind if (exists $args->{reply_markup}) { my $reply_markup = $args->{reply_markup}; - die "bad reply_markup supplied" 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' && @@ -201,6 +204,8 @@ sub _add_getUpdates_handler { $http_active = 0; }); }); + + return; } # process a message which arrived via getUpdates @@ -227,6 +232,8 @@ sub _process_message { # call the listener code, supplying ourself and the update $listener->($self, $update); } + + return; } diff --git a/lib/Teapot/Bot/Object/Animation.pm b/lib/Teapot/Bot/Object/Animation.pm index 0774fc1..8414370 100644 --- a/lib/Teapot/Bot/Object/Animation.pm +++ b/lib/Teapot/Bot/Object/Animation.pm @@ -1,12 +1,12 @@ package Teapot::Bot::Object::Animation; -$Teapot::Bot::Object::Animation::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'Animation' type. - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize; use Carp qw/croak/; +$Teapot::Bot::Object::Animation::VERSION = '0.021'; + has 'file_id'; has 'width'; has 'height'; diff --git a/lib/Teapot/Bot/Object/Audio.pm b/lib/Teapot/Bot/Object/Audio.pm index fa6cb3c..faab728 100644 --- a/lib/Teapot/Bot/Object/Audio.pm +++ b/lib/Teapot/Bot/Object/Audio.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Audio; -$Teapot::Bot::Object::Audio::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Audio' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::Audio::VERSION = '0.021'; + has 'file_id'; has 'duration'; has 'performer'; diff --git a/lib/Teapot/Bot/Object/Base.pm b/lib/Teapot/Bot/Object/Base.pm index ed95e99..d5b108b 100644 --- a/lib/Teapot/Bot/Object/Base.pm +++ b/lib/Teapot/Bot/Object/Base.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Base; -$Teapot::Bot::Object::Base::VERSION = '0.021'; # ABSTRACT: The base class for all Teapot::Bot::Object objects. - use Mojo::Base -base; +$Teapot::Bot::Object::Base::VERSION = '0.021'; + has '_brain'; # a reference to our brain diff --git a/lib/Teapot/Bot/Object/Chat.pm b/lib/Teapot/Bot/Object/Chat.pm index 37f0a10..8bdef5b 100644 --- a/lib/Teapot/Bot/Object/Chat.pm +++ b/lib/Teapot/Bot/Object/Chat.pm @@ -1,12 +1,12 @@ package Teapot::Bot::Object::Chat; -$Teapot::Bot::Object::Chat::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Chat' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::ChatPhoto; use Teapot::Bot::Object::Message; +$Teapot::Bot::Object::Chat::VERSION = '0.021'; + has 'id'; has 'type'; has 'title'; @@ -34,12 +34,12 @@ sub fields { sub is_user { - shift->id > 0; + return shift->id > 0; } sub is_group { - shift->id < 0; + return shift->id < 0; } 1; diff --git a/lib/Teapot/Bot/Object/ChatPhoto.pm b/lib/Teapot/Bot/Object/ChatPhoto.pm index 46f8e41..9bbbddb 100644 --- a/lib/Teapot/Bot/Object/ChatPhoto.pm +++ b/lib/Teapot/Bot/Object/ChatPhoto.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::ChatPhoto; -$Teapot::Bot::Object::ChatPhoto::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'ChatPhoto' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::ChatPhoto::VERSION = '0.021'; + has 'small_file_id'; has 'big_file_id'; diff --git a/lib/Teapot/Bot/Object/Contact.pm b/lib/Teapot/Bot/Object/Contact.pm index 58cd6b1..97da25f 100644 --- a/lib/Teapot/Bot/Object/Contact.pm +++ b/lib/Teapot/Bot/Object/Contact.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Contact; -$Teapot::Bot::Object::Contact::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Contact' objects. - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::Contact::VERSION = '0.021'; + has 'phone_number'; has 'first_name'; has 'last_name'; diff --git a/lib/Teapot/Bot/Object/Document.pm b/lib/Teapot/Bot/Object/Document.pm index 78beb37..4f5cd1e 100644 --- a/lib/Teapot/Bot/Object/Document.pm +++ b/lib/Teapot/Bot/Object/Document.pm @@ -1,12 +1,12 @@ package Teapot::Bot::Object::Document; -$Teapot::Bot::Object::Document::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Document' objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize; +$Teapot::Bot::Object::Document::VERSION = '0.021'; + has 'file_id'; has 'thumb'; #PhotoSize has 'file_name'; diff --git a/lib/Teapot/Bot/Object/EncryptedCredentials.pm b/lib/Teapot/Bot/Object/EncryptedCredentials.pm index 1a78440..7cba096 100644 --- a/lib/Teapot/Bot/Object/EncryptedCredentials.pm +++ b/lib/Teapot/Bot/Object/EncryptedCredentials.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::EncryptedCredentials; -$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'EncryptedCredentials' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.021'; + has 'data'; has 'hash'; has 'secret'; diff --git a/lib/Teapot/Bot/Object/EncryptedPassportElement.pm b/lib/Teapot/Bot/Object/EncryptedPassportElement.pm index 560fa00..41a1899 100644 --- a/lib/Teapot/Bot/Object/EncryptedPassportElement.pm +++ b/lib/Teapot/Bot/Object/EncryptedPassportElement.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::EncryptedPassportElement; -$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'EncryptedPassportElement' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.021'; + # XXX Implement rest of this # https://core.telegram.org/bots/api#encryptedpassportelement diff --git a/lib/Teapot/Bot/Object/Game.pm b/lib/Teapot/Bot/Object/Game.pm index b27574c..849b954 100644 --- a/lib/Teapot/Bot/Object/Game.pm +++ b/lib/Teapot/Bot/Object/Game.pm @@ -1,5 +1,4 @@ package Teapot::Bot::Object::Game; -$Teapot::Bot::Object::Game::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'Game' type. @@ -8,6 +7,8 @@ use Teapot::Bot::Object::PhotoSize; use Teapot::Bot::Object::Animation; use Teapot::Bot::Object::MessageEntity; +$Teapot::Bot::Object::Game::VERSION = '0.021'; + has 'title'; has 'description'; has 'photo'; # Array of PhotoSize @@ -23,7 +24,7 @@ sub fields { }; } -sub arrays { qw/photo text_entities/ } +sub arrays { return qw/photo text_entities/; } 1; diff --git a/lib/Teapot/Bot/Object/InlineKeyboardButton.pm b/lib/Teapot/Bot/Object/InlineKeyboardButton.pm index 97d9f31..d310556 100644 --- a/lib/Teapot/Bot/Object/InlineKeyboardButton.pm +++ b/lib/Teapot/Bot/Object/InlineKeyboardButton.pm @@ -1,12 +1,12 @@ package Teapot::Bot::Object::InlineKeyboardButton; -$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'InlineKeyboardButton' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::LoginUrl; use Teapot::Bot::Object::CallbackGame; +$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.021'; + has 'text'; has 'url'; has 'login_url'; #LoginUrl diff --git a/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm b/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm index d02dc7e..2a023ae 100644 --- a/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm +++ b/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::InlineKeyboardMarkup; -$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'InlineKeyboardMarkup' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::InlineKeyboardButton; +$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.021'; + has 'inline_keyboard'; sub fields { diff --git a/lib/Teapot/Bot/Object/Invoice.pm b/lib/Teapot/Bot/Object/Invoice.pm index a185014..a018392 100644 --- a/lib/Teapot/Bot/Object/Invoice.pm +++ b/lib/Teapot/Bot/Object/Invoice.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Invoice; -$Teapot::Bot::Object::Invoice::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Invoice' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::Invoice::VERSION = '0.021'; + has 'title'; has 'description'; has 'start_parameter'; diff --git a/lib/Teapot/Bot/Object/Location.pm b/lib/Teapot/Bot/Object/Location.pm index a2334fb..0386ce6 100644 --- a/lib/Teapot/Bot/Object/Location.pm +++ b/lib/Teapot/Bot/Object/Location.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Location; -$Teapot::Bot::Object::Location::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'Location' type. - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::Location::VERSION = '0.021'; + has 'longitude'; has 'latitude'; diff --git a/lib/Teapot/Bot/Object/LoginUrl.pm b/lib/Teapot/Bot/Object/LoginUrl.pm index 275c670..86f5ae9 100644 --- a/lib/Teapot/Bot/Object/LoginUrl.pm +++ b/lib/Teapot/Bot/Object/LoginUrl.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::LoginUrl; -$Teapot::Bot::Object::LoginUrl::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'LoginUrl' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::LoginUrl::VERSION = '0.021'; + has 'url'; has 'forward_text'; has 'bot_username'; diff --git a/lib/Teapot/Bot/Object/Message.pm b/lib/Teapot/Bot/Object/Message.pm index e958ea0..c6fd194 100644 --- a/lib/Teapot/Bot/Object/Message.pm +++ b/lib/Teapot/Bot/Object/Message.pm @@ -1,8 +1,6 @@ package Teapot::Bot::Object::Message; -$Teapot::Bot::Object::Message::VERSION = '0.021'; # ABSTRACT: The base class for the Telegram type "Message". - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User; @@ -30,6 +28,8 @@ use Teapot::Bot::Object::InlineKeyboardMarkup; use Data::Dumper; +$Teapot::Bot::Object::Message::VERSION = '0.021'; + # basic message stuff has 'message_id'; has 'from'; # User @@ -124,7 +124,7 @@ sub fields { } sub arrays { - qw/photo entities caption_entities new_chat_members new_chat_photo/ + return qw/photo entities caption_entities new_chat_members new_chat_photo/; } diff --git a/lib/Teapot/Bot/Object/MessageEntity.pm b/lib/Teapot/Bot/Object/MessageEntity.pm index 6da30b6..491b56f 100644 --- a/lib/Teapot/Bot/Object/MessageEntity.pm +++ b/lib/Teapot/Bot/Object/MessageEntity.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::MessageEntity; -$Teapot::Bot::Object::MessageEntity::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'MessageEntity' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User; +$Teapot::Bot::Object::MessageEntity::VERSION = '0.021'; + has 'type'; has 'offset'; has 'length'; diff --git a/lib/Teapot/Bot/Object/PassportData.pm b/lib/Teapot/Bot/Object/PassportData.pm index 88c4e9a..98c6d06 100644 --- a/lib/Teapot/Bot/Object/PassportData.pm +++ b/lib/Teapot/Bot/Object/PassportData.pm @@ -1,12 +1,12 @@ package Teapot::Bot::Object::PassportData; -$Teapot::Bot::Object::PassportData::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'PassportData' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::EncryptedPassportElement; use Teapot::Bot::Object::EncryptedCredentials; +$Teapot::Bot::Object::PassportData::VERSION = '0.021'; + has 'data'; # Array of EncryptedPassportElement has 'credentials'; # EncryptedCredentials @@ -15,8 +15,9 @@ sub fields { 'Teapot::Bot::Object::EncryptedCredentials' => [qw/credentials/], }; } + sub arrays { - qw/data/; + return qw/data/; } 1; diff --git a/lib/Teapot/Bot/Object/PhotoSize.pm b/lib/Teapot/Bot/Object/PhotoSize.pm index 7435fd2..d4f0608 100644 --- a/lib/Teapot/Bot/Object/PhotoSize.pm +++ b/lib/Teapot/Bot/Object/PhotoSize.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::PhotoSize; -$Teapot::Bot::Object::PhotoSize::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'PhotoSize' type. - use Mojo::Base 'Teapot::Bot::Object::Base'; use Carp qw/croak/; +$Teapot::Bot::Object::PhotoSize::VERSION = '0.021'; + has 'file_id'; has 'width'; has 'height'; diff --git a/lib/Teapot/Bot/Object/Poll.pm b/lib/Teapot/Bot/Object/Poll.pm index eade28f..61009b4 100644 --- a/lib/Teapot/Bot/Object/Poll.pm +++ b/lib/Teapot/Bot/Object/Poll.pm @@ -1,11 +1,10 @@ package Teapot::Bot::Object::Poll; -$Teapot::Bot::Object::Poll::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Poll' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PollOption; +$Teapot::Bot::Object::Poll::VERSION = '0.021'; has 'id'; has 'question'; @@ -20,7 +19,7 @@ sub fields { } sub arrays { - qw/options/; + return qw/options/; } 1; diff --git a/lib/Teapot/Bot/Object/PollOption.pm b/lib/Teapot/Bot/Object/PollOption.pm index a9df01c..e2d2f2f 100644 --- a/lib/Teapot/Bot/Object/PollOption.pm +++ b/lib/Teapot/Bot/Object/PollOption.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::PollOption; -$Teapot::Bot::Object::PollOption::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'PollOption' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::PollOption::VERSION = '0.021'; + has 'text'; has 'voter_count'; diff --git a/lib/Teapot/Bot/Object/Sticker.pm b/lib/Teapot/Bot/Object/Sticker.pm index 3005e28..59d658e 100644 --- a/lib/Teapot/Bot/Object/Sticker.pm +++ b/lib/Teapot/Bot/Object/Sticker.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::Sticker; -$Teapot::Bot::Object::Sticker::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'Sticker' type. - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize; +$Teapot::Bot::Object::Sticker::VERSION = '0.021'; + has 'file_id'; has 'width'; has 'height'; diff --git a/lib/Teapot/Bot/Object/SuccessfulPayment.pm b/lib/Teapot/Bot/Object/SuccessfulPayment.pm index 3aa4d1b..6574d91 100644 --- a/lib/Teapot/Bot/Object/SuccessfulPayment.pm +++ b/lib/Teapot/Bot/Object/SuccessfulPayment.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::SuccessfulPayment; -$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'SuccessfulPayment' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; # use Teapot::Bot::Object::OrderInfo; +$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.021'; + has 'currency'; has 'total_amount'; has 'invoice_payload'; diff --git a/lib/Teapot/Bot/Object/User.pm b/lib/Teapot/Bot/Object/User.pm index d0b9304..eeb332d 100644 --- a/lib/Teapot/Bot/Object/User.pm +++ b/lib/Teapot/Bot/Object/User.pm @@ -1,10 +1,11 @@ package Teapot::Bot::Object::User; -$Teapot::Bot::Object::User::VERSION = '0.021'; # ABSTRACT: The base class for Telegram message 'User' type. use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::User::VERSION = '0.021'; + has 'id'; has 'is_bot'; has 'first_name'; diff --git a/lib/Teapot/Bot/Object/Venue.pm b/lib/Teapot/Bot/Object/Venue.pm index 08130da..df50a5c 100644 --- a/lib/Teapot/Bot/Object/Venue.pm +++ b/lib/Teapot/Bot/Object/Venue.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::Venue; -$Teapot::Bot::Object::Venue::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'LoginUrl' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::Location; +$Teapot::Bot::Object::Venue::VERSION = '0.021'; + has 'location'; #Location has 'title'; has 'address'; diff --git a/lib/Teapot/Bot/Object/Video.pm b/lib/Teapot/Bot/Object/Video.pm index a34e2e1..ae3bf69 100644 --- a/lib/Teapot/Bot/Object/Video.pm +++ b/lib/Teapot/Bot/Object/Video.pm @@ -1,11 +1,11 @@ package Teapot::Bot::Object::Video; -$Teapot::Bot::Object::Video::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Video' object. - use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize; +$Teapot::Bot::Object::Video::VERSION = '0.021'; + has 'file_id'; has 'width'; has 'height'; diff --git a/lib/Teapot/Bot/Object/VideoNote.pm b/lib/Teapot/Bot/Object/VideoNote.pm index 7c90e86..d81273d 100644 --- a/lib/Teapot/Bot/Object/VideoNote.pm +++ b/lib/Teapot/Bot/Object/VideoNote.pm @@ -1,11 +1,12 @@ package Teapot::Bot::Object::VideoNote; -$Teapot::Bot::Object::VideoNote::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'VideoNote' type objects use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize; +$Teapot::Bot::Object::VideoNote::VERSION = '0.021'; + has 'file_id'; has 'length'; has 'duration'; diff --git a/lib/Teapot/Bot/Object/Voice.pm b/lib/Teapot/Bot/Object/Voice.pm index 50f5997..6ca34f5 100644 --- a/lib/Teapot/Bot/Object/Voice.pm +++ b/lib/Teapot/Bot/Object/Voice.pm @@ -1,10 +1,10 @@ package Teapot::Bot::Object::Voice; -$Teapot::Bot::Object::Voice::VERSION = '0.021'; # ABSTRACT: The base class for Telegram 'Voice' type objects - use Mojo::Base 'Teapot::Bot::Object::Base'; +$Teapot::Bot::Object::Voice::VERSION = '0.021'; + has 'file_id'; has 'duration'; has 'mime_type';