X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Dispatcher.pm;h=7c4b0a60618c10eaa56180bf1dcd9729102c38b9;hb=0d63bf9da52cdfe2c9d8850b690032ff539b6398;hp=16dae1de9d4e2e637ed03a2c727710db74ad87ad;hpb=102b930d967569cef7f3be81cb56b5c76e98dffa;p=NDIRC.git diff --git a/Dispatcher.pm b/Dispatcher.pm index 16dae1d..7c4b0a6 100644 --- a/Dispatcher.pm +++ b/Dispatcher.pm @@ -30,17 +30,23 @@ use NDIRC::Command; has commands => ( - is => 'rw', + is => 'ro', isa => 'HashRef[Object]', default => sub{ {} }, ); has channels => ( - is => 'rw', + is => 'ro', isa => 'HashRef[ArrayRef[Str]]', default => sub{ {} }, ); +has targets => ( + is => 'ro', + isa => 'HashRef[Str]', + default => sub{ {} }, +); + sub load { my $self = shift; @@ -54,7 +60,7 @@ sub load { warn "couldn't do $file: $!" if $!; warn "couldn't run $file" unless $return; }else { - print "Loading $class\n"; + say "\nLoading $class"; $self->load_class($class); } @@ -67,8 +73,8 @@ sub load_class { my @subs = eval "$class->meta->get_method_list"; for my $c (@subs){ my $attr = eval "$class->meta->get_method('$c')->attributes"; - if ($attr){ - print "Command: $c"; + if (@$attr){ + print "Command: $c "; my %c = (channels => ['all']); my @aliases; for (@{$attr}){ @@ -122,6 +128,11 @@ sub has_command { return 0; } +sub set_target { + my ($self,$label,$target) = @_; + $self->targets->{$label} = $target; +} + sub run_command { my ($self,$c,$command,$args) = @_;