X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FDef.pm;fp=Commands%2FDef.pm;h=74d0aa8dd85de111414620e2510cbb2d2483e983;hb=d40ac61049a226782476938747ce50f2da3d2d89;hp=7931033e2f6ddd1ba1cf1b04372dff5bb5fbaef0;hpb=565ece6e27fa54253934518cc8c69ecfac9487e4;p=NDIRC.git diff --git a/Commands/Def.pm b/Commands/Def.pm index 7931033..74d0aa8 100644 --- a/Commands/Def.pm +++ b/Commands/Def.pm @@ -39,5 +39,45 @@ sub anon $c->message("msg ".$c->channel, "$target << $mess"); } +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 $callnr $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;