All pastes #236703 Raw Edit

Stuff

public text v1 · immutable
·published 2006-11-04 00:10 UTC
rendered paste body
package Modules::fedcount;

sub new {
   main::add_handler('event join', 'fedplus');
   main::add_handler('event part', 'fedminus');
   my $self = {};
   bless $self;
   return $self;
}

sub del {
   main::del_handler('event join', 'fedplus');
   main::del_handler('event part', 'fedminus');
}

sub fedplus {
  my($self, $remotenick, $hostmask, $channel) = @_;
  open(FEDL, "$main::options{config}{datadir}/fed.list");
  while(<FEDL>) {
    chop;
    my $fed = quotemeta $_;
    if($remotenick !~ /$fed/i) {
      next;
    }else{
      main::irc_sayfh($channel, "!(ALERT)! THE FED COUNT OF $channel HAS INCREASED BY [1] !(ALERT)!");
    }
  }
  close(FEDL);
}

sub fedminus {
  my($self, $remotenick, $hostmask, $channel) = @_;
  open(FEDL, "$main::options{config}{datadir}/fed.list");
  while(<FEDL>) {
    chop;
    my $fed = quotemeta $_;
    if($remotenick !~ /$fed/i) {
      next;
    }else{
      main::irc_sayfh($channel, "!(ALERT)! THE FED COUNT OF $channel HAS DECREASED BY [1] !(ALERT)!");
    }
    $fed = undef;
  }
  close(FEDL);
}

1;