aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Ramos2020-03-07 13:37:12 +0100
committerGuillermo Ramos2020-03-07 13:37:12 +0100
commit6f347a1ff480a16a4010ef5b5a044bc55ff2c6f7 (patch)
tree9cc49ccebcceb5f21b1185b994ce28c56a4b8432
parentfacd913e5418fde9823ea24e476a0b0cd5ef154c (diff)
downloadtgutils-6f347a1ff480a16a4010ef5b5a044bc55ff2c6f7.tar.gz
Fix handling of non-message updates
-rw-r--r--lib/TgLib/Api.pm7
-rwxr-xr-xtgserver2
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");
}
}
}