41 lines
682 B
Perl
41 lines
682 B
Perl
package TgMagicPdf;
|
|
|
|
use v5.38.2;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use feature 'signatures';
|
|
|
|
use Moo;
|
|
|
|
use Path::Tiny;
|
|
use YAML::PP;
|
|
use TgMagicPdf::Telegram;
|
|
|
|
sub config($self) {
|
|
if (!-f $self->config_file) {
|
|
die 'No such config file.';
|
|
}
|
|
my $ypp = YAML::PP->new;
|
|
my @documents = $ypp->load_file($self->config_file);
|
|
if (!scalar @documents) {
|
|
die "Unable to parse @{[$self->config_file->absolute]}.";
|
|
}
|
|
return $documents[0];
|
|
}
|
|
|
|
sub config_file($self) {
|
|
return $self->root->child('config.yml');
|
|
}
|
|
|
|
sub root($self) {
|
|
return path(__FILE__)->parent->parent;
|
|
}
|
|
|
|
sub run {
|
|
TgMagicPdf::Telegram->new->run;
|
|
Mojo::IOLoop->start;
|
|
}
|
|
1;
|