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 #**************************************************************************/
25 use NDIRC::Dispatcher;
28 help => q(Show current calls),
30 }, class extends NDIRC::Command {
31 method execute($c,$msg) {
32 my $f = $c->model->prepare(q{
33 SELECT (c.landing_tick - tick()) AS eta
34 ,array_to_string(array_agg(i.shiptype),'/') AS shiptype
37 JOIN incomings i USING (call)
38 LEFT OUTER JOIN users dc ON dc.uid = c.dc
39 WHERE status = 'Open' AND (c.landing_tick - tick()) >= 7
40 GROUP BY call,c.landing_tick,dc.username
41 ORDER BY c.landing_tick;
45 while (my @row = $f->fetchrow()){
46 my $dc = $row[2] // '';
47 $calls .= " (Anti $row[1] ETA: $row[0] DC: $dc) |"
50 if ($msg ne 'q' || length $calls > 0){
51 $c->reply("Current calls: $calls");
57 help => q(List currently open raids),
59 }, class extends NDIRC::Command {
60 method execute($c,$msg) {
62 my $f = $c->model->prepare(q{
64 WHERE open AND not removed AND tick + waves - 7 > tick()
65 AND id IN (SELECT raid FROM raid_access WHERE gid = 'M')
69 while (my ($raid) = $f->fetchrow()){
70 $calls .= " https://nd.ruin.nu/raids/view/$raid |"
72 $calls = "No open future raids" if ($f->rows == 0);
79 help => q(syntax: .points [nick] | not everyone have access to check for others.),
80 }, class extends NDIRC::Command {
81 method execute($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");
104 help => q(syntax: .sms nick | % can be used for wildcards %arro% will match barrow),
106 }, class extends NDIRC::Command {
107 method execute($c,$msg) {
108 my ($nick) = $msg =~ /(\S+)/ or die 'ARGS';
109 my $f = $c->model->prepare(q{
110 SELECT username,COALESCE(sms,'nothing added'), call_if_needed, timezone, sms_note
111 ,to_char(NOW() AT TIME ZONE timezone,'HH24:MI') AS time
112 FROM users WHERE username ILIKE ?
114 if (my ($username,$sms, $call, $timezone, $note, $time) = $c->model->selectrow_array($f,undef,$nick)){
115 $call = $call ? 'Wake up if needed' : 'Do not wake up';
116 $c->reply("<b>$username</b> has sms <b>$sms</b>, $call, <b>$time</b> ($timezone), $note ");
118 $c->reply("No hit, maybe spelling mistake, or add % as wildcard");
124 help => q(Shows link to webbie and maybe more links later),
125 }, class extends NDIRC::Command {
126 method execute($c,$msg) {
127 $c->reply("https://nd.ruin.nu/");
132 help => q(syntax: .forum [nick] | not everyone have access to check for others.),
133 }, class extends NDIRC::Command {
134 method execute($c,$msg) {
138 if ($msg =~ /(\S+)/ && $c->check_user_roles('irc_forum_others')){
139 $user = $dbh->selectrow_hashref(q{
140 SELECT uid,username FROM users WHERE username ILIKE ?
143 $user = $dbh->selectrow_hashref(q{
144 SELECT uid,username FROM users WHERE uid = ?
148 my $unread = $dbh->selectrow_hashref(q{SELECT * FROM unread_posts($1)},undef,$user->{uid});
150 $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");