From 6f347a1ff480a16a4010ef5b5a044bc55ff2c6f7 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Sat, 7 Mar 2020 13:37:12 +0100 Subject: Fix handling of non-message updates --- lib/TgLib/Api.pm | 7 ++----- tgserver | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/TgLib/Api.pm b/lib/TgLib/Api.pm index 51d4c31..02e8b83 100644 --- a/lib/TgLib/Api.pm +++ b/lib/TgLib/Api.pm @@ -37,11 +37,8 @@ sub get_updates { } else { my $updates = decode_json($resp->content)->{'result'}; # TODO why does `decode_json` not do this work? - map { utf8::encode($_->{'message'}{'text'}) if exists $_->{'message'}{'text'} } @$updates; - $logger->debug(sprintf "Received %d updates from chats %s\n", - scalar(@$updates), - join(", ", map { $_->{'message'}{'chat'}{'id'} } @$updates)) - if @$updates; + map { utf8::encode($_->{'message'}{'text'}) if exists $_->{'message'} && exists $_->{'message'}{'text'} } @$updates; + $logger->debug(sprintf "Received %d updates\n", scalar(@$updates)) if @$updates; return $updates; } } diff --git a/tgserver b/tgserver index 55855ce..4de8fdb 100755 --- a/tgserver +++ b/tgserver @@ -75,6 +75,8 @@ while (1) { my $msg = $update->{'edited_message'}; # TODO $logger->info("Received edited message, ignoring..."); + } else { + $logger->warn("Received unknown update type (ignoring): $update\n"); } } } -- cgit v1.2.3