aboutsummaryrefslogtreecommitdiff
path: root/tgrecv
diff options
context:
space:
mode:
authorGuillermo Ramos2019-06-25 12:57:22 +0200
committerGuillermo Ramos2019-06-25 13:03:53 +0200
commit077112d7242df2d1a26d90506b23045c6a6eb4ab (patch)
tree9509e135485c123a9f797347d0448e36eb46b84a /tgrecv
parent16cd42e6fbfbf6fff06fd50926ac374b771e3f97 (diff)
downloadtgutils-077112d7242df2d1a26d90506b23045c6a6eb4ab.tar.gz
TgLib::Cache does its own logging
Diffstat (limited to 'tgrecv')
-rwxr-xr-xtgrecv11
1 files changed, 3 insertions, 8 deletions
diff --git a/tgrecv b/tgrecv
index 01b2d9e..4670b63 100755
--- a/tgrecv
+++ b/tgrecv
@@ -18,9 +18,9 @@ use JSON qw<encode_json>;
use FindBin;
use lib "$FindBin::Bin/lib";
use TgLib qw<fetch_token>;
+require TgLib::Api;
require TgLib::Cache;
require TgLib::Logger;
-require TgLib::Api;
my $TOKEN;
my $OUTPUT;
@@ -46,8 +46,7 @@ $TOKEN ||= fetch_token() or
pod2usage(-message => "ERROR: Unable to get bot token ($!).\n",
-verbose => 99, -sections => "AUTHENTICATION");
-my $cache = TgLib::Cache->new;
-$logger->debug("Using cache: " . Dumper($cache));
+my $cache = TgLib::Cache->new($logger);
# Get offset from cache if --auto-offset is enabled (and no --offset provided)
if ($AUTO_OFFSET && ! $OFFSET) {
@@ -63,11 +62,7 @@ if ($OUTPUT) {
}
# Store new offset in cache (last update id +1)
-if ($AUTO_OFFSET && @$updates) {
- $cache->offset($updates->[-1]{'update_id'}+1);
- $logger->debug(sprintf "Cached offset %s (--auto-offset)\n", $cache->offset);
- $cache->save;
-}
+$cache->offset($updates->[-1]{'update_id'}+1) if ($AUTO_OFFSET && @$updates);
print $out encode_json($updates);