From e6924def82c4035f9ee520602654c5912184585f Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 9 Jan 2025 15:47:23 -0500 Subject: calc.pl: print help for !calc !hex !bin with no args --- calc.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/calc.pl b/calc.pl index 6e2ad4d..e042748 100644 --- a/calc.pl +++ b/calc.pl @@ -136,7 +136,12 @@ sub on_public_msg { $prefix = ""; } - if($msg !~ /^!(calc|bin|hex)\s+(.+)/) { + if($msg !~ /^!(calc|bin|hex)(?:\s+(.+))?/) { + return; + } + + if((!defined $2) || (lc $2 eq 'help') || (lc $2 eq '--help')) { + $server->command("msg $target $helpmsg"); return; } @@ -146,11 +151,6 @@ sub on_public_msg { my $input = lc $2; utf8::decode($input); - if($input =~ /^-*h(?:elp)?/) { - $server->command("msg $target $helpmsg"); - return; - } - expand_vars($input, $target); my ($err, $result) = calc($input, $hex, $bin); -- cgit v1.2.3