Perlcritic overhaul, apply to Teapot lib too

This commit is contained in:
eleksir
2022-02-12 17:31:09 +03:00
parent e84241c340
commit a9bb74b440
54 changed files with 493 additions and 263 deletions

10
.gitignore vendored
View File

@@ -2,15 +2,7 @@ _Deparsed_XSubs.pm
.idea/**
.vscode/**
.vstags
aleesa-telegram-bot.pid
aleesa-telegram.pid
data/cache/**
data/config.json
data/fortune/**
data/friday/**
data/gamestat/**
data/image/**
data/karma/**
data/lat/**
data/proverb/**
data/telegrambot-brains/**
vendor_perl/**

View File

@@ -96,3 +96,35 @@ lib_sections = NAME | VERSION | DESCRIPTION | AUTHOR | LICENSE AND COPYRIGHT
[-ControlStructures::ProhibitUntilBlocks]
# Until is really useful if condition is simple, so let's assume condition is
# always simple to read
[-CodeLayout::RequireASCII]
# Nope
[-Editor::RequireEmacsFileVariables]
[-TooMuchCode::ProhibitUnnecessaryUTF8Pragma]
[-ErrorHandling::RequireUseOfExceptions]
[-Lax::ProhibitEmptyQuotes::ExceptAsFallback]
[-TooMuchCode::ProhibitDuplicateLiteral]
[-ValuesAndExpressions::RequireConstantOnLeftSideOfEquality]
# But constants on the right side of coditional expression are more readable!
[-Lax::RequireConstantOnLeftSideOfEquality::ExceptEq]
# same as previous
[ValuesAndExpressions::RestrictLongStrings]
max_length = 200
[-TooMuchCode::ProhibitExtraStricture]
[-Documentation::ProhibitUnbalancedParens]
# closing paren on the next, you fucking fuck, so shut your ass up and stop farting on me
[-Subroutines::ProhibitCallsToUndeclaredSubs]
# Can't find how to mark DSL keywords
# (Moo{,se} provides has/with/extends/etc., Dancer{,2} provides more)
# This is problematic

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
@@ -29,9 +29,10 @@ no Cwd;
use Cwd::utf8 qw (chdir abs_path);
use File::Basename qw (basename dirname);
use File::Path qw (make_path);
use File::Spec qw ();
use Log::Any qw ($log);
use Log::Any::Adapter;
use Log::Any::For::Std;
use Log::Any::Adapter ();
use Log::Any::For::Std ();
use POSIX qw (setgid setuid setsid);
use BotLib::Conf qw (LoadConf);
use TelegramBot qw (RunTelegramBot);
@@ -68,8 +69,8 @@ if ($UID == 0) {
make_path (
$piddir, {
uid => $uid,
group => $gid
}
group => $gid,
},
);
}
@@ -80,8 +81,8 @@ if ($UID == 0) {
make_path (
$logdir, {
uid => $uid,
group => $gid
}
group => $gid,
},
) or die "Unable to create $logdir: $OS_ERROR\n";
}
}
@@ -101,14 +102,14 @@ if (defined $logfile) {
# verbosity paticulary for CHI.
Log::Any::Adapter->set (
{
category => 'CHI::Driver'
category => 'CHI::Driver',
},
'File',
$logfile,
log_level => 'warn'
log_level => 'warn',
);
} else {
Log::Any::Adapter->set ('File', '/dev/null');
Log::Any::Adapter->set ('File', File::Spec->devnull);
}
# double fork attach to /dev/null all stdio and go background
@@ -120,7 +121,7 @@ my $apath = abs_path $PROGRAM_NAME;
unless (defined $apath) {
$log->fatal ("[FATAL] Unable to get abs_path: $OS_ERROR\n");
exit 1;
};
}
# write pidfile
my $pidfile = sprintf '%s/%s.pid', $piddir, basename $apath;
@@ -152,7 +153,7 @@ our $RCONN;
# run bot, at last
RunTelegramBot ();
if (-f $pidfile) {
if (-e $pidfile) {
unlink $pidfile;
}
@@ -160,11 +161,11 @@ exit 0;
sub daemonize {
__fork ();
POSIX::setsid ();
open STDIN, '<', '/dev/null'; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
setsid ();
open STDIN, '<', File::Spec->devnull; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
# we handle STDOUT && STDERR via Log::Any::For::Std, so do not close them explicitly
#open STDOUT, '>', '/dev/null'; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
#open STDERR, '>', '/dev/null'; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
#open STDOUT, '>', File::Spec->devnull; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
#open STDERR, '>', File::Spec->devnull; ## no critic (InputOutput::RequireCheckedSyscalls, InputOutput::RequireCheckedOpen)
__fork ();
umask 0;
return;
@@ -188,7 +189,7 @@ sub __fork {
sub __signal_handler {
$log->info ("[INFO] Caught a signal $OS_ERROR");
if (-f $pidfile) {
if (-e $pidfile) {
unlink $pidfile;
}

View File

@@ -1,13 +1,13 @@
#!/usr/bin/perl
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use lib qw (./lib ./vendor_perl ./vendor_perl/lib/perl5);
use JSON::XS;
use JSON::XS ();
use version; our $VERSION = qw (1.0);

View File

@@ -1,18 +1,16 @@
package BotLib;
# store here utility functions that are not protocol-specified
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use Carp qw (carp);
use Clone qw (clone);
use Math::Random::Secure qw (irand);
use Data::Dumper;
use Log::Any qw ($log);
use Data::Dumper qw (Dumper);
use BotLib::Conf qw (LoadConf);
use BotLib::Admin qw (@ForbiddenMessageTypes GetForbiddenTypes AddForbiddenType
@@ -139,7 +137,7 @@ sub Command {
my $pubsub = $main::REDIS->pubsub;
$pubsub->json ($c->{'redis_router_channel'})->notify (
$c->{'redis_router_channel'} => $rmsg
$c->{'redis_router_channel'} => $rmsg,
);
# Если команда не найдена, но строка подозрительно напоминает команду help
} elsif (substr ($text, 1) eq 'help' || substr ($text, 1) eq 'помощь') {

View File

@@ -1,14 +1,13 @@
package BotLib::Admin;
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use Carp qw (cluck croak);
use CHI;
use CHI::Driver::BerkeleyDB;
use CHI ();
use CHI::Driver::BerkeleyDB ();
use BotLib::Conf qw (LoadConf);
use BotLib::Util qw (utf2sha1);
@@ -33,7 +32,7 @@ sub GetForbiddenTypes {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid),
);
foreach (@ForbiddenMessageTypes) {
@@ -60,7 +59,7 @@ sub AddForbiddenType {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid),
);
$cache->set ($type, 1, 'never');
@@ -74,7 +73,7 @@ sub DelForbiddenType {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid),
);
$cache->remove ($type);
@@ -88,7 +87,7 @@ sub ListForbidden {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'censor' . '_' . utf2sha1 ($chatid),
);
foreach (@ForbiddenMessageTypes) {
@@ -116,7 +115,7 @@ sub FortuneToggle (@) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'fortune'
namespace => __PACKAGE__ . '_' . 'fortune',
);
my $state = $cache->get ($chatid);
@@ -152,7 +151,7 @@ sub FortuneStatus ($) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'fortune'
namespace => __PACKAGE__ . '_' . 'fortune',
);
my $state = $cache->get ($chatid);
@@ -170,7 +169,7 @@ sub FortuneToggleList () {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'fortune'
namespace => __PACKAGE__ . '_' . 'fortune',
);
return $cache->get_keys ();
@@ -184,7 +183,7 @@ sub ChanMsgToggle (@) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'chan_msg'
namespace => __PACKAGE__ . '_' . 'chan_msg',
);
my $state = $cache->get ($chatid);
@@ -227,7 +226,7 @@ sub ChanMsgStatus ($) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'chan_msg'
namespace => __PACKAGE__ . '_' . 'chan_msg',
);
my $state = $cache->get ($chatid);
@@ -251,7 +250,7 @@ sub ChanMsgEnabled ($) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'chan_msg'
namespace => __PACKAGE__ . '_' . 'chan_msg',
);
my $state = $cache->get ($chatid);
@@ -271,7 +270,7 @@ sub ChanMsgToggleList () {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'chan_msg'
namespace => __PACKAGE__ . '_' . 'chan_msg',
);
return $cache->get_keys ();
@@ -285,7 +284,7 @@ sub PluginStatus (@) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid),
);
my $state = $cache->get ($plugin);
@@ -315,7 +314,7 @@ sub PluginEnabled (@) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid),
);
my $state = $cache->get ($plugin);
@@ -336,7 +335,7 @@ sub PluginToggle (@) {
my $cache = CHI->new (
driver => 'BerkeleyDB',
root_dir => $cachedir,
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid)
namespace => __PACKAGE__ . '_' . 'plugin' . '_' . utf2sha1 ($chatid),
);
my $state = $cache->get ($plugin);

View File

@@ -1,13 +1,13 @@
package BotLib::Conf;
# loads config
# Загружает конфиг файл
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use JSON::XS;
use JSON::XS ();
use version; our $VERSION = qw (1.0);
use Exporter qw (import);
@@ -15,7 +15,12 @@ our @EXPORT_OK = qw (LoadConf);
sub LoadConf {
my $c = 'data/config.json';
open my $CH, '<', $c or die "[FATAL] No conf at $c: $OS_ERROR\n";
my $CH;
unless (open $CH, '<', $c) {
die "[FATAL] No conf at $c: $OS_ERROR\n";
}
my $len = (stat $c) [7];
my $json;
my $readlen = read $CH, $json, $len;

View File

@@ -1,16 +1,16 @@
package BotLib::Util;
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use Digest::SHA qw (sha1_base64);
use Encode;
use MIME::Base64;
use Encode qw (encode_utf8);
use MIME::Base64 qw (encode_base64);
use Text::Fuzzy qw (distance_edits);
use URI::URL;
use URI::URL qw (url);
use version; our $VERSION = qw (1.0);
use Exporter qw (import);

View File

@@ -1,6 +1,6 @@
package RedisLib;
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
@@ -8,12 +8,12 @@ use open qw (:std :utf8);
use Log::Any qw ($log);
# Чтобы "уж точно" использовать hiredis-биндинги, загрузим этот модуль перед Mojo::Redis
use Protocol::Redis::XS;
use Mojo::Redis;
use Mojo::Redis::Connection;
use Protocol::Redis::XS ();
use Mojo::Redis ();
use Mojo::Redis::Connection ();
use BotLib::Conf qw (LoadConf);
use Teapot::Bot::Object::ChatPermissions;
use Teapot::Bot::Object::ChatPermissions ();
use version; our $VERSION = qw (1.0);
use Exporter qw (import);
@@ -48,7 +48,7 @@ sub redis_parse_message {
}
return;
};
}
sub redis_events_listener {
$log->notice ('[NOTICE] Run redis events listener');
@@ -66,7 +66,7 @@ sub redis_events_listener {
}
my $r = Mojo::Redis->new (
sprintf 'redis://%s:%s/1', $c->{redis_server}, $c->{redis_port}
sprintf 'redis://%s:%s/1', $c->{redis_server}, $c->{redis_port},
);
$log->notice ('[NOTICE] New redis client registered, registering callbacks');
@@ -85,11 +85,11 @@ sub redis_events_listener {
$log->error ("[ERROR] Redis connection error: $error");
$main::RCONN = undef;
return;
}
},
);
return;
}
},
);
# Subscribe to channels
@@ -102,7 +102,7 @@ sub redis_events_listener {
$log->info ("[INFO] Subscribing to $channel");
$sub->{$channel} = $pubsub->json ($channel)->listen (
$channel => sub { $rpm->(@_); }
$channel => sub { $rpm->(@_); },
);
}

View File

@@ -2,6 +2,8 @@ package Teapot::Bot;
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
$Teapot::Bot::VERSION = '0.022';
# ABSTRACT: A base class to make your very own Telegram bot
@@ -11,7 +13,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME

View File

@@ -6,25 +6,27 @@ use Mojo::Base -base;
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use English qw ( -no_match_vars );
use Mojo::IOLoop;
use Mojo::UserAgent;
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 Log::Any;
use Data::Dumper;
use Log::Any ();
use Data::Dumper qw (Dumper);
use Teapot::Bot::Object::Message;
use Teapot::Bot::Object::Poll;
use Teapot::Bot::Object::PollAnswer;
use Teapot::Bot::Object::ChatMemberUpdated;
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::Chat;
use Teapot::Bot::Object::ChatMember;
use Teapot::Bot::Object::ChatInviteLink;
use Teapot::Bot::Object::Message ();
use Teapot::Bot::Object::Poll ();
use Teapot::Bot::Object::PollAnswer ();
use Teapot::Bot::Object::ChatMemberUpdated ();
use Teapot::Bot::Object::User ();
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::ChatMember ();
use Teapot::Bot::Object::ChatInviteLink ();
$Teapot::Bot::Brain::VERSION = '0.022';
@@ -706,7 +708,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -764,7 +766,7 @@ This method will add a sub to run every C<$seconds> seconds. Pass this method
two parameters, the number of seconds between executions, and the coderef to
execute.
Your coderef will be passed the L<Teapot::Bot::Brain> object when it is
Your coderef will be passed the C<Teapot::Bot::Brain> object when it is
executed.
=head2 add_listener

View File

@@ -1,9 +1,13 @@
package Teapot::Bot::Object::Animation;
# ABSTRACT: The base class for Telegram message 'Animation' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize;
use Carp qw/croak/;
use Teapot::Bot::Object::PhotoSize ();
$Teapot::Bot::Object::Animation::VERSION = '0.022';
@@ -31,7 +35,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -45,7 +49,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Animation> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Audio;
# ABSTRACT: The base class for Telegram 'Audio' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Audio::VERSION = '0.022';
@@ -28,7 +33,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -42,7 +47,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Audio> objects.
=head1 AUTHOR

View File

@@ -1,11 +1,17 @@
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 strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Carp qw/croak cluck/;
use Data::Dumper;
use Data::Dumper qw (Dumper);
use JSON::PP ();
use List::Util qw/any/;
use Mojo::Base -base;
$Teapot::Bot::Object::Base::VERSION = '0.022';
@@ -27,7 +33,6 @@ sub _field_is_array {
return;
}
sub array_of_arrays { return qw// } #override if needed
sub _field_is_array_of_arrays {
my $self = shift;
@@ -59,9 +64,6 @@ sub create_from_array {
return $obj;
}
cluck "Dumping class: " . Dumper ($class);
cluck "Dumping array: " . Dumper ($array);
# it's stub, return $obj
return $obj;
}
@@ -163,7 +165,7 @@ sub as_hashref {
if (ref($self->$field) ne 'ARRAY' && defined $self->$field);
# array types
$hash->{$field} = [
map { $_->as_hashref } @{ $self->$field }
map { $_->as_hashref } @{ $self->$field },
] if (ref($self->$field) eq 'ARRAY');
}
}
@@ -177,7 +179,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -193,7 +195,7 @@ 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>,
You should generally not need to instantiate objects of sub-classes of C<Teapot::Bot::Object::Base>,
instead the appropriate objects will be created from an incoming request via
L<Teapot::Bot::Brain>.

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::CallbackGame;
# ABSTRACT: The base class for Telegram message 'CallbackGame' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::CallbackGame::VERSION = '0.022';
@@ -8,7 +13,7 @@ $Teapot::Bot::Object::CallbackGame::VERSION = '0.022';
# "A placeholder, currently holds no information. Use BotFather to set up your game"
sub fields {
return { },
return { };
}
1;
@@ -17,7 +22,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -31,7 +36,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::CallbackGame> objects.
=head1 AUTHOR

View File

@@ -1,11 +1,16 @@
package Teapot::Bot::Object::Chat;
# ABSTRACT: The base class for Telegram 'Chat' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::ChatPhoto;
use Teapot::Bot::Object::Message;
use Teapot::Bot::Object::ChatPermissions;
use Teapot::Bot::Object::ChatLocation;
use Teapot::Bot::Object::ChatPhoto ();
use Teapot::Bot::Object::Message ();
use Teapot::Bot::Object::ChatPermissions ();
use Teapot::Bot::Object::ChatLocation ();
$Teapot::Bot::Object::Chat::VERSION = '0.022';
@@ -64,7 +69,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -78,7 +83,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Chat> objects.
=head1 METHODS

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::ChatInviteLink;
# ABSTRACT: The base class for Telegram message 'ChatInviteLink' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::User ();
$Teapot::Bot::Object::ChatInviteLink::VERSION = '0.022';
@@ -31,7 +36,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -45,7 +50,7 @@ version 0.022
The base class for Telegram message 'ChatInviteLink' type.
See L<https://core.telegram.org/bots/api#chatinvitelink> for details of the
attributes available for L<Teapot::Bot::Object::ChatInviteLink> objects.
attributes available for C<Teapot::Bot::Object::ChatInviteLink> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::ChatLocation;
# ABSTRACT: The base class for Telegram message 'ChatLocation' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::ChatLocation::VERSION = '0.022';
@@ -21,7 +26,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -35,7 +40,7 @@ version 0.022
The base class for Telegram message 'ChatLocation' type.
See L<https://core.telegram.org/bots/api#chatlocation> for details of the
attributes available for L<Teapot::Bot::Object::ChatLocation> objects.
attributes available for C<Teapot::Bot::Object::ChatLocation> objects.
=head1 AUTHOR

View File

@@ -1,10 +1,17 @@
package Teapot::Bot::Object::ChatMember;
# ABSTRACT: The base class for Telegram 'ChatMember' type objects
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User;
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Carp qw(cluck);
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User ();
$Teapot::Bot::Object::ChatMember::VERSION = '0.022';
# ChatMemberOwner
@@ -130,7 +137,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -144,7 +151,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::ChatMember> objects.
=head1 METHODS

View File

@@ -1,12 +1,17 @@
package Teapot::Bot::Object::ChatMemberUpdated;
# ABSTRACT: The base class for Telegram 'ChatMemberUpdated' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::Chat;
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::ChatMember;
use Teapot::Bot::Object::ChatInviteLink;
use Teapot::Bot::Object::Voice;
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::User ();
use Teapot::Bot::Object::ChatMember ();
use Teapot::Bot::Object::ChatInviteLink ();
use Teapot::Bot::Object::Voice ();
$Teapot::Bot::Object::ChatMemberUpdated::VERSION = '0.022';
@@ -27,7 +32,7 @@ sub fields {
'scalar' => [qw/date text/],
'Teapot::Bot::Object::ChatMember' => [qw/old_chat_member new_chat_member/],
'Teapot::Bot::Object::Voice' => [qw/voice/],
'Teapot::Bot::Object::ChatInviteLink' => [qw/invite_link/]
'Teapot::Bot::Object::ChatInviteLink' => [qw/invite_link/],
};
}
@@ -37,7 +42,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -51,7 +56,7 @@ version 0.022
The base class for Telegram 'ChatMemberUpdated' type objects.
See L<https://core.telegram.org/bots/api#chatmemberupdated> for details of the
attributes available for L<Teapot::Bot::Object::ChatMemberUpdated> objects.
attributes available for C<Teapot::Bot::Object::ChatMemberUpdated> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,14 @@
package Teapot::Bot::Object::ChatPermissions;
# ABSTRACT: The base class for Telegram 'ChatPermissions' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Carp qw(carp);
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Brain;
use Teapot::Bot::Brain ();
$Teapot::Bot::Object::ChatPermissions::VERSION = '0.022';
@@ -25,7 +31,7 @@ sub fields {
return {
'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/]
can_invite_users can_pin_messages/],
};
}
@@ -84,7 +90,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -98,7 +104,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::ChatPermissions> objects.
=head1 METHODS

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::ChatPhoto;
# ABSTRACT: The base class for Telegram 'ChatPhoto' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::ChatPhoto::VERSION = '0.022';
@@ -22,7 +27,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -36,7 +41,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::ChatPhoto> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Contact;
# ABSTRACT: The base class for Telegram 'Contact' objects.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Contact::VERSION = '0.022';
@@ -23,7 +28,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -37,7 +42,7 @@ version 0.022
The base class for Telegram 'Contact' objects.
See L<https://core.telegram.org/bots/api#contact> for details of the
attributes available for L<Teapot::Bot::Object::Contact> objects.
attributes available for C<Teapot::Bot::Object::Contact> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Dice;
# ABSTRACT: The base class for Telegram message 'Dice' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Dice::VERSION = '0.022';
@@ -18,7 +23,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -32,7 +37,7 @@ version 0.022
The base class for Telegram message 'Dice' type.
See L<https://core.telegram.org/bots/api#dice> for details of the
attributes available for L<Teapot::Bot::Object::dice> objects.
attributes available for C<Teapot::Bot::Object::dice> objects.
=head1 AUTHOR

View File

@@ -1,9 +1,13 @@
package Teapot::Bot::Object::Document;
# ABSTRACT: The base class for Telegram 'Document' objects
use Mojo::Base 'Teapot::Bot::Object::Base';
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Teapot::Bot::Object::PhotoSize;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize ();
$Teapot::Bot::Object::Document::VERSION = '0.022';
@@ -17,7 +21,7 @@ has 'file_size';
sub fields {
return {
scalar => [qw/file_id file_unique_id file_name mime_type file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/]
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/],
};
}
@@ -27,7 +31,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -41,7 +45,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Document> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::EncryptedCredentials;
# ABSTRACT: The base class for Telegram 'EncryptedCredentials' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.022';
@@ -19,7 +24,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -33,7 +38,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::EncryptedCredentials> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::EncryptedPassportElement;
# ABSTRACT: The base class for Telegram 'EncryptedPassportElement' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.022';
@@ -25,7 +30,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -39,7 +44,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::EncryptedPassportElement> objects.
Note that this type is not yet fully implemented.

View File

@@ -1,11 +1,15 @@
package Teapot::Bot::Object::Game;
# ABSTRACT: The base class for Telegram message 'Game' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::Animation;
use Teapot::Bot::Object::MessageEntity;
use Teapot::Bot::Object::PhotoSize ();
use Teapot::Bot::Object::Animation ();
use Teapot::Bot::Object::MessageEntity ();
$Teapot::Bot::Object::Game::VERSION = '0.022';
@@ -33,7 +37,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -47,7 +51,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Game> objects.
=head1 AUTHOR

View File

@@ -1,9 +1,14 @@
package Teapot::Bot::Object::InlineKeyboardButton;
# ABSTRACT: The base class for Telegram 'InlineKeyboardButton' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::LoginUrl;
use Teapot::Bot::Object::CallbackGame;
use Teapot::Bot::Object::LoginUrl ();
use Teapot::Bot::Object::CallbackGame ();
$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.022';
@@ -30,7 +35,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -44,7 +49,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::InlineKeyboardButton> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::InlineKeyboardMarkup;
# ABSTRACT: The base class for Telegram 'InlineKeyboardMarkup' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::InlineKeyboardButton;
use Teapot::Bot::Object::InlineKeyboardButton ();
$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.022';
@@ -22,7 +27,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -36,7 +41,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::InlineKeyboardMarkup> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Invoice;
# ABSTRACT: The base class for Telegram 'Invoice' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Invoice::VERSION = '0.022';
@@ -21,7 +26,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -35,7 +40,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Invoice> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Location;
# ABSTRACT: The base class for Telegram message 'Location' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Location::VERSION = '0.022';
@@ -22,7 +27,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -36,7 +41,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Location> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::LoginUrl;
# ABSTRACT: The base class for Telegram 'LoginUrl' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::LoginUrl::VERSION = '0.022';
@@ -20,7 +25,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -34,7 +39,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::LoginUrl> objects.
=head1 AUTHOR

View File

@@ -1,42 +1,44 @@
package Teapot::Bot::Object::Message;
# ABSTRACT: The base class for the Telegram type "Message".
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::Chat;
use Teapot::Bot::Object::ChatMember;
use Teapot::Bot::Object::ChatPermissions;
use Teapot::Bot::Object::MessageEntity;
use Teapot::Bot::Object::Audio;
use Teapot::Bot::Object::Document;
use Teapot::Bot::Object::Animation;
use Teapot::Bot::Object::Game;
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::Sticker;
use Teapot::Bot::Object::Video;
use Teapot::Bot::Object::Voice;
use Teapot::Bot::Object::VideoNote;
use Teapot::Bot::Object::Contact;
use Teapot::Bot::Object::Location;
use Teapot::Bot::Object::Poll;
use Teapot::Bot::Object::Location;
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::Invoice;
use Teapot::Bot::Object::Venue;
use Teapot::Bot::Object::SuccessfulPayment;
use Teapot::Bot::Object::PassportData;
use Teapot::Bot::Object::InlineKeyboardMarkup;
use Teapot::Bot::Object::ProximityAlertTriggered;
use Teapot::Bot::Object::Dice;
use Teapot::Bot::Object::MessageAutoDeleteTimerChanged;
use Teapot::Bot::Object::VoiceChatScheduled;
use Teapot::Bot::Object::VoiceChatStarted;
use Teapot::Bot::Object::VoiceChatEnded;
use Teapot::Bot::Object::VoiceChatParticipantsInvited;
use Data::Dumper;
use Carp qw(cluck);
use Teapot::Bot::Object::User ();
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::ChatMember ();
use Teapot::Bot::Object::ChatPermissions ();
use Teapot::Bot::Object::MessageEntity ();
use Teapot::Bot::Object::Audio ();
use Teapot::Bot::Object::Document ();
use Teapot::Bot::Object::Animation ();
use Teapot::Bot::Object::Game ();
use Teapot::Bot::Object::PhotoSize ();
use Teapot::Bot::Object::Sticker ();
use Teapot::Bot::Object::Video ();
use Teapot::Bot::Object::Voice ();
use Teapot::Bot::Object::VideoNote ();
use Teapot::Bot::Object::Contact ();
use Teapot::Bot::Object::Location ();
use Teapot::Bot::Object::Poll ();
use Teapot::Bot::Object::Location ();
use Teapot::Bot::Object::PhotoSize ();
use Teapot::Bot::Object::Invoice ();
use Teapot::Bot::Object::Venue ();
use Teapot::Bot::Object::SuccessfulPayment ();
use Teapot::Bot::Object::PassportData ();
use Teapot::Bot::Object::InlineKeyboardMarkup ();
use Teapot::Bot::Object::ProximityAlertTriggered ();
use Teapot::Bot::Object::Dice ();
use Teapot::Bot::Object::MessageAutoDeleteTimerChanged ();
use Teapot::Bot::Object::VoiceChatScheduled ();
use Teapot::Bot::Object::VoiceChatStarted ();
use Teapot::Bot::Object::VoiceChatEnded ();
use Teapot::Bot::Object::VoiceChatParticipantsInvited ();
$Teapot::Bot::Object::Message::VERSION = '0.022';
@@ -200,7 +202,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -214,7 +216,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Message> objects.
=head1 METHODS
@@ -222,7 +224,7 @@ attributes available for L<Teapot::Bot::Object::Message> objects.
A convenience method to reply to a message with text.
Will return the L<Teapot::Bot::Object::Message> object representing the message
Will return the C<Teapot::Bot::Object::Message> object representing the message
sent.
=head2 typing

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::MessageAutoDeleteTimerChanged;
# ABSTRACT: The base class for Telegram 'MessageAutoDeleteTimerChanged' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::MessageAutoDeleteTimerChanged::VERSION = '0.022';
@@ -19,7 +24,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -33,7 +38,7 @@ version 0.022
The base class for Telegram 'MessageAutoDeleteTimerChanged' type objects.
See L<https://core.telegram.org/bots/api#messageautodeletetimerchanged> for details of the
attributes available for L<Teapot::Bot::Object::MessageAutoDeleteTimerChanged> objects.
attributes available for C<Teapot::Bot::Object::MessageAutoDeleteTimerChanged> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::MessageEntity;
# ABSTRACT: The base class for Telegram 'MessageEntity' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::User ();
$Teapot::Bot::Object::MessageEntity::VERSION = '0.022';
@@ -26,7 +31,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -40,7 +45,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::MessageEntity> objects.
=head1 AUTHOR

View File

@@ -1,9 +1,14 @@
package Teapot::Bot::Object::PassportData;
# ABSTRACT: The base class for Telegram 'PassportData' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::EncryptedPassportElement;
use Teapot::Bot::Object::EncryptedCredentials;
use Teapot::Bot::Object::EncryptedPassportElement ();
use Teapot::Bot::Object::EncryptedCredentials ();
$Teapot::Bot::Object::PassportData::VERSION = '0.022';
@@ -27,7 +32,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -41,7 +46,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::PassportData> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,12 @@
package Teapot::Bot::Object::PhotoSize;
# ABSTRACT: The base class for Telegram message 'PhotoSize' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Carp qw/croak/;
$Teapot::Bot::Object::PhotoSize::VERSION = '0.022';
@@ -22,7 +26,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -36,7 +40,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::PhotoSize> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::Poll;
# ABSTRACT: The base class for Telegram 'Poll' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PollOption;
use Teapot::Bot::Object::PollOption ();
$Teapot::Bot::Object::Poll::VERSION = '0.022';
@@ -39,7 +44,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -53,7 +58,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Poll> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::PollAnswer;
# ABSTRACT: The base class for Telegram 'PollOption' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::PollAnswer::VERSION = '0.022';
@@ -26,7 +31,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -40,7 +45,7 @@ version 0.022
The base class for Telegram 'PollAnswer' type objects.
See L<https://core.telegram.org/bots/api#pollanswer> for details of the
attributes available for L<Teapot::Bot::Object::PollAnswer> objects.
attributes available for C<Teapot::Bot::Object::PollAnswer> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::PollOption;
# ABSTRACT: The base class for Telegram 'PollOption' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::PollOption::VERSION = '0.022';
@@ -18,7 +23,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -32,7 +37,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::PollOption> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::ProximityAlertTriggered;
# ABSTRACT: The base class for Telegram message 'ProximityAlertTriggered' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::ProximityAlertTriggered::VERSION = '0.022';
@@ -22,7 +27,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -36,7 +41,7 @@ version 0.022
The base class for Telegram message 'ProximityAlertTriggered' type.
See L<https://core.telegram.org/bots/api#proximityalerttriggered> for details of the
attributes available for L<Teapot::Bot::Object::ProximityAlertTriggered> objects.
attributes available for C<Teapot::Bot::Object::ProximityAlertTriggered> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::Sticker;
# ABSTRACT: The base class for Telegram message 'Sticker' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::PhotoSize ();
$Teapot::Bot::Object::Sticker::VERSION = '0.022';
@@ -28,7 +33,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -42,7 +47,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Sticker> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::SuccessfulPayment;
# ABSTRACT: The base class for Telegram 'SuccessfulPayment' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
# use Teapot::Bot::Object::OrderInfo;
@@ -28,7 +33,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -42,7 +47,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::SuccessfulPayment> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,10 @@
package Teapot::Bot::Object::User;
# ABSTRACT: The base class for Telegram message 'User' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
@@ -19,7 +23,7 @@ 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
can_read_all_group_messages supports_inline_queries/]
can_read_all_group_messages supports_inline_queries/],
};
}
@@ -29,7 +33,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -43,7 +47,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::User> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::Venue;
# ABSTRACT: The base class for Telegram 'LoginUrl' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::Location;
use Teapot::Bot::Object::Location ();
$Teapot::Bot::Object::Venue::VERSION = '0.022';
@@ -17,7 +22,7 @@ has 'google_place_type';
sub fields {
return {
'scalar' => [qw/title address foursquare_id foursquare_type google_place_id google_place_type/],
'Teapot::Bot::Object::Location' => [qw/location/]
'Teapot::Bot::Object::Location' => [qw/location/],
};
}
@@ -28,7 +33,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -42,7 +47,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Venue> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::Video;
# ABSTRACT: The base class for Telegram 'Video' object.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::PhotoSize ();
$Teapot::Bot::Object::Video::VERSION = '0.022';
@@ -20,7 +25,7 @@ sub fields {
return {
scalar => [qw/file_id file_unique_id width height duration file_name mime_type
file_size/],
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/]
'Teapot::Bot::Object::PhotoSize' => [qw/thumb/],
};
}
@@ -30,7 +35,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -44,7 +49,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Video> objects.
=head1 AUTHOR

View File

@@ -1,9 +1,13 @@
package Teapot::Bot::Object::VideoNote;
# ABSTRACT: The base class for Telegram 'VideoNote' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::PhotoSize;
use Teapot::Bot::Object::PhotoSize ();
$Teapot::Bot::Object::VideoNote::VERSION = '0.022';
@@ -28,7 +32,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -42,7 +46,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::VideoNote> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::Voice;
# ABSTRACT: The base class for Telegram 'Voice' type objects
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::Voice::VERSION = '0.022';
@@ -21,7 +26,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -35,7 +40,7 @@ version 0.022
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.
attributes available for C<Teapot::Bot::Object::Voice> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::VoiceChatEnded;
# ABSTRACT: The base class for Telegram message 'VoiceChatEnded' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::VoiceChatEnded::VERSION = '0.022';
@@ -18,7 +23,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -32,7 +37,7 @@ version 0.022
The base class for Telegram message 'VoiceChatEnded' type.
See L<https://core.telegram.org/bots/api#voicechatended> for details of the
attributes available for L<Teapot::Bot::Object::VoiceChatEnded> objects.
attributes available for C<Teapot::Bot::Object::VoiceChatEnded> objects.
=head1 AUTHOR

View File

@@ -1,8 +1,13 @@
package Teapot::Bot::Object::VoiceChatParticipantsInvited;
# ABSTRACT: The base class for Telegram message 'VoiceChatParticipantsInvited' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::User;
use Teapot::Bot::Object::User ();
$Teapot::Bot::Object::VoiceChatParticipantsInvited::VERSION = '0.022';
@@ -23,7 +28,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -37,7 +42,7 @@ version 0.022
The base class for Telegram message 'VoiceChatParticipantsInvited' type.
See L<https://core.telegram.org/bots/api#voicechatparticipantsinvited> for details of the
attributes available for L<Teapot::Bot::Object::VoiceChatParticipantsInvited> objects.
attributes available for C<Teapot::Bot::Object::VoiceChatParticipantsInvited> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::VoiceChatScheduled;
# ABSTRACT: The base class for Telegram message 'VoiceChatEnded' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::VoiceChatScheduled::VERSION = '0.022';
@@ -18,7 +23,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -32,7 +37,7 @@ version 0.022
The base class for Telegram message 'VoiceChatScheduled' type.
See L<https://core.telegram.org/bots/api#voicechatscheduled> for details of the
attributes available for L<Teapot::Bot::Object::VoiceChatScheduled> objects.
attributes available for C<Teapot::Bot::Object::VoiceChatScheduled> objects.
=head1 AUTHOR

View File

@@ -1,6 +1,11 @@
package Teapot::Bot::Object::VoiceChatStarted;
# ABSTRACT: The base class for Telegram message 'VoiceChatStarted' type.
use strict;
use warnings;
use 5.018; ## no critic (ProhibitImplicitImport)
use utf8;
use Mojo::Base 'Teapot::Bot::Object::Base';
$Teapot::Bot::Object::VoiceChatStarted::VERSION = '0.022';
@@ -18,7 +23,7 @@ __END__
=pod
=encoding UTF-8
=encoding utf8
=head1 NAME
@@ -32,7 +37,7 @@ version 0.022
The base class for Telegram message 'VoiceChatStarted' type.
See L<https://core.telegram.org/bots/api#voicechatstarted> for details of the
attributes available for L<Teapot::Bot::Object::VoiceChatStarted> objects.
attributes available for C<Teapot::Bot::Object::VoiceChatStarted> objects.
=head1 AUTHOR

View File

@@ -1,15 +1,13 @@
package TelegramBot;
# main bot gears are here
use 5.018;
use 5.018; ## no critic (ProhibitImplicitImport)
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use Carp qw (cluck carp);
use Clone qw (clone);
use File::Path qw (make_path);
use Log::Any qw ($log);
use Math::Random::Secure qw (irand);
use Mojo::Base 'Teapot::Bot::Brain';
@@ -18,7 +16,7 @@ use BotLib::Admin qw (FortuneToggleList ChanMsgEnabled);
use BotLib qw (Command Highlight BotSleep IsCensored);
use BotLib::Conf qw (LoadConf);
use BotLib::Util qw (trim fmatch);
use RedisLib qw (redis_parse_message redis_events_listener);
use RedisLib qw (redis_events_listener);
use version; our $VERSION = qw (1.0);
use Exporter qw (import);
@@ -67,7 +65,7 @@ sub __cron {
$rmsg->{chatid} = $enabledfortunechat;
$pubsub->json ($c->{'redis_router_channel'})->notify (
$c->{'redis_router_channel'} => $rmsg
$c->{'redis_router_channel'} => $rmsg,
);
}
}
@@ -81,7 +79,7 @@ sub __on_msg {
my $chatid;
my $chatname = 'Noname chat';
# user sending message info
my ($userid, $username, $fullname, $highlight, $vis_a_vi) = BotLib::Highlight ($msg);
my ($userid, $username, $fullname, $highlight, $vis_a_vi) = Highlight ($msg);
my $csign = $c->{telegrambot}->{csign};
unless ($myid) {
@@ -161,7 +159,7 @@ sub __on_msg {
}
push @members, sprintf '[%s](tg://user?id=%s)', $member_str, $member->id;
};
}
if ($#members > 1) {
my $lastone = pop @members;
@@ -197,7 +195,7 @@ sub __on_msg {
$rmsg->{chatid} = $userid;
my $pubsub = $main::REDIS->pubsub;
$pubsub->json ($c->{'redis_router_channel'})->notify (
$c->{'redis_router_channel'} => $rmsg
$c->{'redis_router_channel'} => $rmsg,
);
return;
@@ -289,7 +287,7 @@ sub __on_msg {
my $pubsub = $main::REDIS->pubsub;
$pubsub->json ($c->{'redis_router_channel'})->notify (
$c->{'redis_router_channel'} => $rmsg
$c->{'redis_router_channel'} => $rmsg,
);
return;
@@ -337,7 +335,7 @@ sub __on_msg {
my $pubsub = $main::REDIS->pubsub;
$pubsub->json ($c->{'redis_router_channel'})->notify (
$c->{'redis_router_channel'} => $rmsg
$c->{'redis_router_channel'} => $rmsg,
);
return;
@@ -408,7 +406,7 @@ sub RunTelegramBot {
while (sleep 3) {
eval { ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval)
TelegramBot->new->think;
}
};
}
return;