]> ruin.nu Git - NDIRC.git/commitdiff
Added commands sub
authorMichael Andreen <harv@ruin.nu>
Fri, 7 Sep 2007 06:54:14 +0000 (08:54 +0200)
committerMichael Andreen <harv@ruin.nu>
Fri, 7 Sep 2007 06:54:14 +0000 (08:54 +0200)
Misc.pm

diff --git a/Misc.pm b/Misc.pm
index 37501f20d3944b5ef244e66ff24c1a0ca25dae15..b3a1b315bcd108125b427d1ec83d06ab447d8981 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;
@@ -80,6 +80,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;