-
-
-sub sig_usr2 {
- my $heap = $_[HEAP];
-
- my $disp = new NDIRC::Dispatcher;
-
- $disp->load(qw/Basic SMS Channel Def Intel Members PA Quotes Usermgm/);
-
- 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 irc_public {
- my ($sender, $heap, $who, $where, $msg) = @_[SENDER, HEAP, ARG0 .. ARG2];
- my ($nick,$username,$address) = ( split /[!@]/, $who );
- my $channel = $where->[0];
-
- my $irc = $sender->get_heap();
-
- #$irc->yield(privmsg => $channel, "Authed? " . $irc->is_nick_authed($nick));
-
- if ($msg =~ /^(\S+): (.+)$/ && $heap->{disp}->has_command('anon',$channel)){
- my $_ = $1;
- my $text = $2;
- unless ($irc->is_channel_member($channel,$1) || /(Constructing|Researching)/){
- $msg = ".anon $_ $text";
- }
-
- }
- if (parseCommand($msg,$irc,$nick,$address,$channel,$heap->{disp},DB())){
- #Command parsed and run successfully
- }
-}
-
-
-sub irc_msg {
- my ($sender, $heap, $who, $where, $msg) = @_[SENDER, HEAP, ARG0 .. ARG2];
- my ($nick,$username,$address) = ( split /[!@]/, $who );
- my $irc = $sender->get_heap();
-
- if (parseCommand($msg,$irc,$nick,$address,'pm',$heap->{disp},DB())){
- #Command parsed and run successfully
- }
-}
-
-sub irc_join {
- my ($sender, $heap, $who, $channel) = @_[SENDER, HEAP, ARG0 .. ARG1];
- my ($nick,$username,$address) = ( split /[!@]/, $who );
- my $irc = $sender->get_heap();
-
- if($heap->{disp}->has_command('voice',$channel)){
- my $dbh = DB();
- my $flags = $dbh->prepare_cached(q{
-SELECT DISTINCT flag
-FROM users u
- JOIN groupmembers g USING (uid)
- JOIN channel_group_flags gf USING (gid)
-WHERE u.hostmask = $1 AND channel = $2 AND flag IN ('o','v');
- });
- $flags->execute($address, $channel);
- my $mode = '';
- my @who;
- while (my ($flag) = $flags->fetchrow()){
- $mode .= $flag;
- push @who, $nick;
- }
- say "$mode - @who";
- $irc->yield(mode => $channel, $mode, @who) if $mode;
- }
-}
-
-sub refresh {
- my ($kernel,$heap) = @_[KERNEL,HEAP];
- print 'Time: ' . time() . ' Lag: ' . $heap->{connector}->lag() . "\n";
- $kernel->delay( refresh => 60 );
- return;
-}