Compare commits

...

3 Commits

Author SHA1 Message Date
eleksir
4f9675f1d2 Import JSON::PP explicitly in lib/BotLib.pm 2024-08-22 21:44:09 +03:00
eleksir
1667772268 Make use of logOut() method 2024-08-22 21:42:58 +03:00
eleksir
ebaf2c9b38 Add logOut() method to Teapot lib 2024-08-22 21:29:49 +03:00
3 changed files with 22 additions and 0 deletions

View File

@@ -193,6 +193,10 @@ sub __fork {
sub __signal_handler {
$log->info ("[INFO] Caught a signal $OS_ERROR");
eval {
$main::TGM->logOut();
};
if (-e $pidfile) {
unlink $pidfile;
}

View File

@@ -10,6 +10,7 @@ use English qw ( -no_match_vars );
use Clone qw (clone);
use Data::Dumper qw (Dumper);
use JSON::PP ();
use Log::Any qw ($log);
use Math::Random::Secure qw (irand);

View File

@@ -958,6 +958,23 @@ sub _post_request {
return $result;
}
sub logOut {
my $self = shift;
my $send_args = {};
my $ret;
if (! defined($self->token) || $self->token eq '') {
$ret->{error} = 1;
$ret->{message} = 'No token supplied to logOut()';
return $ret;
}
my $url = sprintf 'https://api.telegram.org/bot%s/logOut', $self->token;
return $self->_post_request($url, $send_args);
}
1;