# NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997
#
-if (&IsParam("useStrict")) { use strict; }
-
# GENERIC. TO COPY.
sub on_generic {
my ($self, $event) = @_;
### TODO: prevent users without CRYPT chatting.
if (!defined $crypto) {
- &DEBUG("todo: dcc close chat");
+ &TODO("dcc close chat");
&msg($who, "nope, no guest logins allowed...");
return;
}
&DEBUG("chat: sock => '$sock'.");
### $sock->close();
delete $dcc{'CHAT'}{$nick};
- &DEBUG("chat: after closing sock. FIXME");
+ &FIXME("chat: after closing sock.");
### BUG: close seizes bot. why?
}
return 'DCC CHAT MESSAGE';
}
+# is there isoff? how do we know if someone signs off?
+sub on_ison {
+ my ($self, $event) = @_;
+ my $x1 = ($event->args)[0];
+ my $x2 = ($event->args)[1];
+ $x2 =~ s/\s$//;
+
+# &nick( $param{'ircNick'} );
+
+ &DEBUG("on_ison: x1 = '$x1', x2 => '$x2'");
+}
+
sub on_endofmotd {
my ($self) = @_;
# update IRCStats.
- $ident ||= $param{'ircNick'}; # hack.
+ $ident = $param{'ircNick'};
$ircstats{'ConnectTime'} = time();
$ircstats{'ConnectCount'}++;
- $ircstats{'OffTime'} += time() - $ircstats{'DisconnectTime'}
- if (defined $ircstats{'DisconnectTime'});
+ if (defined $ircstats{'DisconnectTime'}) {
+ $ircstats{'OffTime'} += time() - $ircstats{'DisconnectTime'};
+ }
# first time run.
if (!exists $users{_default}) {
# ok, we're free to do whatever we want now. go for it!
$running = 1;
- $conn->ison($ident);
- &DEBUG("adding self to NOTIFY/ISON.");
+ # add ourself to notify.
+ $conn->ison( $param{'ircNick'} );
# Q, as on quakenet.org.
if (&IsParam("Q_pass")) {
my(undef, $nick, $sock) = @_;
if ($nuh{$nick} eq "GETTING-NOW") {
- &DEBUG("getting nuh for $nick failed. FIXME.");
+ &FIXME("getting nuh for $nick failed.");
return;
}
my $crypto = $users{$userHandle}{PASS};
$dcc{'CHAT'}{$nick} = $sock;
- # todo: don't make DCC CHAT established in the first place.
+ # TODO: don't make DCC CHAT established in the first place.
if ($userHandle eq "_default") {
&dccsay($nick, "_default/guest not allowed");
$sock->close();
# clear any variables on reconnection.
$nickserv = 0;
- &DEBUG("on_disconnect: 1");
&clearIRCVars();
- &DEBUG("on_disconnect: 2");
if (!defined $self) {
&WARN("on_disconnect: self is undefined! WTF");
my $i = scalar(keys %{ $channels{$chan} });
my $j = $cache{maxpeeps}{$chan} || 0;
- if (time() > ($sched{shmFlush}{TIME} || time()) + 3600) {
+ if (!&IsParam("noSHM") && time() > ($sched{shmFlush}{TIME} || time()) + 3600) {
&DEBUG("looks like schedulers died somewhere... restarting...");
&setupSchedulers();
}
$chanstats{$chan}{'Join'}++;
- $userstats{lc $who}{'Join'} = time() if (&IsChanConf("seenStats"));
+ $userstats{lc $who}{'Join'} = time() if (&IsChanConf("seenStats") > 0);
$cache{maxpeeps}{$chan} = $i if ($i > $j);
&joinfloodCheck($who, $chan, $event->userhost);
### ROOTWARN:
&rootWarn($who,$user,$host,$chan) if (
&IsChanConf("rootWarn") &&
- $user =~ /^r(oo|ew|00)t$/i
+ $user =~ /^~?r(oo|ew|00)t$/i
);
### NEWS:
}
}
- ### chanlimit check.
-# &chanLimitVerify($chan);
+ ### botmail:
+ if (&IsChanConf("botmail")) {
+ &botmail::check(lc $who);
+ }
### wingate:
&wingateCheck();
my $nick = $event->nick();
$chan = ($event->to)[0];
- $args[0] =~ s/\s$//;
+ # last element is empty... so nuke it.
+ pop @args while ($args[$#args] eq "");
if ($nick eq $chan) { # UMODE
&status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
sub on_nick {
my ($self, $event) = @_;
- my $nick = $event->nick();
+ my $nick = $event->nick();
my $newnick = ($event->args)[0];
if (exists $netsplit{lc $newnick}) {
$channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
}
}
- # todo: do %flood* aswell.
+ # TODO: do %flood* aswell.
&delUserInfo($nick, keys %channels);
$nuh{lc $newnick} = $nuh{lc $nick};
sub on_nick_taken {
my ($self) = @_;
- my $nick = $self->nick;
- my $newnick = $nick."-";
+ my $nick = $self->nick();
+ my $newnick = $nick.int(rand 10);
+
+ if ($nick eq $ident) {
+ &DEBUG("on_nick_tane: nick eq ident... wtf?");
+ return;
+ }
+
+ &DEBUG("on_nick_taken: ident => $ident");
&status("nick taken ($nick); preparing nick change.");
sub on_notice {
my ($self, $event) = @_;
+ #$conn = $self; <- ugly hack or elegant solution?
my $nick = $event->nick();
my $chan = ($event->to)[0];
my $args = ($event->args)[0];
$chanstats{$chan}{'Part'}++;
&delUserInfo($nick,$chan);
if ($nick eq $ident) {
- &DEBUG("on_part: ok, I left $chan... clearChanVars...");
&clearChanVars($chan);
}
- if (!&IsNickInAnyChan($nick) and &IsChanConf("seenStats")) {
+ if (!&IsNickInAnyChan($nick) and &IsChanConf("seenStats") > 0) {
delete $userstats{lc $nick};
}
$uh = $event->userhost();
$nuh = $nick."!".$uh;
$msgType = "public";
- # todo: move this out of hookMsg to here?
+ # TODO: move this out of hookMsg to here?
($user,$host) = split(/\@/, $uh);
$h = $host;
$msgtime = time();
$lastWho{$chan} = $nick;
### TODO: use $nick or lc $nick?
- if (&IsChanConf("seenStats")) {
+ if (&IsChanConf("seenStats") > 0) {
$userstats{lc $nick}{'Count'}++;
$userstats{lc $nick}{'Time'} = time();
}
- # would this slow things down?
- if ($_ = &getChanConf("ircTextCounters")) {
- my $time = time();
-
- foreach (split /[\s]+/) {
- my $x = $_;
-
- # either full word or ends with a space, etc...
- next unless ($msg =~ /^\Q$x\E[\$\s!.]/i);
+ # cache it.
+ my $time = time();
+ if (!$cache{ircTextCounters}) {
+ &DEBUG("caching ircTextCounters for first time.");
+ my @str = split(/\s+/, &getChanConf("ircTextCounters"));
+ for (@str) { $_ = quotemeta($_); }
+ $cache{ircTextCounters} = join('|', @str);
+ }
- &VERB("textcounters: $x matched for $who",2);
- my $c = $chan || "PRIVATE";
+ my $str = $cache{ircTextCounters};
+ if ($str && $msg =~ /^($str)[\s!\.]?$/i) {
+ my $x = $1;
- my ($v,$t) = &dbGet("stats", "counter,time",
- "nick=". &dbQuote($who)
- ." AND type=".&dbQuote($x)
- ." AND channel=".&dbQuote($c)
- );
- $v++;
+ &VERB("textcounters: $x matched for $who",2);
+ my $c = $chan || "PRIVATE";
- # don't allow ppl to cheat the stats :-)
- next unless ($time - $t > 10);
+ # better to do "counter=counter+1".
+ # but that will avoid time check.
+ my ($v,$t) = &sqlSelect("stats", "counter,time", {
+ nick => $who,
+ type => $x,
+ channel => $c,
+ } );
+ $v++;
- my %hash = (
+ # don't allow ppl to cheat the stats :-)
+ if (defined $t && $time - $t > 60) {
+ &sqlReplace("stats", {
nick => $who,
type => $x,
channel => $c,
-
time => $time,
counter => $v,
- );
-
-
- &dbReplace("stats", "nick", %hash);
- # does not work, atleast with old mysql!!! :(
-# &dbReplace("stats", (nick => $who, type => $x, -counter => "counter+1") );
+ } );
}
}
$netsplit{lc $nick} = time();
if (!exists $netsplitservers{$1}{$2}) {
- &status("netsplit detected between $1 and $2 at [".scalar(localtime)."]");
+ &status("netsplit detected between $1 and $2 at [".scalar(gmtime)."]");
$netsplitservers{$1}{$2} = time();
}
}
# well.. it's good but weird that this has happened - lets just
# be quiet about it.
}
- delete $userstats{lc $nick} if (&IsChanConf("seenStats"));
+ delete $userstats{lc $nick} if (&IsChanConf("seenStats") > 0);
delete $chanstats{lc $nick};
###
# does this work?
if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
&status("nickchange: own nickname became free; changing.");
- &nick($param{'ircNick'});
+ &nick( $param{'ircNick'} );
}
}
my $timestr;
if (time() - $time > 60*60*24) {
- $timestr = "at ". localtime $time;
+ $timestr = "at ". gmtime $time;
} else {
$timestr = &Time2String(time() - $time) ." ago";
}