$c->reply("<b>$count</b> Users with flag <b>$flag</b>: $users");
}
+sub laston
+ : Help(syntax: .laston flag [days] | 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. Days can also specify forum and claim with irc|forum|claim syntax)
+ : ACL(irc_laston)
+{
+ my ($self,$c,$msg) = @_;
+ my ($flag,$min,$forum,$claim) = $msg =~ /^(\w)(?: (\d+)(?:\|(\d+)\|(\d+))?)?$/
+ or die 'ARGS';
+ $min //= 0;
+
+ my $f = $c->model->prepare(q{
+SELECT username, COALESCE(last::text,'?') AS 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);
+
+ my $text;
+ my $i = 0;
+ while (my $user = $f->fetchrow_hashref){
+ $text .= "$user->{username}($user->{last}|$user->{lastforum}|$user->{lastclaim}) ";
+ $i++;
+ }
+ $c->reply("<b>$i</b> Users(days) with flag <b>$flag</b>: $text");
+}
+
+
+sub lastseen
+ : Help(syntax: .lastseen username | Shows the number of days since the user(s) last visited irc, forum and raids)
+ : ACL(irc_lastseen)
+{
+ my ($self,$c,$msg) = @_;
+ my ($username) = $msg =~ /^(\S+)$/ or die 'ARGS';
+
+ my $f = $c->model->prepare(q{
+SELECT username, COALESCE(date_part('day',now() - laston)::text,'?') 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($username);
+
+ my $text;
+ my $i = 0;
+ while (my $user = $f->fetchrow_hashref){
+ $text .= "$user->{username}($user->{last}|$user->{lastforum}|$user->{lastclaim}) ";
+ $i++;
+ }
+ $c->reply("<b>$i</b> Users(days): $text");
+}
+
1;
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 <flag [days]|nick> | 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) = @_;
INSERT INTO roles VALUES('irc_chattr');
INSERT INTO roles VALUES('irc_whois');
INSERT INTO roles VALUES('irc_flag');
+INSERT INTO roles VALUES('irc_laston');
+INSERT INTO roles VALUES('irc_lastseen');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_nick');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_intel');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_chattr');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_whois');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_flag');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_laston');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_lastseen');
INSERT INTO group_roles (gid,role) VALUES(2,'irc_gs');
INSERT INTO group_roles (gid,role) VALUES(2,'irc_scan');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_chattr');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_whois');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_flag');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_laston');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_lastseen');
INSERT INTO group_roles (gid,role) VALUES(4,'irc_points_others');
INSERT INTO group_roles (gid,role) VALUES(18,'irc_points_others');
INSERT INTO group_roles (gid,role) VALUES(18,'irc_whois');
INSERT INTO group_roles (gid,role) VALUES(18,'irc_flag');
+INSERT INTO group_roles (gid,role) VALUES(18,'irc_laston');
+INSERT INTO group_roles (gid,role) VALUES(18,'irc_lastseen');
INSERT INTO group_roles (gid,role) VALUES(19,'irc_p_intel');