$c->message("msg ".$c->channel, "<c03>$target << $mess</c>");
}
+sub defcall
+ : Help(syntax: .defcall [callid] | if a call id is given, then shiptypes and eta will be fetched from the database and added to the message)
+ : Type(def)
+ : ACL(irc_defcall)
+{
+ my ($self,$c,$msg) = @_;
+ my ($callnr,$mess) = $msg =~ /^(\d+)?(.*)$/ or die 'ARGS';
+ my $dbh = $c->model;
+
+ my $callinfo = "";
+ if ($callnr){
+ my $st = $dbh->prepare(q{
+SELECT covered
+ ,c.landing_tick - (SELECT value::integer FROM misc WHERE id = 'TICK') AS eta
+ ,concat(i.shiptype||'/') AS shiptype
+FROM calls c
+ JOIN incomings i ON i.call = c.id
+ LEFT OUTER JOIN users dc ON dc.uid = c.dc
+ JOIN users u ON u.uid = c.member
+WHERE c.id = ?
+GROUP BY c.id,c.landing_tick,c.covered
+ORDER BY c.landing_tick;
+ });
+ my $call = $dbh->selectrow_hashref($st,undef,$callnr);
+ unless (defined $call->{covered}){
+ $c->reply("No call with id: $callnr");
+ return;
+ }
+ chop($call->{shiptype});
+ $callinfo = "(Anti $call->{shiptype} ETA: $call->{eta})";
+ if($call->{covered}){
+ $c->reply("Call <b>$callnr</b> $callinfo is covered.");
+ return;
+ }
+ }
+ $c->message("notice $ND::memchan", "DEFENSE REQUIRED!! WAKE UP!!");
+ $c->message("msg $ND::memchan", "DEFENSE REQUIRED $mess $callinfo MSG "
+ .$c->nick." TO RESPOND");
+}
+
1;
our @ISA = qw/Exporter/;
our @EXPORT = qw/showCall setType takeCall covCall ignoreCall
- defcall setDefPrio setCalc getCalc/;
+ setDefPrio setCalc getCalc/;
sub showCall {
my ($msg,$command) = @_;
}
}
-sub defcall {
- my ($msg,$command) = @_;
- my ($mess,$nick,$callnr) = @_;
- if (defined $msg && $msg =~ /^(\d+)?(.*)$/){
- $callnr = $1;
- $mess = $2;
- }else{
- $ND::server->command("notice $ND::nick Usage: $command [callid] message | if a call id is given, then shiptypes and eta will be fetched from the database and added to the message");
- return;
- }
- if (dc()){
- my $call = "";
- if ($callnr){
- my $st = $ND::DBH->prepare(q{
- SELECT c.landing_tick - (SELECT value::integer FROM misc WHERE id = 'TICK'), concat(i.shiptype||'/') AS shiptype
- FROM calls c
- JOIN incomings i ON i.call = c.id
- LEFT OUTER JOIN users dc ON dc.uid = c.dc
- JOIN users u ON u.uid = c.member
- WHERE not covered AND c.id = ?
- GROUP BY c.id,c.landing_tick
- ORDER BY c.landing_tick;
- });
- if (my @row = $ND::DBH->selectrow_array($st,undef,$callnr)){
- chop($row[1]);
- $call = "(Anti $row[1] ETA: $row[0])"
- }
- }
- $ND::server->command("notice $ND::memchan DEFENSE REQUIRED!! WAKE UP!!");
- $ND::server->command("msg $ND::memchan DEFENSE REQUIRED $mess $call MSG $ND::nick TO RESPOND");
- }
-}
-
sub setCalc {
my ($msg,$command) = @_;
my ($id, $calc);
INSERT INTO roles VALUES('irc_setally');
INSERT INTO roles VALUES('irc_setchannel');
INSERT INTO roles VALUES('irc_anondef');
+INSERT INTO roles VALUES('irc_defcall');
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_setally');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_setchannel');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_anondef');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_defcall');
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_setally');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_setchannel');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_anondef');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_defcall');
INSERT INTO group_roles (gid,role) VALUES(4,'irc_points_others');
INSERT INTO group_roles (gid,role) VALUES(4,'irc_a');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_d');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_sethostile');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_anondef');
+INSERT INTO group_roles (gid,role) VALUES(6,'irc_defcall');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_scanreqs');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_anonscan');