From: Michael Andreen Date: Fri, 7 Sep 2007 06:54:14 +0000 (+0200) Subject: Added commands sub X-Git-Url: https://ruin.nu/git/?p=NDIRC.git;a=commitdiff_plain;h=d24378e9a1f63f504a60eff9795a7846483d855c Added commands sub --- diff --git a/Misc.pm b/Misc.pm index 37501f2..b3a1b31 100644 --- 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;