]> ruin.nu Git - NDIRC.git/blobdiff - CommonStates.pm
Move things to bot specific class + some more shared code
[NDIRC.git] / CommonStates.pm
index 655bbba8442c6b6eedb18fffde017c6e8ce1bdc9..7da1c512788281d2d9954689e4a9a59824576e10 100644 (file)
@@ -23,6 +23,7 @@ use warnings;
 use feature ':5.10';
 
 use POE::Session;
+use NDIRC::Dispatcher;
 
 # We registered for all events, this will produce some debug info.
 sub _default {
@@ -63,6 +64,28 @@ sub _start {
        return;
 }
 
+sub sig_usr2 {
+       my $heap = $_[HEAP];
+
+       open COMMANDS, 'commands';
+       my @commands = split /\W+/, do { local $/; <COMMANDS> };
+       close COMMANDS;
+
+       my $disp = new NDIRC::Dispatcher;
+       $disp->load(@commands);
+
+       open CHANNELS, 'channels';
+       while (<CHANNELS>){
+               print;
+               my ($chan, @types) = split /\s+/;
+               say "$chan - @types";
+               $disp->add_channel($chan,\@types);
+       }
+       close CHANNELS;
+
+       $heap->{disp} = $disp;
+}
+
 sub sig_DIE {
        my( $kernel,$sig, $ex ) = @_[ KERNEL,ARG0, ARG1 ];
        say "DIED!!!!!!!!!!!!!!";