Skip to content
Extraits de code Groupes Projets
Valider de8c2de8 rédigé par ElTata's avatar ElTata :ok_hand:
Parcourir les fichiers

auto_login hash only in Main

parent 344a9408
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -29,6 +29,7 @@ my $lastreg = 0; # holds the time of the last reg. cleared every second. ...@@ -29,6 +29,7 @@ my $lastreg = 0; # holds the time of the last reg. cleared every second.
my $lasttime_ref; my $lasttime_ref;
my %split; # holds nick!user@hosts for clients that have been netsplit my %split; # holds nick!user@hosts for clients that have been netsplit
my %onchan; # users on game channel my %onchan; # users on game channel
my %auto_login;
my $pausemode = 0; # pausemode on/off flag my $pausemode = 0; # pausemode on/off flag
my $silentmode = 0; # silent mode 0/1/2/3, see head of file my $silentmode = 0; # silent mode 0/1/2/3, see head of file
...@@ -37,7 +38,6 @@ my $primnick; ...@@ -37,7 +38,6 @@ my $primnick;
my $opts; my $opts;
my $rps; my $rps;
my $prev_online; my $prev_online;
my $auto_login;
=head1 FUNCTION init_pkg =head1 FUNCTION init_pkg
This function sets the references to This function sets the references to
options and players hashes. options and players hashes.
...@@ -45,10 +45,9 @@ my $auto_login; ...@@ -45,10 +45,9 @@ my $auto_login;
=item SCALAR (ref) - reference to the options hash =item SCALAR (ref) - reference to the options hash
=item SCALAR (ref) - reference to the players hash =item SCALAR (ref) - reference to the players hash
=item SCALAR (ref) - reference to the prev_online hash =item SCALAR (ref) - reference to the prev_online hash
=item SCALAR (ref) - reference to the auto_login hash
=cut =cut
sub init_pkg { sub init_pkg {
($opts, $rps, $lasttime_ref, $prev_online, $auto_login) = @_; ($opts, $rps, $lasttime_ref, $prev_online) = @_;
$primnick = $opts->{botnick}; # for regain or register checks $primnick = $opts->{botnick}; # for regain or register checks
Irpg::Irc::init_pkg(\$silentmode); Irpg::Irc::init_pkg(\$silentmode);
Irpg::Quest::init_pkg($opts, $rps); Irpg::Quest::init_pkg($opts, $rps);
...@@ -138,7 +137,6 @@ sub penalize { ...@@ -138,7 +137,6 @@ sub penalize {
my $pen_key; my $pen_key;
if ($type eq "quit") { if ($type eq "quit") {
$pen = int(20 * ($opts->{rppenstep}**$rps->{$username}{level})); $pen = int(20 * ($opts->{rppenstep}**$rps->{$username}{level}));
$rps->{$username}{online}=0;
$reason = undef; $reason = undef;
$pen_key = 'pen_quit'; $pen_key = 'pen_quit';
} }
...@@ -270,9 +268,6 @@ sub rpcheck { # check levels, update database ...@@ -270,9 +268,6 @@ sub rpcheck { # check levels, update database
foreach (qw(Quest Action Event)) { foreach (qw(Quest Action Event)) {
eval 'Irpg::'.$_.'::rpcheck($rpreport, $online'; eval 'Irpg::'.$_.'::rpcheck($rpreport, $online';
} }
# Irpg::Quest::rpcheck($rpreport, $online); ### QUEST BUSINESS ###
# Irpg::Action::rpcheck($rpreport, $online); ### FIGHT BUSINESS ###
# Irpg::Event::rpcheck($rpreport, $online); ### EVENT BUSINESS ###
### TOP PLAYERS REPORT ### ### TOP PLAYERS REPORT ###
if ($rpreport && $rpreport%36000==0) { # 10 hours if ($rpreport && $rpreport%36000==0) { # 10 hours
...@@ -373,10 +368,10 @@ sub parse { ...@@ -373,10 +368,10 @@ sub parse {
if (lc($arg[0]) eq 'ping') { Irpg::Irc::sts("PONG $arg[1]",1); } if (lc($arg[0]) eq 'ping') { Irpg::Irc::sts("PONG $arg[1]",1); }
elsif (lc($arg[0]) eq 'error') { elsif (lc($arg[0]) eq 'error') {
# uh oh, we've been disconnected from the server, possibly before we've # uh oh, we've been disconnected from the server, possibly before we've
# logged in the users in %$auto_login. so, we'll set those users' online # logged in the users in %auto_login. so, we'll set those users' online
# flags to 1, rewrite db, and attempt to reconnect (if that's wanted of # flags to 1, rewrite db, and attempt to reconnect (if that's wanted of
# us) # us)
$rps->{$_}{online}=1 for keys(%$auto_login); $rps->{$_}{online}=1 for keys(%auto_login);
writedb($rps); writedb($rps);
return; return;
} }
...@@ -386,7 +381,7 @@ sub parse { ...@@ -386,7 +381,7 @@ sub parse {
Irpg::Irc::sts("NICK $opts->{botnick}"); Irpg::Irc::sts("NICK $opts->{botnick}");
} }
elsif ($arg[1] eq 'join') { elsif ($arg[1] eq 'join') {
# %onchan holds time user joined channel. used for the advertisement ban # %onchan holds time user joined channel. used just to now who is there
$onchan{$usernick}=time() if ($opts->{botchan} eq substr($arg[2], 1)); $onchan{$usernick}=time() if ($opts->{botchan} eq substr($arg[2], 1));
if ($opts->{'detectsplits'} && exists($split{substr($arg[0],1)})) { if ($opts->{'detectsplits'} && exists($split{substr($arg[0],1)})) {
delete($split{substr($arg[0],1)}); delete($split{substr($arg[0],1)});
...@@ -408,7 +403,8 @@ sub parse { ...@@ -408,7 +403,8 @@ sub parse {
$split{substr($arg[0],1)}{account}=$username; $split{substr($arg[0],1)}{account}=$username;
} }
} }
else { elsif (defined($username)) {
$rps->{$username}{online}=0;
penalize($username,"quit"); penalize($username,"quit");
} }
delete($onchan{$usernick}); delete($onchan{$usernick});
...@@ -422,24 +418,26 @@ sub parse { ...@@ -422,24 +418,26 @@ sub parse {
# us who just lost it # us who just lost it
elsif ($usernick eq $primnick) { Irpg::Irc::sts("NICK $primnick",1); } elsif ($usernick eq $primnick) { Irpg::Irc::sts("NICK $primnick",1); }
else { else {
if (defined($username)) {
$rps->{$username}{nick} = substr($arg[2],1); $rps->{$username}{nick} = substr($arg[2],1);
substr($rps->{$username}{userhost},0,length($rps->{$username}{nick})) = substr($rps->{$username}{userhost},0,length($rps->{$username}{nick})) =
substr($arg[2],1); substr($arg[2],1);
penalize($username,"nick"); penalize($username,"nick");
}
if (exists($onchan{$usernick})) { if (exists($onchan{$usernick})) {
$onchan{substr($arg[2],1)} = delete($onchan{$usernick}); $onchan{substr($arg[2],1)} = delete($onchan{$usernick});
} }
} }
} }
elsif ($arg[1] eq 'part') { elsif ($arg[1] eq 'part') {
$rps->{$username}{online}=0; $rps->{$username}{online}=0 if (defined($username));
penalize($username,"part"); penalize($username,"part");
delete($onchan{$usernick}) if ($opts->{botchan} eq substr($arg[2], 1)); delete($onchan{$usernick}) if ($opts->{botchan} eq substr($arg[2], 1));
} }
elsif ($arg[1] eq 'kick') { elsif ($arg[1] eq 'kick') {
$usernick = $arg[3]; $usernick = $arg[3];
$username = finduser($usernick); $username = finduser($usernick);
$rps->{$usernick}{online}=0; $rps->{$username}{online}=0;
penalize($username,"kick"); penalize($username,"kick");
delete($onchan{$usernick}) if ($opts->{botchan} eq $arg[2]); delete($onchan{$usernick}) if ($opts->{botchan} eq $arg[2]);
} }
...@@ -460,20 +458,20 @@ sub parse { ...@@ -460,20 +458,20 @@ sub parse {
elsif ($arg[1] eq '315') { elsif ($arg[1] eq '315') {
# 315 is /WHO end. report who we automagically signed online iff it will # 315 is /WHO end. report who we automagically signed online iff it will
# print < 1k of text # print < 1k of text
if (keys(%$auto_login)) { if (keys(%auto_login)) {
# not a true measure of size, but easy # not a true measure of size, but easy
if (length("%$auto_login") < 1024 && $opts->{senduserlist}) { if (length("%auto_login") < 1024 && $opts->{senduserlist}) {
Irpg::Irc::chanmsg(scalar(keys(%$auto_login))." users matching ". Irpg::Irc::chanmsg(scalar(keys(%auto_login))." users matching ".
scalar(keys(%$prev_online))." hosts automatically ". scalar(keys(%$prev_online))." hosts automatically ".
"logged in; accounts: ".join(", ",keys(%$auto_login))); "logged in; accounts: ".join(", ",keys(%auto_login)));
} }
else { else {
Irpg::Irc::chanmsg(scalar(keys(%$auto_login))." users matching ". Irpg::Irc::chanmsg(scalar(keys(%auto_login))." users matching ".
scalar(keys(%$prev_online))." hosts automatically ". scalar(keys(%$prev_online))." hosts automatically ".
"logged in."); "logged in.");
} }
if ($opts->{voiceonlogin}) { if ($opts->{voiceonlogin}) {
my @vnicks = map { $rps->{$_}{nick} } keys(%$auto_login); my @vnicks = map { $rps->{$_}{nick} } keys(%auto_login);
while (@vnicks) { while (@vnicks) {
Irpg::Irc::sts("MODE $opts->{botchan} +". Irpg::Irc::sts("MODE $opts->{botchan} +".
('v' x $opts->{modesperline})." ". ('v' x $opts->{modesperline})." ".
...@@ -484,7 +482,7 @@ sub parse { ...@@ -484,7 +482,7 @@ sub parse {
} }
else { Irpg::Irc::chanmsg("0 users qualified for auto login."); } else { Irpg::Irc::chanmsg("0 users qualified for auto login."); }
undef($prev_online); undef($prev_online);
undef($auto_login); undef(%auto_login);
} }
elsif ($arg[1] eq '005') { elsif ($arg[1] eq '005') {
if ("@arg" =~ /MODES=(\d+)/) { $opts->{modesperline}=$1; } if ("@arg" =~ /MODES=(\d+)/) { $opts->{modesperline}=$1; }
...@@ -496,7 +494,7 @@ sub parse { ...@@ -496,7 +494,7 @@ sub parse {
$onchan{$arg[7]}=time() if ($opts->{botchan} eq $arg[3]); $onchan{$arg[7]}=time() if ($opts->{botchan} eq $arg[3]);
if (exists($prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]})) { if (exists($prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]})) {
$rps->{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}{online} = 1; $rps->{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}{online} = 1;
$auto_login->{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}=1; $auto_login{$prev_online->{$arg[7]."!".$arg[4]."\@".$arg[5]}}=1;
} }
} }
elsif ($arg[1] eq 'privmsg') { elsif ($arg[1] eq 'privmsg') {
......
...@@ -151,7 +151,7 @@ $prev_online = loaddb($rps, 1); ...@@ -151,7 +151,7 @@ $prev_online = loaddb($rps, 1);
irc_connect($opts); irc_connect($opts);
Irpg::Main::init_pkg($opts, $rps, \$lasttime, $prev_online, $auto_login); Irpg::Main::init_pkg($opts, $rps, \$lasttime, $prev_online);
#-----------------# #-----------------#
# MAIN LOOP # # MAIN LOOP #
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter