]> ruin.nu Git - NDIRC.git/blobdiff - Misc.pm
r26 feudalism, late commit
[NDIRC.git] / Misc.pm
diff --git a/Misc.pm b/Misc.pm
index 37501f20d3944b5ef244e66ff24c1a0ca25dae15..f1bf8165d3e18a661feb3da0913b22947dd2bac2 100644 (file)
--- a/Misc.pm
+++ b/Misc.pm
@@ -23,7 +23,7 @@ require Exporter;
 
 our @ISA = qw/Exporter/;
 
-our @EXPORT = qw/valuecolor addCommand parseCommand/;
+our @EXPORT = qw/valuecolor addCommand parseCommand commands/;
 
 our %channels;
 our %commands;
@@ -34,6 +34,7 @@ $channels{'#ndef'} = ['all','member','scan'];
 $channels{'#nd-day'} = ['all','member'];
 $channels{'#ndintel'} = ['all','member'];
 $channels{'#nd-officers'} = ['all','member'];
+$channels{'#nd-ia'} = ['all','member'];
 $channels{'#ndawn'} = ['all'];
 $channels{'pm'} = ['pm'];
 
@@ -64,7 +65,7 @@ sub addCommand {
 
 sub parseCommand {
        my ($msg,$channel) = @_;
-       if ($msg =~ /^(\w+)(?: (.+))?$/){
+       if ($msg =~ /^(\S+)(?: (.+))?$/){
                my $c = $1;
                my $args = $2;
                my @k = keys %commands;
@@ -80,6 +81,19 @@ sub parseCommand {
        return 0;
 }
 
+sub commands {
+       my ($channel) = @_;
+       my @commands;
+       my $b = (exists $channels{lc $channel} ? $channels{lc $channel} : ['all']);
+       for my $c (sort keys %commands){
+               my $a = $commands{$c}->{acc};
+               if (intersect($a,$b) > 0){
+                       push @commands, $c;
+               }
+       }
+       return join ', ', @commands;
+}
+
 sub intersect {
        my ($a, $b) = @_;
        my %union;