aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-01-09 15:47:23 -0500
committerB. Watson <urchlay@slackware.uk>2025-01-09 15:47:23 -0500
commite6924def82c4035f9ee520602654c5912184585f (patch)
tree3b328e86f3f2cc07441c4bbaf9471b7d0b5c47f1
parent14a3ab25c9d4d404e544f3b44a4ad5e3bedf5ae6 (diff)
downloadstupid-irssi-tricks-e6924def82c4035f9ee520602654c5912184585f.tar.gz
calc.pl: print help for !calc !hex !bin with no args
-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);