X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Delling.pm;fp=Delling.pm;h=26e97842a453872cc5e18fe00a054c09b3ddcfd9;hb=139b1bb64717ec8be8d97d2d9efc6caaf9e800ca;hp=0000000000000000000000000000000000000000;hpb=e8c94cdebefdc428ea92fde6db63f18d3e8399b2;p=NDIRC.git diff --git a/Delling.pm b/Delling.pm new file mode 100644 index 0000000..26e9784 --- /dev/null +++ b/Delling.pm @@ -0,0 +1,98 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ +package NDIRC::Delling; + +use strict; +use warnings; +use feature ':5.10'; + +use POE::Session; +use NDIRC::Misc; +use ND::DB; + +my $DBH = DB(); +my $TICK = $DBH->selectrow_array('SELECT tick()'); + +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; +} + +1;