aboutsummaryrefslogtreecommitdiff
path: root/tgsend
diff options
context:
space:
mode:
authorGuillermo Ramos2019-06-21 12:18:48 +0200
committerGuillermo Ramos2019-06-21 12:18:48 +0200
commit07975e3f25a20d30238442ce3fc98dc2b24f14a9 (patch)
tree3c8b10073a7c54f6ee31fa8efdca9f5a4ae317a3 /tgsend
parent553c7574c6b4e5360d727353d690db5c1608035f (diff)
downloadtgutils-07975e3f25a20d30238442ce3fc98dc2b24f14a9.tar.gz
Update tgsend to follow tgrecv conventions
Diffstat (limited to 'tgsend')
-rwxr-xr-xtgsend13
1 files 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<encode_json>;
+
+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