]> ruin.nu Git - NDIRC.git/blobdiff - Bot.pm
getanti command
[NDIRC.git] / Bot.pm
diff --git a/Bot.pm b/Bot.pm
index 1200424a94cfba04219b6415cc1dfd685ce222e2..9a289f0695a55a39866706d9f199a5bd491ecb26 100644 (file)
--- a/Bot.pm
+++ b/Bot.pm
@@ -24,6 +24,7 @@ use feature ':5.10';
 
 use Moose;
 
+use POE::Component::IRC::Common qw/irc_to_utf8/;
 use POE::Session;
 use POE::Component::IRC::Plugin::Logger;
 use POE::Component::IRC::Plugin::BotTraffic;
@@ -32,6 +33,7 @@ use POE::Component::IRC::Plugin::AutoJoin;
 use POE::Component::IRC::Plugin::NickReclaim;
 
 use NDIRC::Dispatcher;
+use NDIRC::Context;
 
 use IO::File;
 
@@ -79,11 +81,12 @@ sub _start {
                Sort_by_date => 1,
                Strip_color => 1,
                Strip_formatting => 1,
+               Notices => 1,
        ));
 
        $heap->{connector} = POE::Component::IRC::Plugin::Connector->new(
-               servers => ['irc.netgamers.org', 'underworld.no.eu.netgamers.org'
-                       ,'firefly.no.eu.netgamers.org', 'underworld.ca.us.netgamers.org' ]
+               servers => [['irc.netgamers.org'], ['underworld.no.eu.netgamers.org']
+                       ,['firefly.no.eu.netgamers.org'], ['underworld.ca.us.netgamers.org'] ]
        );
        $irc->plugin_add( 'Connector' => $heap->{connector} );
 
@@ -112,9 +115,66 @@ sub sig_usr1 {
        $kernel->yield( 'refresh' );
 }
 
+sub clear_constraint {
+       my $tc = shift;
+
+       while (1) {
+               if (ref $tc eq 'MooseX::Meta::TypeConstraint::Structured'){
+                       for my $t (@{$tc->{type_constraints}}){
+                               clear_constraint($t);
+                       }
+
+               }
+               if (ref $tc eq 'Moose::Meta::TypeConstraint::Parameterized'){
+                       clear_constraint($tc->{type_parameter});
+               }
+               last if ref $tc eq 'HASH';
+               last if ref $tc eq '';
+               if (defined $tc->{_type_constraint}){
+                       $tc = $tc->{_type_constraint};
+               }elsif(defined $tc->{__type_constraint}){
+                       $tc = $tc->{__type_constraint};
+               }else{
+                       last;
+               }
+       }
+}
+
+sub clear_metains {
+       my $ins = shift;
+
+       for my $a (@{$ins->{attributes}}){
+               for my $m (@{$a->{associated_methods}}){
+                       $m->{body} = undef;
+               }
+               clear_constraint($a->{isa});
+       }
+}
+
+sub clear_cycles {
+       my $c = shift;
+
+       for my $m (values %{$c->meta->{methods}}){
+               clear_constraint($m->{type_constraint});
+
+               my $ps = $m->{parsed_signature};
+               for my $p (@{$ps->{_positional_params}->{params}}){
+                       clear_metains($p->{__MOP__}->{_meta_instance});
+               }
+
+               $m->{body} = undef;
+       }
+       clear_metains($c->meta->{_meta_instance});
+}
+
+
 sub sig_usr2 {
        my $self = shift @_;
 
+       for my $c (values %{$self->disp->commands}){
+               clear_cycles($c);
+       }
+
        $self->disp($self->_build_disp);
 }
 
@@ -196,16 +256,18 @@ sub irc_001 {
 }
 
 sub irc_invite {
-       my ($self,$sender, $who, $channel) = @_[OBJECT,SENDER, HEAP, ARG0 .. ARG1];
+       my ($self,$sender, $who, $channel) = @_[OBJECT,SENDER, ARG0 .. ARG1];
        my $irc = $sender->get_heap();
 
        $irc->yield( join => $_ ) for grep /^$channel$/i, keys %{$self->disp->channels}
 }
 
 sub irc_public {
+       $_[ARG2] = irc_to_utf8 $_[ARG2];
 }
 
 sub irc_msg {
+       $_[ARG2] = irc_to_utf8 $_[ARG2];
 }
 
 sub  refresh {