Compare commits

...

2 Commits

2 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# Important for switch feature
use v5.34;
use v5.32;
use utf8;
use strict;
@ -13,6 +13,7 @@ use Encode;
# CPAN packages
use JSON;
use Log::Log4perl;
use YAML;
# Package name
package F1DataBot;
@ -36,6 +37,9 @@ sub new {
Telegram => 'https://api.telegram.org',
};
# load remembered update ids
$Self->{UpdateIDs} = YAML::LoadFile('update_ids.yml');
return $Self;
}
@ -386,11 +390,20 @@ sub fetchMessages {
my @Messages = $MessageDataRaw->{result}->@*;
$Self->{LogObject}
->info( 'fetchMessages: Messages returned are ' . Dumper( \@Messages ) );
MESSAGE:
for my $Message (@Messages) {
$Self->{LogObject}->info('fetchMessages: Calling processMessage');
$Self->processMessage( Message => $Message, );
if ($Self->{UpdateIDs}{$Message->{update_id}}) {
$Self->{LogObject}->info('fetchMessages: Skipping known update_id');
next MESSAGE;
}
else {
$Self->{UpdateIDs}{$Message->{update_id}} = 1;
$Self->processMessage( Message => $Message, );
}
}
YAML::DumpFile('update_ids.yml', $Self->{UpdateIDs});
}
1;

View File

@ -1,6 +1,6 @@
#/usr/bin/perl
use v5.34;
use v5.32;
use strict;
use warnings;