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 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib') 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; } } -- cgit v1.2.3