diff options
author | Guillermo Ramos | 2020-02-24 18:22:58 +0100 |
---|---|---|
committer | Guillermo Ramos | 2020-02-24 18:22:58 +0100 |
commit | 0817cf1c12f8ad49435fa6cbc85fe76028a92325 (patch) | |
tree | 65f71bce16546cb05d7a5663a63dd71ad2feb8b0 /tgserver | |
parent | 267e948b52ce6a58d016b05e4616b8f1836e027f (diff) | |
download | tgutils-0817cf1c12f8ad49435fa6cbc85fe76028a92325.tar.gz |
Pass user/chat metadata from tgserver to child
Diffstat (limited to 'tgserver')
-rwxr-xr-x | tgserver | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -62,6 +62,9 @@ while (1) { $logger->debug(sprintf "Update %s", Dumper($update)); my $msg = $update->{'message'}; + $ENV{'TGUTILS_CHAT_ID'} = $msg->{'chat'}{'id'}; + $ENV{'TGUTILS_FROM_ID'} = $msg->{'from'}{'id'}; + $ENV{'TGUTILS_FROM_USERNAME'} = $msg->{'from'}{'username'}; if (exists $msg->{'photo'}) { handle_photo($msg); } else { @@ -99,11 +102,11 @@ sub handle_text { sub reply { my $chat_id = shift; my $response = shift; - my $type = ref $response eq 'HASH' ? $response->{'type'} : undef; + my $type = ref $response eq 'HASH' ? $response->{'type'} : 'TEXT'; if ($type eq 'DOCUMENT') { my $caption = $response->{'caption'}; $api->send_document($chat_id, decode_base64 $response->{'content'}, $caption); - } elsif ($response) { + } elsif ($type eq 'TEXT' and $response) { $api->send_message($chat_id, $response); } else { $logger->warn("Empty response, skipping\n"); |