diff --git a/Irpg/Main.pm b/Irpg/Main.pm index 10442e770f1b3c4518d32bd284b0ac5f32b264ee..6d5dcda6380e0bdea78bff02c1b70b86c4aabae3 100644 --- a/Irpg/Main.pm +++ b/Irpg/Main.pm @@ -19,7 +19,7 @@ use Irpg::Event; use Irpg::Admin; use Irpg::Users; use Exporter qw(import); -our @EXPORT = qw(&init_hashes &rpcheck &parse &penalize &ha); +our @EXPORT = qw(&init_hashes &rpcheck &parse &penalize &ha &finduser); our @EXPORT_OK = qw($pausemode $silentmode $primnick $lastreg); @@ -100,9 +100,10 @@ sub reloaddb { =cut sub finduser { my $nick = shift; + my $offline = shift; return undef if !defined($nick); for my $user (keys(%$rps)) { - next unless $rps->{$user}{online}; + next unless ($rps->{$user}{online} || $offline); if ($rps->{$user}{nick} eq $nick) { return $user; } } return undef; diff --git a/Irpg/Users.pm b/Irpg/Users.pm index e1c7a510df5a1e8cd0ac24f45dbaaa284bdc7e8b..dd3d71507b3a6e78188ea59fc7e3532f1ab26725 100644 --- a/Irpg/Users.pm +++ b/Irpg/Users.pm @@ -206,32 +206,28 @@ sub logout { sub status { return unless ($opts->{statuscmd}); my ($userhost, $usernick, $username, $source, @arg) = @_; - if (!defined($username)) { - Irpg::Irc::privmsg("You are not logged in.", $usernick); - } + #if (!defined($username)) { + # Irpg::Irc::privmsg("You are not logged in.", $usernick); + #} # argument is optional - elsif ($arg[0] && !exists($rps->{$arg[0]})) { - Irpg::Irc::privmsg("No such user.",$usernick); - } - elsif ($arg[0]) { # optional 'user' argument - Irpg::Irc::privmsg("$arg[0]: Level $rps->{$arg[0]}{level} ". - "$rps->{$arg[0]}{class}; Status: O". - ($rps->{$arg[0]}{online}?"n":"ff")."line; ". - "TTL: ".duration($rps->{$arg[0]}{next})."; ". - "Idled: ".duration($rps->{$arg[0]}{idled}). - "; Item sum: ".itemsum($arg[0]). - "; More details at ".$opts->{playerurl}.$arg[0] - ,$usernick); + my $asked = $arg[0]; + $asked = $username unless ($asked); + my $asked_found = Irpg::Main::finduser($asked) unless (exists($rps->{$asked})); + $asked = $asked_found if ($asked_found); + $asked = Irpg::Main::finduser($asked, 1) unless ($asked_found); + + if (!$asked) { + Irpg::Irc::privmsg("No matching user found.",$source); } else { # no argument, look up this user - Irpg::Irc::privmsg("$username: Level $rps->{$username}{level} ". - "$rps->{$username}{class}; Status: O". - ($rps->{$username}{online}?"n":"ff")."line; ". - "TTL: ".duration($rps->{$username}{next})."; ". - "Idled: ".duration($rps->{$username}{idled})."; ". - "Item sum: ".itemsum($username). - "; More details at ".$opts->{playerurl}.$username - ,$usernick); + Irpg::Irc::privmsg("$asked: Level $rps->{$asked}{level} ". + "$rps->{$asked}{class}; Status: O". + ($rps->{$asked}{online}?"n":"ff")."line; ". + "TTL: ".duration($rps->{$asked}{next})."; ". + "Idled: ".duration($rps->{$asked}{idled})."; ". + "Item sum: ".itemsum($asked). + "; More details at ".$opts->{playerurl}.$asked + ,$source); } } diff --git a/Irpg/Utils.pm b/Irpg/Utils.pm index 458bb261433d2f0d8e502238220105a56a5ef8d2..d60e529e7861afd59e77aaa385a64c0af10da5ae 100644 --- a/Irpg/Utils.pm +++ b/Irpg/Utils.pm @@ -33,6 +33,8 @@ my $debug; my $verbose; my $debugfile; +my $_configfile = '.irpg.conf'; + =head1 FUNCTION set_debug_status This function sets the variables used by the debug function. =over @@ -179,13 +181,13 @@ sub daemonize { =cut sub readconfig { my %opts; - if (! -e ".irpg.conf") { - debug("Error: Cannot find .irpg.conf. Copy it to this directory, ". + if (! -e $_configfile) { + debug("Error: Cannot find $_configfile. Copy it to this directory, ". "please.",\%opts,1); } else { - open(CONF,"<.irpg.conf") or do { - debug("Failed to open config file .irpg.conf: $!",\%opts,1); + open(CONF,"<$_configfile") or do { + debug("Failed to open config file $_configfile: $!",\%opts,1); }; my($line,$key,$val); while ($line=<CONF>) { @@ -198,7 +200,7 @@ sub readconfig { if (lc($val) eq "on" || lc($val) eq "yes") { $val = 1; } elsif (lc($val) eq "off" || lc($val) eq "no") { $val = 0; } if ($key eq "die") { - die("Please edit the file .irpg.conf to setup your bot's ". + die("Please edit the file $_configfile to setup your bot's ". "options. Also, read the README file if you haven't ". "yet.\n"); }