diff options
author | Guillermo Ramos | 2020-03-07 13:31:33 +0100 |
---|---|---|
committer | Guillermo Ramos | 2020-03-07 13:31:33 +0100 |
commit | facd913e5418fde9823ea24e476a0b0cd5ef154c (patch) | |
tree | 434a816dafacc570d2c4136d5d15f4ef7b11078d /tgserver | |
parent | 90139dc853b1c4dae705814a3566cb9a98077e1c (diff) | |
download | tgutils-facd913e5418fde9823ea24e476a0b0cd5ef154c.tar.gz |
Better logging
Diffstat (limited to 'tgserver')
-rwxr-xr-x | tgserver | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -84,7 +84,7 @@ sub handle_photo { my $photos = $msg->{'photo'}; my $chat_id = $msg->{'chat'}{'id'}; my $photo = (sort { $b->{'width'} <=> $a->{'width'} } @$photos)[0]; - $logger->info(sprintf "%s: [Received photo %s (size=%d)]\n", + $logger->info(sprintf "%s: [Photo %s (size=%d)] -> 🤖\n", $chat_id, $photo->{'file_id'}, $photo->{'file_size'}); my $file = $api->get_file($photo->{'file_id'}); @@ -98,7 +98,7 @@ sub handle_text { my $msg = shift; my $text = $msg->{'text'}; my $chat_id = $msg->{'chat'}{'id'}; - $logger->info("$chat_id: '$text'\n"); + $logger->info("$chat_id: '$text' -> 🤖\n"); $ENV{'TGUTILS_TYPE'} = 'TEXT'; my $response = pipe_send($text, @ARGV); @@ -111,8 +111,10 @@ sub reply { my $type = ref $response eq 'HASH' ? $response->{'type'} : 'TEXT'; if ($type eq 'DOCUMENT') { my $caption = $response->{'caption'}; + $logger->info("🤖: [Document '$caption'] -> $chat_id\n"); $api->send_document($chat_id, decode_base64 $response->{'content'}, $caption); } elsif ($type eq 'TEXT' and $response) { + $logger->info("🤖: '$response' -> $chat_id\n"); $api->send_message($chat_id, $response); } else { $logger->debug("Empty response, skipping\n"); @@ -144,7 +146,6 @@ sub pipe_send { waitpid $pid, 0; # collect the child process chomp $response; - # $logger->debug("'$content' -> @ARGV -> '$response'\n"); return try { decode_json $response } catch { $response }; } |