1 #**************************************************************************
2 # Copyright (C) 2009 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDIRC::Commands::Members;
27 use MooseX::MethodAttributes;
30 : Help(Show current calls)
33 my ($self,$c,$msg) = @_;
34 my $f = $c->model->prepare(q{
35 SELECT (c.landing_tick - tick()) AS eta
36 ,array_to_string(array_agg(i.shiptype),'/') AS shiptype
39 JOIN incomings i USING (call)
40 LEFT OUTER JOIN users dc ON dc.uid = c.dc
41 WHERE status = 'Open' AND (c.landing_tick - tick()) >= 7
42 GROUP BY call,c.landing_tick,dc.username
43 ORDER BY c.landing_tick;
47 while (my @row = $f->fetchrow()){
48 my $dc = $row[2] // '';
49 $calls .= " (Anti $row[1] ETA: $row[0] DC: $dc) |"
52 if ($msg ne 'q' || length $calls > 0){
53 $c->reply("Current calls: $calls");
58 : Help(List currently open raids)
61 my ($self,$c,$msg) = @_;
63 my $f = $c->model->prepare(q{
65 WHERE open AND not removed AND tick + waves - 7 > tick()
66 AND id IN (SELECT raid FROM raid_access WHERE gid = 'M')
70 while (my ($raid) = $f->fetchrow()){
71 $calls .= " https://nd.ruin.nu/raids/view/$raid |"
73 $calls = "No open future raids" if ($f->rows == 0);
79 : Help(syntax: .points [nick] | not everyone have access to check for others.)
81 my ($self,$c,$msg) = @_;
84 if ($msg =~ /(\S+)/ && $c->check_user_roles(qw/irc_points_others/)){
86 $f = $c->model->prepare(q{
87 SELECT username, attack_points, defense_points, scan_points, humor_points
88 FROM users WHERE username ILIKE ? LIMIT 5
91 $f = $c->model->prepare(q{
92 SELECT username, attack_points, defense_points, scan_points, humor_points
93 FROM users WHERE uid = ?
97 while (my @row = $f->fetchrow()){
98 $c->reply("$row[0] has $row[1] Attack, $row[2] Defense, $row[3] Scan, $row[4] Humor points");
103 : Help(syntax: .sms nick | % can be used for wildcards %arro% will match barrow)
106 my ($self,$c,$msg) = @_;
107 my ($nick) = $msg =~ /(\S+)/ or die 'ARGS';
108 my $f = $c->model->prepare(q{
109 SELECT username,COALESCE(sms,'nothing added'), call_if_needed, timezone, sms_note
110 ,to_char(NOW() AT TIME ZONE timezone,'HH24:MI') AS time
111 FROM users WHERE username ILIKE ?
113 if (my ($username,$sms, $call, $timezone, $note, $time) = $c->model->selectrow_array($f,undef,$nick)){
114 $call = $call ? 'Wake up if needed' : 'Do not wake up';
115 $c->reply("<b>$username</b> has sms <b>$sms</b>, $call, <b>$time</b> ($timezone), $note ");
117 $c->reply("No hit, maybe spelling mistake, or add % as wildcard");
122 : Help(Shows link to webbie and maybe more links later)
124 my ($self,$c,$msg) = @_;
125 $c->reply("https://nd.ruin.nu/");
129 : Help(syntax: .forum [nick] | not everyone have access to check for others.)
131 my ($self,$c,$msg) = @_;
135 if ($msg =~ /(\S+)/ && $c->check_user_roles('irc_forum_others')){
136 $user = $dbh->selectrow_hashref(q{
137 SELECT uid,username FROM users WHERE username ILIKE ?
140 $user = $dbh->selectrow_hashref(q{
141 SELECT uid,username FROM users WHERE uid = ?
145 my $unread = $dbh->selectrow_hashref(q{SELECT * FROM unread_posts($1)},undef,$user->{uid});
147 $c->reply("$user->{username} has $unread->{new} posts since your last forum visit ($unread->{unread} unread posts in total) https://nd.ruin.nu/forum/allUnread");