aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--calc.pl12
1 files 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);