From 07975e3f25a20d30238442ce3fc98dc2b24f14a9 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Fri, 21 Jun 2019 12:18:48 +0200 Subject: Update tgsend to follow tgrecv conventions --- tgsend | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tgsend b/tgsend index 3303da0..ad874b6 100755 --- a/tgsend +++ b/tgsend @@ -17,6 +17,11 @@ use Data::Dumper; use HTTP::Request; use JSON qw; + +my $HOME = $ENV{'HOME'}; +my $CONFIG_HOME = $ENV{'XDG_CONFIG_HOME'} || "$HOME/.config"; +my $CACHE_HOME = $ENV{'XDG_CACHE_HOME'} || "$HOME/.cache"; + my $TOKEN; my $PRETEND; my $VERBOSE = 0; @@ -58,12 +63,12 @@ sub send_message { my $req = HTTP::Request->new("POST", $URI, ["Content-Type", "application/json"], $content); if ($VERBOSE || $PRETEND) { - print "Sending to $chat_id:\n====\n$TEXT\n====\n"; - print "Request:\n", Dumper($req) if $VERBOSE > 1; + print STDERR "Sending to $chat_id:\n====\n$TEXT\n====\n"; + print STDERR "Request:\n", Dumper($req), "\n" if $VERBOSE > 1; } unless ($PRETEND) { my $resp = $ua->request($req); - print "Response:\n", Dumper($resp) if $VERBOSE > 1; + print STDERR "Response:\n", Dumper($resp), "\n" if $VERBOSE > 1; if ($resp->is_error()) { die $resp->message; } @@ -87,8 +92,8 @@ tgsend [options] [chatid1 chatid2 ...] =head1 OPTIONS - --token | -t Bot token (see AUTHENTICATION) --pretend | -p Do not actually do anything + --token | -t Bot token (see AUTHENTICATION) --version Show version --verbose | -v Show more information (combine with -h to see full manual) --help | -h Show this message -- cgit v1.2.3