my $success = 0;
if ( $userHandle eq '_default' ) {
- &WARN("DCC CHAT: _default/guest not allowed.");
+ &WARN('DCC CHAT: _default/guest not allowed.');
return;
}
### TODO: prevent users without CRYPT chatting.
if ( !defined $crypto ) {
- &TODO("dcc close chat");
- &msg( $who, "nope, no guest logins allowed..." );
+ &TODO('dcc close chat');
+ &msg( $who, 'nope, no guest logins allowed...' );
return;
}
# stolen from eggdrop.
$conn->privmsg( $sock, "Connected to $ident" );
$conn->privmsg( $sock,
- "Commands start with '.' (like '.quit' or '.help')" );
+ 'Commands start with "." (like ".quit" or ".help")' );
$conn->privmsg( $sock,
- "Everything else goes out to the party line." );
+ 'Everything else goes out to the party line.' );
&dccStatus(2) unless ( exists $sched{'dccStatus'}{RUNNING} );
}
else {
- &status("DCC CHAT: incorrect pass; closing connection.");
+ &status('DCC CHAT: incorrect pass; closing connection.');
&DEBUG("chat: sock => '$sock'.");
### $sock->close();
delete $dcc{'CHAT'}{$nick};
- &FIXME("chat: after closing sock.");
+ &FIXME('chat: after closing sock.');
### BUG: close seizes bot. why?
}
return unless ( defined $retval );
return if ( $retval eq $noreply );
- $conn->privmsg( $dcc{'CHAT'}{$who}, "Invalid command." );
+ $conn->privmsg( $dcc{'CHAT'}{$who}, 'Invalid command.' );
}
else { # dcc chat arena.
&DEBUG("on_ison: x1 = '$x1', x2 => '$x2'");
}
-sub on_endofmotd {
+sub on_connected {
$conn = shift(@_);
# update IRCStats.
# first time run.
if ( !exists $users{_default} ) {
- &status("!!! First time run... adding _default user.");
+ &status('!!! First time run... adding _default user.');
$users{_default}{FLAGS} = 'amrt';
- $users{_default}{HOSTS}{"*!*@*"} = 1;
+ $users{_default}{HOSTS}{'*!*@*'} = 1;
}
if ( scalar keys %users < 2 ) {
- &status( "!" x 40 );
- &status(
-"!!! Ok. Now type '/msg $ident PASS <pass>' to get master access through DCC CHAT."
- );
- &status( "!" x 40 );
+ &status( '!' x 40 );
+ &status("!!! Ok. Now type '/msg $ident PASS <pass>' to get master access through DCC CHAT.");
+ &status( '!' x 40 );
}
-
# end of first time run.
if ( &IsChanConf('Wingate') > 0 ) {
if ( &IsParam('ircUMode') ) {
&VERB( "Attempting change of user modes to $param{'ircUMode'}.", 2 );
if ( $param{'ircUMode'} !~ /^[-+]/ ) {
- &WARN("ircUMode had no +- prefix; adding +");
- $param{'ircUMode'} = "+" . $param{'ircUMode'};
+ &WARN('ircUMode had no +- prefix; adding +');
+ $param{'ircUMode'} = '+' . $param{'ircUMode'};
}
&rawout("MODE $ident $param{'ircUMode'}");
# Q, as on quakenet.org.
if ( &IsParam('Q_pass') ) {
- &status("Authing to Q...");
- &rawout(
-"PRIVMSG Q\@CServe.quakenet.org :AUTH $param{'Q_user'} $param{'Q_pass'}"
- );
+ &status('Authing to Q...');
+ &rawout("PRIVMSG Q\@CServe.quakenet.org :AUTH $param{'Q_user'} $param{'Q_pass'}");
}
- &status("End of motd. Now lets join some channels...");
+ &status("$ident End of motd. Now lets join some channels...");
#&joinNextChan();
}
# pity Net::IRC doesn't store nuh. Here's a hack :)
if ( !exists $nuh{ lc $nick } ) {
$conn->whois($nick);
- $nuh{$nick} = "GETTING-NOW"; # trying.
+ $nuh{$nick} = 'GETTING-NOW'; # trying.
}
- $type ||= "???";
+ $type ||= '???';
if ( $type eq 'SEND' ) { # GET for us.
# incoming DCC SEND. we're receiving a file.
# DCC CHAT close on fork exit workaround.
if ( $bot_pid != $$ ) {
- &WARN("run-away fork; exiting.");
+ &WARN('run-away fork; exiting.');
&delForked($forker);
}
&status("on_dcc_open type=$type nick=$nick sock=$sock");
$msgType = 'chat';
- $type ||= "???";
+ $type ||= '???';
### BUG: who is set to bot's nick?
# lets do it.
# very cheap hack.
### TODO: run ScheduleThis inside on_dcc_open_chat recursively
### 1,3,5,10 seconds then fail.
- if ( $nuh{$nick} eq "GETTING-NOW" ) {
+ if ( $nuh{$nick} eq 'GETTING-NOW' ) {
&ScheduleThis( 3 / 60, 'on_dcc_open_chat', $nick, $sock );
}
else {
}
elsif ( $type eq 'SEND' ) {
- &status("Starting DCC receive.");
+ &status('Starting DCC receive.');
foreach ( $event->args ) {
&status(" => '$_'.");
}
sub on_dcc_open_chat {
my ( undef, $nick, $sock ) = @_;
- if ( $nuh{$nick} eq "GETTING-NOW" ) {
+ if ( $nuh{$nick} eq 'GETTING-NOW' ) {
&FIXME("getting nuh for $nick failed.");
return;
}
if ( !exists $users{$userHandle}{HOSTS} ) {
&performStrictReply(
- "you have no hosts defined in my user file; rejecting.");
+ 'you have no hosts defined in my user file; rejecting.');
$sock->close();
return;
}
# TODO: don't make DCC CHAT established in the first place.
if ( $userHandle eq '_default' ) {
- &dccsay( $nick, "_default/guest not allowed" );
+ &dccsay( $nick, '_default/guest not allowed' );
$sock->close();
return;
}
if ( defined $crypto ) {
- &status( "DCC CHAT: going to use " . $nick . "'s crypt." );
- &dccsay( $nick, "Enter your password." );
+ &status( "DCC CHAT: going to use $nick\'s crypt." );
+ &dccsay( $nick, 'Enter your password.' );
}
else {
&clearIRCVars();
if ( !defined $conn ) {
- &WARN("on_disconnect: self is undefined! WTF");
- &DEBUG("running function irc... lets hope this works.");
+ &WARN('on_disconnect: self is undefined! WTF');
+ &DEBUG('running function irc... lets hope this works.');
&irc();
return;
}
- &WARN("scheduling call ircCheck() in 60s");
+ &WARN('scheduling call ircCheck() in 60s');
&clearIRCVars();
&ScheduleThis( 1, 'ircCheck' );
}
# sync time should be done in on_endofwho like in BitchX
if ( exists $cache{jointime}{$chan} ) {
my $delta_time =
- sprintf( "%.03f", &timedelta( $cache{jointime}{$chan} ) );
+ sprintf( '%.03f', &timedelta( $cache{jointime}{$chan} ) );
$delta_time = 0 if ( $delta_time <= 0 );
if ( $delta_time > 100 ) {
&WARN("endofnames: delta_time > 100 ($delta_time)");
&chanServCheck($chan);
- # schedule used to solve ircu (OPN) "target too fast" problems.
- $conn->schedule( 5, sub { &joinNextChan(); } );
+ # FIXME: scheduler is b0rken! flood join for now
+ # schedule used to solve ircu (OPN) 'target too fast' problems.
+ #$conn->schedule( 5, sub { &joinNextChan(); } );
+ &joinNextChan();
}
sub on_init {
my $nick = $event->nick;
if ( $nick =~ /^\Q$ident\E$/ ) {
- &DEBUG("on_invite: self invite.");
+ &DEBUG('on_invite: self invite.');
return;
}
if ( !&IsParam('noSHM')
&& time() > ( $sched{shmFlush}{TIME} || time() ) + 3600 )
{
- &DEBUG("looks like schedulers died somewhere... restarting...");
+ &DEBUG('looks like schedulers died somewhere... restarting...');
&setupSchedulers();
}
$netsplit = 1;
if ( !scalar keys %netsplit ) {
- &DEBUG("on_join: netsplit hash is now empty!");
+ &DEBUG('on_join: netsplit hash is now empty!');
undef %netsplitservers;
&netsplitCheck(); # any point in running this?
&chanlimitCheck();
}
if ( $netsplit and !exists $cache{netsplit} ) {
- &VERB( "on_join: ok.... re-running chanlimitCheck in 60.", 2 );
+ &VERB('on_join: ok.... re-running chanlimitCheck in 60.', 2);
$conn->schedule(
60,
sub {
);
$channels{$chan}{''}{$who}++;
- $nuh = $who . "!" . $user . "\@" . $host;
+ $nuh = $who . '!' . $user . '@' . $host;
$nuh{ lc $who } = $nuh unless ( exists $nuh{ lc $who } );
### on-join bans.
&DEBUG(" bans_on_chan($chan) => $_");
}
- my $reason = "no reason";
+ my $reason = 'no reason';
foreach ( $chan, '*' ) {
next unless ( exists $bans{$_} );
next unless ( exists $bans{$_}{$ban} );
### ROOTWARN:
&rootWarn( $who, $user, $host, $chan )
if ( &IsChanConf('RootWarn') > 0
- && $user =~ /^~?r(oo|ew|00)t$/i );
+ && $user eq 'root' );
+ #&& $user =~ /^~?r(oo|ew|00)t$/i );
### emit a message based on who just joined
&onjoin( $who, $user, $host, $chan ) if ( &IsChanConf('OnJoin') > 0 );
( $user, $host ) = split( /\@/, $event->userhost );
$uh = $event->userhost();
- $nuh = $nick . "!" . $uh;
+ $nuh = $nick . '!' . $uh;
$msgtime = time();
$h = $host;
my $nick = $event->nick();
my $chan = ( $event->to )[0];
my $args = ( $event->args )[0];
+ my $mynick = $conn->nick();
if ( $nick =~ /^NickServ$/i ) { # nickserv.
- &status("NickServ: <== '$args'");
+ &status("NickServ: $mynick <== '$args'");
my $check = 0;
$check++ if ( $args =~ /^This nickname is registered/i );
$check++ if ( $args =~ /nickname.*owned/i );
if ($check) {
- &status("nickserv told us to register; doing it.");
+ &status("nickserv told $mynick to register; doing it.");
if ( &IsParam('nickServ_pass') ) {
- &status("NickServ: ==> Identifying.");
+ &status("NickServ: ==> Identifying as $mynick.");
&rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
return;
}
else {
- &status("We can't tell nickserv a passwd ;(");
+ &status("$mynick can't tell nickserv a passwd ;(");
}
}
foreach ( &ChanConfList('chanServ_ops') ) {
next unless &chanServCheck($_);
next if ($done);
- &DEBUG(
- "nickserv activated or restarted; doing chanserv check.");
+ &DEBUG('nickserv activated or restarted; doing chanserv check.');
$done++;
}
my $chan = ( $event->to )[0];
my $nick = $event->nick;
- &status("!!! other called.");
+ &status('!!! other called.');
&status("!!! $event->args");
}
my $nick = $event->nick;
my $t = ( $event->args )[1];
if ( !defined $t ) {
- &WARN("on_ping_reply: t == undefined.");
+ &WARN('on_ping_reply: t == undefined.');
return;
}
my $nick = $event->nick;
$who = $nick;
$uh = $event->userhost();
- $nuh = $nick . "!" . $uh;
+ $nuh = $nick . '!' . $uh;
$msgType = 'public';
# TODO: move this out of hookMsg to here?
# rare case should this happen - catch it just in case.
if ( $bot_pid != $$ ) {
- &ERROR("run-away fork; exiting.");
+ &ERROR('run-away fork; exiting.');
&delForked($forker);
}
# cache it.
my $time = time();
if ( !$cache{ircTextCounters} ) {
- &DEBUG("caching ircTextCounters for first time.");
+ &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';
- # better to do "counter=counter+1".
+ # better to do 'counter=counter+1'.
# but that will avoid time check.
my ( $v, $t ) = &sqlSelect(
'stats',
- "counter,time",
+ 'counter,time',
{
nick => $who,
type => $x,
if ( ( defined $t && $time - $t > 60 ) or ( !defined $t ) ) {
&sqlSet(
'stats',
- { 'nick' => $who },
{
- type => $x,
- channel => $c,
+ 'nick' => $who,
+ 'type' => $x,
+ 'channel' => $c,
+ },
+ {
time => $time,
counter => $v,
}
next unless ( exists $channels{$_}{'l'} );
&DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
- $conn->mode( $_, "-l" );
+ $conn->mode( $_, '-l' );
}
$netsplit{ lc $nick } = time();
if ( !exists $netsplitservers{$1}{$2} ) {
&status("netsplit detected between $1 and $2 at ["
. scalar(gmtime)
- . "]" );
+ . ']' );
$netsplitservers{$1}{$2} = time();
}
}
# revert to main nick. Note that Net::IRC only knows our main nick
if ( $nick eq $conn->nick() ) {
&status("nickchange: own nick \"$nick\" became free; changing.");
- &nick($mynick);
+ &nick($nick);
}
}
my $timestr;
if ( time() - $time > 60 * 60 * 24 ) {
- $timestr = "at " . gmtime $time;
+ $timestr = 'at ' . gmtime $time;
}
else {
- $timestr = &Time2String( time() - $time ) . " ago";
+ $timestr = &Time2String( time() - $time ) . ' ago';
}
&status(">>> set by $b_cyan$setby$ob $timestr");
}
push( @vernick, $nick );
+ &DEBUG("on_crversion: Got '$ver' from $nick");
+
if ( $ver =~ /bitchx/i ) {
$ver{bitchx}{$nick} = $ver;
}
- elsif ( $ver =~ /xc\!|xchat/i ) {
+ elsif ( $ver =~ /infobot/i ) {
+ $ver{infobot}{$nick} = $ver;
+
+ }
+ elsif ( $ver =~ /(xc\!|xchat)/i ) {
$ver{xchat}{$nick} = $ver;
}
$ver{irssi}{$nick} = $ver;
}
- elsif ( $ver =~ /epic|(Third Eye)/i ) {
+ elsif ( $ver =~ /(epic|Third Eye)/i ) {
$ver{epic}{$nick} = $ver;
}
- elsif ( $ver =~ /ircII|PhoEniX/i ) {
+ elsif ( $ver =~ /(ircII|PhoEniX)/i ) {
$ver{ircII}{$nick} = $ver;
}
elsif ( $ver =~ /mirc/i ) {
-
- # &DEBUG("verstats: mirc: $nick => '$ver'.");
+ # Apparently, mIRC gets the reply as "VERSION " and doesnt like the
+ # space, so mirc matching is considered bugged.
$ver{mirc}{$nick} = $ver;
- # ok... then we get to the lesser known/used clients.
}
elsif ( $ver =~ /ircle/i ) {
$ver{ircle}{$nick} = $ver;
$conn = shift(@_);
my ($event) = @_;
my @args = $event->args;
- my $str = $args[5] . "!" . $args[2] . "\@" . $args[3];
+ my $str = $args[5] . '!' . $args[2] . '@' . $args[3];
if ( $cache{on_who_Hack} ) {
$cache{nuhInfo}{ lc $args[5] }{Nick} = $args[5];
}
if ( $args[5] =~ /^nickserv$/i and !$nickserv ) {
- &DEBUG("ok... we did a who for nickserv.");
+ &DEBUG('ok... we did a who for nickserv.');
&rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
}
- $nuh{ lc $args[5] } = $args[5] . "!" . $args[2] . "\@" . $args[3];
+ $nuh{ lc $args[5] } = $args[5] . '!' . $args[2] . '@' . $args[3];
}
sub on_whois {
my ($event) = @_;
my @args = $event->args;
- $nuh{ lc $args[1] } = $args[1] . "!" . $args[2] . "\@" . $args[3];
+ $nuh{ lc $args[1] } = $args[1] . '!' . $args[2] . '@' . $args[3];
}
sub on_whoischannels {
my ($event) = @_;
my @args = $event->args;
- &status(">>> chanfull/$b_blue$args[1]$ob");
-
+ &status(">>> chanfull/$b_blue$args[1]$ob, removing autojoin");
+ delete $chanconf{$chan}{autojoin};
&joinNextChan();
}
my ($event) = @_;
my @args = $event->args;
- &status(">>> inviteonly/$b_cyan$args[1]$ob");
-
+ &status(">>> inviteonly/$b_cyan$args[1]$ob, removing autojoin");
+ delete $chanconf{$chan}{autojoin};
&joinNextChan();
}