X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Usermgm.pm;fp=Usermgm.pm;h=b24e3e11ab92e659c9e4cfdc156014bf77425fd1;hb=51ff7a3cc079e17dd0c11eb90a6b28a0ef51d409;hp=e751c566f9148363a994ac816f3f9c751209a925;hpb=5f7e87f30570220f44035831a51c881ee3ca34b7;p=NDIRC.git diff --git a/Usermgm.pm b/Usermgm.pm index e751c56..b24e3e1 100644 --- a/Usermgm.pm +++ b/Usermgm.pm @@ -25,64 +25,7 @@ require Exporter; our @ISA = qw/Exporter/; -our @EXPORT = qw/laston addPoints setHost setPNick getShips getFleet/; - -sub laston { - my ($msg, $command) = @_; - - if (officer() || ia()){ - my ($flag,$min); - my $f; - if(defined $msg && $msg =~ /^(\w)(?: (\d+)(?:\|(\d+)\|(\d+))?)?$/){ - $flag = $1; - $min = $2; - my $forum = $3; - my $claim = $4; - $min = 0 unless defined $min; - $f = $ND::DBH->prepare(q{SELECT username, last - ,COALESCE(lastforum::text,'?') AS lastforum - ,COALESCE(lastclaim::text,'?') AS lastclaim - FROM (SELECT username - ,date_part('day',now() - laston)::int AS last - ,date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid)) AS lastforum - ,date_part('day',now() - (SELECT max(timestamp) FROM raid_claims WHERE uid = u.uid)) AS lastclaim - FROM users u - NATURAL JOIN groupmembers - NATURAL JOIN groups - WHERE flag = $1 - ) a - WHERE COALESCE(last >= $2,TRUE) AND COALESCE(lastforum >= $3,TRUE) AND COALESCE(lastclaim >= $4,TRUE) - ORDER BY last DESC, lastforum DESC, lastclaim DESC - }); - $f->execute($flag,$min,$forum,$claim); - }elsif(defined $msg && $msg =~ /^(\S+)$/){ - $f = $ND::DBH->prepare(q{SELECT username - ,date_part('day',now() - laston)::int AS last - ,COALESCE(date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid))::text,'?') - AS lastforum - ,COALESCE(date_part('day',now() - (SELECT max(timestamp) FROM raid_claims WHERE uid = u.uid))::text,'?') AS lastclaim - FROM users u - WHERE username ILIKE $1 ORDER BY lower(username) - }); - $f->execute($1); - }else{ - $ND::server->command("notice $ND::nick syntax: .$command | lists users and the number of days since they were last seen (irc|forum|claim). If days is specified it will only list users with at least that amount of idle time."); - return; - } - - my $text; - my $i = 0; - while (my $user = $f->fetchrow_hashref){ - $user->{last} = '?' unless defined $user->{last}; - $text .= "$user->{username}($user->{last}|$user->{lastforum}|$user->{lastclaim}) "; - $i++; - } - $ND::server->command("msg $ND::target $ND::B$i$ND::B Users(days)".(defined $flag ? " with flag $ND::B$flag$ND::B" : "").": $text"); - }else{ - $ND::server->command("msg $ND::target Only officers are allowed to check that"); - } -} - +our @EXPORT = qw/addPoints setHost setPNick getShips getFleet/; sub getShips { my ($ship,$command) = @_;