summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <jonas@atreju.jones.dk>2012-10-11 16:14:25 +0200
committerJonas Smedegaard <jonas@atreju.jones.dk>2012-10-11 16:14:25 +0200
commit846ec44317a52f347bfe0beb5a0d8af572631ffb (patch)
tree21c51f274a444d11ac4b1cb9ee536cbf4b0f6d6c
parent6eef9c02d29390a769671ccf83cbddfe4d44567e (diff)
Use getopt more consistently (also at too few arguments.
-rwxr-xr-xsmsbot11
1 files changed, 3 insertions, 8 deletions
diff --git a/smsbot b/smsbot
index 6cf5995..f90ebc2 100755
--- a/smsbot
+++ b/smsbot
@@ -31,7 +31,9 @@ my ($opt, $usage) = describe_options(
[ 'help', "print usage message and exit"],
);
-print($usage->text), exit if $opt->help;
+print($usage->text), exit if ($opt->help or @ARGV < 3);
+
+my ($jid, $pw, $inputfile, $room) = @ARGV;
# TODO: support overriding full URL
# TODO: use URI module to construct URL
@@ -60,13 +62,6 @@ sub answer_to {
binmode STDOUT, ":utf8";
-my ($jid, $pw, $inputfile, $room) = @ARGV;
-
-unless (@ARGV >= 3) {
- warn "usage: talkbot <jid> <password> <talkfile> [<conference room jid>]\n";
- exit;
-}
-
read_messages ($inputfile);
my $j = AnyEvent->condvar;