+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Access;
-use strict;
-use warnings;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/member officer dc bc hc scanner intel masterop masterinvite/;
-
-sub member {
- return groupmember("HM");
-};
-sub officer {
- return groupmember("HO");
-};
-sub dc {
- return groupmember("HD");
-};
-sub bc {
- return groupmember("HB");
-};
-sub hc {
- return groupmember("H");
-};
-sub scanner {
- return groupmember("HS");
-};
-sub intel {
- return groupmember("HI");
-};
-
-sub masterop {
- return groupmember("HO");
-};
-sub masterinvite {
- return groupmember("H");
-};
-
-sub groupmember {
- my ($groups) = @_;
- $groups = join ",", map {"'$_'"} split //, $groups;
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users NATURAL JOIN groupmembers NATURAL JOIN groups WHERE flag IN ('T',$groups) AND lower(hostmask) = ?") or print $ND::DBH->errstr;
- $f->execute(lc($ND::address));
- my $user = $f->fetchrow_hashref;
- return $user;
-};
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Channel;
-use strict;
-use warnings;
-use ND::IRC::Access;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/op deop voice devoice/;
-
-sub op {
- my ($nick) = @_;
- umode("op","op",$nick);
-}
-
-sub deop {
- my ($nick) = @_;
- umode("deop","op",$nick);
-}
-
-sub voice {
- my ($nick) = @_;
- umode("voice","voice",$nick);
-}
-
-sub devoice {
- my ($nick) = @_;
- umode("devoice","voice",$nick);
-}
-
-sub umode {
- my ($command,$access,$nick) = @_;
- my $where = "";
- unless (defined $nick){
- $nick = $ND::nick;
- $where = "OR f.name = 'auto_$access'";
- }
-
- my $mode = qq{
-SELECT DISTINCT c.name FROM users u
- JOIN groupmembers g ON g.uid = u.uid
- JOIN channel_group_flags gf ON g.gid = gf.group
- JOIN channels c ON gf.channel = c.id
- JOIN channel_flags f ON f.id = gf.flag
-WHERE u.hostmask ILIKE ? AND c.name = ? AND (f.name = '$access' $where);
- };
- if (masterop()){
- $mode = 1;
- }else{
- ($mode) = $ND::DBH->selectrow_array($mode,undef,$ND::address,$ND::target);
- }
- if ($mode){
- $ND::server->command("$command $ND::target $nick");
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Def;
-use strict;
-use warnings;
-use ND::DB;
-use ND::Include;
-use ND::IRC::Access;
-use ND::IRC::Misc;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/showCall setType takeCall covCall ignoreCall defcall anon setDefPrio/;
-
-sub showCall {
- my ($id) = @_;
- DB();
- if (dc()){
- my $f = $ND::DBH->prepare(<<SQL
- SELECT i.id,coords(p.x,p.y,p.z), p.planet_status,p.nick, p.alliance, p.race,i.eta,i.amount,i.fleet,i.shiptype,p.relationship,c.landing_tick - (SELECT value::integer FROM misc WHERE id = 'TICK')
- FROM incomings i
- JOIN calls c ON i.call = c.id
- JOIN current_planet_stats p ON i.sender = p.id
- WHERE i.call = ?
- ORDER BY p.x,p.y,p.z;
-SQL
-);
- $f->execute($id);
- while (my @row = $f->fetchrow()){
- @row = map (valuecolor(0),@row);
- $ND::server->command("msg $ND::target (CALL $id) $row[0]: $row[1], $row[3] ($row[2]), $row[4] ($row[10]), $row[5], ETA: $row[11](/$row[6]), Amount: $row[7], $row[8], Type: $row[9]");
- }
- }
-}
-
-sub setType {
- my ($type,$id,$x,$y,$z) = @_;
- DB();
- if (my $user = dc()){
- my $fleet;
- my $query = qq{
- SELECT i.id,call,shiptype, coords(x,y,z),c.landing_tick - tick() FROM incomings i
- JOIN current_planet_stats p ON i.sender = p.id
- JOIN calls c ON i.call = c.id
- };
- if (defined $x && $x eq 'call'){
- $fleet = $ND::DBH->prepare(qq{
- $query
- WHERE i.call = ?
- });
- $fleet->execute($id);
- }elsif (defined $x){
- $fleet = $ND::DBH->prepare(qq{
- $query
- WHERE i.call = ? AND p.id = planetid(?,?,?,0)
- });
- $fleet->execute($id,$x,$y,$z);
- }else{
- $fleet = $ND::DBH->prepare(qq{
- $query
- WHERE i.id = ?
- });
- $fleet->execute($id);
- }
- while (my ($id,$call,$oldtype,$coords,$tick) = $fleet->fetchrow()){
- if($ND::DBH->do(q{UPDATE incomings SET shiptype = ? WHERE id = ?},undef,$type,$id) == 1){
- log_message $user->{uid}, "DC set fleet: $id to: $type";
- $ND::server->command("msg $ND::target Set fleet from $coords on call $call to $type (previously $oldtype)");
- if ($tick < 0 && not (defined $x && $x eq 'call')){
- $ND::server->command("msg $ND::target This call is old, did you use the call id, instead of inc id by accident? You can use .settypeall callid to set the type on all incs in a call.");
- }
- }
- }
- }
-}
-sub takeCall {
- my ($id) = @_;
- DB();
- if (dc()){
- if ($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?) WHERE id = ?}
- ,undef,$ND::address,$id) == 1){
- $ND::server->command("msg $ND::target Updated the DC for call $id");
- }
- }
-}
-
-sub covCall {
- my ($id) = @_;
- DB();
- if (dc()){
- if($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?), covered = TRUE, open = FALSE WHERE id = ?}
- ,undef,$ND::address,$id) == 1){
- $ND::server->command("msg $ND::target Marked call $id as covered");
- }
- }
-}
-
-sub ignoreCall {
- my ($id) = @_;
- DB();
- if (dc()){
- if($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?), covered = FALSE, open = FALSE WHERE id = ?}
- ,undef,$ND::address,$id) == 1){
- $ND::server->command("msg $ND::target Marked call $id as ignored");
- }
- }
-}
-
-sub defcall {
- my ($msg,$nick,$callnr) = @_;
- DB();
- 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, p.x
- 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
- JOIN current_planet_stats p ON u.planet = p.id
- WHERE not covered AND c.id = ?
- GROUP BY c.id,c.landing_tick,p.x
- 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] Cluster: $row[2])"
- }
- }
- $ND::server->command("notice $ND::memchan DEFENSE REQUIRED!! WAKE UP!!");
- $ND::server->command("msg $ND::memchan DEFENSE REQUIRED $msg $call MSG $nick TO RESPOND");
- }
-}
-
-sub anon {
- my ($target,$msg) = @_;
- if (dc()){
- $ND::server->command("msg $target ".chr(2).$msg);
- $ND::server->command("msg $ND::target ".chr(3)."3$1 << $2");
- }
-}
-
-
-sub setDefPrio {
- my ($min,$max) = @_;
- DB();
- if (hc()){
- $ND::DBH->begin_work;
- my $update = $ND::DBH->prepare('UPDATE misc SET value = ? :: int WHERE id = ?');
- $update->execute($min,'DEFMIN');
- $update->execute($max,'DEFMAX');
- if ($ND::DBH->commit){
- $ND::server->command("msg $ND::target min def prio set to $min and max set to $max");
- }else{
- $ND::server->command("msg $ND::target something went wrong");
- }
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Intel;
-use strict;
-use warnings;
-use ND::DB;
-use ND::IRC::Access;
-use ND::IRC::Misc;
-use ND::Include;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/checkIntel setHostile findNick setNick setAlly setChannel/;
-
-sub checkIntel {
- my ($x,$y,$z) = @_;
- DB();
- if (officer() || dc()){
- my $f = $ND::DBH->prepare("SELECT nick,alliance,coords(x,y,z),ruler,planet,hit_us,race,score,size,value,planet_status,relationship,channel FROM current_planet_stats WHERE x = ? AND y = ? and z = ?");
- $f->execute($x,$y,$z);
- while (my @row = $f->fetchrow()){
- @row = map (valuecolor(1),@row);
- $ND::server->command("notice $ND::target $row[2] - $row[3] OF $row[4], Alliance=$row[1] ($row[11]), Nick=$row[0] ($row[10]), Channel=$row[12] Hostile Count=$row[5], Race=$row[6], Score=$row[7], Size=$row[8], Value=$row[9] ");
- }
- }else{
- $ND::server->command("msg $ND::target Only officers are allowed to check that");
- }
-}
-
-sub setHostile {
- my ($x,$y,$z) = @_;
- DB();
- if(my $user = dc()){
- my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)});
- my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
- my $rv = $ND::DBH->do(q{UPDATE planets SET planet_status = 'Hostile' WHERE id = $1},undef,$id);
- if ($rv == 1){
- $ND::server->command("msg $ND::target $x:$y:$z is now marked s hostile");
- intel_log $user->{uid},$id,"Set planet_status to: 'Hostile'";
- }
- }
-}
-
-sub findNick {
- my ($nick) = @_;
- DB();
- if(officer()){
- my $f = $ND::DBH->prepare("SELECT coords(x,y,z), ruler,planet,nick FROM current_planet_stats WHERE nick ILIKE ? ORDER BY x,y,z");
- $f->execute($nick);
- $ND::server->command("notice $ND::target No such nick") if $f->rows == 0;
- while (my @row = $f->fetchrow()){
- $ND::server->command("notice $ND::target $row[0] $row[1] OF $row[2] is $row[3]");
- }
- }
-}
-sub setNick {
- my ($x,$y,$z,$nick) = @_;
- DB();
- if (my $user = officer){
- my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)});
- my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
- if ($ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2'
- ,undef,$nick,$id)){
- $ND::server->command("msg $ND::target $x:$y:$z has been updated");
- intel_log $user->{uid},$id,"Set nick to: $nick";
- }
- }
-}
-
-sub setAlly {
- my ($x,$y,$z,$ally) = @_;
- DB();
- if (my $user = officer){
- my $aid;
- if ($ally ne 'unknown'){
- ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally);
- }
- if ($ally){
- my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)});
- my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
- if($id && $ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2'
- ,undef,$aid,$id)){
- $ND::server->command("msg $ND::target Setting $x:$y:$z as $ally");
- intel_log $user->{uid},$id,"Set alliance_id to: $aid ($ally)";
- }else{
- $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
- }
- }else{
- $ND::server->command("msg $ND::target Couldn't find such an alliance");
- }
- }
-}
-
-sub setChannel {
- my ($x,$y,$z,$channel) = @_;
- DB();
- if (my $user = officer()){
- my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)});
- my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
- if ($ND::DBH->do('UPDATE planets SET channel = $1 WHERE id = $2'
- ,undef,$channel,$id)){
- $ND::server->command("msg $ND::target $x:$y:$z relay channel has been set to: $channel");
- intel_log $user->{uid},$id,"Set channel to: $channel";
- }
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Members;
-use strict;
-use warnings;
-use ND::IRC::Access;
-use ND::DB;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/currentCalls showraids checkPoints findSMS/;
-
-sub currentCalls {
- my ($verbose) = @_;
- DB();
- if (1){ #TODO: add check for member
- my $f = $ND::DBH->prepare(<<SQL
- SELECT (c.landing_tick - tick()) AS eta, concat(i.shiptype||'/') AS shiptype, dc.username,p.x
- 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
- JOIN current_planet_stats p ON u.planet = p.id
- WHERE open AND (c.landing_tick - tick()) >= 7
- GROUP BY c.id,c.landing_tick,dc.username,p.x
- ORDER BY c.landing_tick;
-SQL
-);
- $f->execute();
- my $calls = "";
- while (my @row = $f->fetchrow()){
- chop($row[1]);
- my $dc = defined $row[2] ? $row[2] : '';
- $calls .= " (Anti $row[1] ETA: $row[0] Cluster: $row[3] DC: $dc) |"
- }
- chop($calls);
- if (defined $verbose || length $calls > 0){
- $ND::server->command("msg $ND::target Current calls: $calls");
- }
- }
-}
-
-sub showraids {
- DB();
- if (1){ #TODO: add check for member
- my $f = $ND::DBH->prepare(<<SQL
- SELECT id FROM raids
- WHERE open AND not removed AND tick + waves - 7 > tick()
- AND id IN (SELECT raid FROM raid_access WHERE gid = 2)
-SQL
-);
- $f->execute();
- my $calls = "";
- while (my ($raid) = $f->fetchrow()){
- $calls .= " https://nd.ruin.nu/raids?raid=$raid |"
- }
- $calls = "No open future raids" if ($f->rows == 0);
- chop($calls);
- $ND::server->command("msg $ND::target $calls");
- }
-}
-
-sub checkPoints {
- my ($nick) = @_;
- DB();
- my $f;
- if ($nick){
- if (officer() || dc() || bc()){
- $f = $ND::DBH->prepare("SELECT username, attack_points, defense_points, scan_points, humor_points FROM users WHERE username ILIKE ?");
- }else{
- $ND::server->command("msg $ND::target Only officers are allowed to check for others");
- }
- } else{
- $f = $ND::DBH->prepare("SELECT username, attack_points, defense_points, scan_points, humor_points FROM users WHERE hostmask ILIKE ?");
- $nick = $ND::address;
- }
- if ($f){
- $f->execute($nick);
- while (my @row = $f->fetchrow()){
- $ND::server->command("msg $ND::target $row[0] has $row[1] Attack, $row[2] Defense, $row[3] Scan, $row[4] Humor points");
- }
- }
-}
-
-sub findSMS {
- my ($nick) = @_;
- DB();
- my $f;
- if (officer() || dc()){
- $f = $ND::DBH->prepare("SELECT username,COALESCE(sms,'nothing added') FROM users WHERE username ILIKE ?");
- if (my ($username,$sms) = $ND::DBH->selectrow_array($f,undef,$nick)){
- $ND::server->command("notice $ND::target $ND::B$username$ND::B has sms $ND::B$sms$ND::B");
- }else{
- $ND::server->command("notice $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }
- }else{
- $ND::server->command("notice $ND::target Only dcs and above are allowed to check for others");
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Misc;
-use strict;
-use warnings;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/valuecolor/;
-
-$ND::defchan = "#def-ndawn";
-$ND::memchan = "#nd";
-$ND::scanchan = "#ndef";
-$ND::bcchan = "#nd-day";
-$ND::intelchan = "#ndintel";
-$ND::officerchan = "#nd-officers";
-$ND::communitychan = "#ndawn";
-$ND::pubchan = "#newdawn";
-$ND::xanchan = "#ViolatorS";
-
-sub valuecolor {
- my $s = $_;
- $s = $_[1] if $#_ >= 1;
- $s = "" unless defined $s;
- return chr(3)."5$s".chr(15) if $s eq 'Hostile';
- return chr(3)."3$s".chr(15) if $s eq 'Friendly';
- return chr(3)."3$s".chr(15) if $s eq 'Nap' or $s eq 'NAP';
- return chr(2)."$s".chr(15) if $_[0];
- return $s;
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::PA;
-use strict;
-use warnings;
-use ND::DB;
-use ND::Include;
-use ND::IRC::Access;
-use ND::IRC::Misc;
-use POSIX;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/checkPlanet checkGal shipEff shipStop parseValue prettyValue calcXp/;
-
-sub checkPlanet {
- my ($msg) = @_;
-
- DB();
- my ($x,$y,$z,$nick);
- if ($msg =~ /(\d+)\D+(\d+)\D+(\d+)/){
- $x = $1;
- $y = $2;
- $z = $3;
- }elsif (officer()){
- $nick = $msg;
- }else{
- $ND::server->command("notice $ND::target usage .p X:Y:Z".(officer() ? ' or .p nick' : ''));
- }
- my $f = $ND::DBH->prepare(q{SELECT coords(x,y,z),ruler,planet,race,score,size,value,scorerank,sizerank,
- valuerank, xp, xprank, alliance, relationship, nick, planet_status, hit_us, channel
- FROM current_planet_stats WHERE (x = $1 AND y = $2 and z = $3) OR nick ILIKE $4 LIMIT 1
- });
- $f->execute($x,$y,$z,$nick);
- if (my $planet = $f->fetchrow_hashref()){
- for (keys %{$planet}){
- $planet->{$_} = valuecolor(1,$planet->{$_});
- }
- my $ally = "";
- if (officer() || dc()){
- $ally = "Alliance=$planet->{alliance} ($planet->{relationship}), Nick=$planet->{nick} ($planet->{planet_status}), Channel: $planet->{channel}, Hostile Count: $planet->{hit_us},";
- }
- $ND::server->command("notice $ND::target $planet->{coords} $planet->{ruler} OF $planet->{planet},$ally Race=$planet->{race}, Score=$planet->{score} ($planet->{scorerank}), Size=$planet->{size} ($planet->{sizerank}), Value=$planet->{value} ($planet->{valuerank}), XP=$planet->{xp} ($planet->{xprank})");
- }else{
- $ND::server->command("notice $ND::target Couldn't find planet: $msg");
- }
-}
-sub checkGal {
- my ($x,$y) = @_;
- DB();
- my $f = $ND::DBH->prepare("SELECT name,score,size,value FROM galaxies WHERE x = ? AND y = ? and tick = (SELECT max(tick) from galaxies)");
- $f->execute($x,$y);
- while (my @row = $f->fetchrow()){
- @row = map (valuecolor(1),@row);
- $ND::server->command("notice $ND::target $x:$y $row[0], Score=$row[1], Size=$row[2], Value=$row[3]");
- }
-}
-
-sub shipEff {
- my ($amount,$ship,$value) = @_;
- $ship = "\%$ship\%";
- $amount = parseValue($amount);
- $value = parseValue($value);
- $value *= -1.5 if defined $value and $value < 0;
- my $feud = '';
-
- my @ship = $ND::DBH->selectrow_array(q{
-SELECT name,target,"type",damage,metal+crystal+eonium,init,"class",guns,race
-FROM ship_stats WHERE name ILIKE ?
- }, undef, $ship);
- if (@ship){
- my $type = "kill";
- $type = "stun" if $ship[2] eq 'Emp';
- $type = "steal" if ($ship[2] eq 'Steal') or ($ship[2] eq 'Pod');
-
- $amount = int(($value*100/$ship[4])) if $amount eq 'value';
- $feud = '(FEUD: '.prettyValue(int($amount/0.80)).') ' if defined $value;
- $value = prettyValue(($amount*$ship[4]/100));
- my $text = prettyValue($amount)." $feud $ship[0] ($ship[5]:$value) will $type:";
- my $st = $ND::DBH->prepare(q{
- SELECT name,"class","type",armor,metal+crystal+eonium,init,target,eres,race
- FROM ship_stats WHERE "class" = ?
- });
- $st->execute($ship[1]);
- while (my @target = $st->fetchrow()){
- my $dead = $ship[2] eq 'Emp' ? int($amount*$ship[7]*(100-$target[7])/100) : int($amount*$ship[3]/$target[3]);
- $value = prettyValue($dead*$target[4]/100);
- if (($target[6] eq $ship[6]) and ($target[5] <= $ship[5])){
- $target[5] = "${ND::C}04$target[5]$ND::C";
- }elsif(($target[6] eq $ship[6]) and ($target[5] > $ship[5])){
- $target[5] = "${ND::C}12$target[5]$ND::C";
- }
- $target[0] = "${ND::C}04$target[0]$ND::C" if $target[2] eq 'Norm' || $target[2] eq 'Cloak';
- $target[0] = "${ND::C}12$target[0]$ND::C" if $target[2] eq 'Emp';
- $target[0] = "${ND::C}13$target[0]$ND::C" if $target[2] eq 'Steal';
- $text .= " $ND::B$dead$ND::B $target[0] ($target[5]:$value),";
- }
- chop $text;
- $ND::server->command("notice $ND::target $text");
- }
- #print $text;
-}
-
-sub shipStop {
- my ($amount,$ship,$value) = @_;
- $ship = "\%$ship\%";
- $amount = parseValue($amount);
- $value = parseValue($value);
- $value *= -1.5 if defined $value and $value < 0;
- my $feud = '';
-
- my @ship = $ND::DBH->selectrow_array(q{
-SELECT name,target,"type",armor,metal+crystal+eonium,init,"class",eres,race
-FROM ship_stats WHERE name ILIKE ?
- }, undef, $ship);
- if (@ship){
- $ship[0] = "${ND::C}04$ship[0]$ND::C" if $ship[2] eq 'Norm';
- $ship[0] = "${ND::C}12$ship[0]$ND::C" if $ship[2] eq 'Emp';
- $ship[0] = "${ND::C}13$ship[0]$ND::C" if $ship[2] eq 'Steal';
-
- $amount = int(($value*100/$ship[4])) if $amount eq 'value';
- $feud = '(FEUD: '.int($amount/0.80).') ' if defined $value;
- $value = prettyValue(($amount*$ship[4]/100));
- my $text = "To stop $amount $feud $ship[0] ($ship[5]:$value) you need:";
- my $st = $ND::DBH->prepare(q{
- SELECT name,"class","type",damage,metal+crystal+eonium,init,target,guns,race
- FROM ship_stats WHERE "target" = ?
- });
- $st->execute($ship[6]);
- while (my @stopper = $st->fetchrow()){
- my $needed = $stopper[2] eq 'Emp' ? ceil($amount*100/(100-$ship[7])/$stopper[7]) : ceil($amount*$ship[3]/$stopper[3]);
- $value = prettyValue($needed*$stopper[4]/100);
- if (($stopper[1] eq $ship[1]) and ($ship[5] <= $stopper[5])){
- $stopper[5] = "${ND::C}04$stopper[5]$ND::C";
- }elsif(($stopper[1] eq $ship[1]) and ($ship[5] > $stopper[5])){
- $stopper[5] = "${ND::C}12$stopper[5]$ND::C";
- }
- $stopper[0] = "${ND::C}04$stopper[0]$ND::C" if $stopper[2] eq 'Norm' || $stopper[2] eq 'Cloak';
- $stopper[0] = "${ND::C}12$stopper[0]$ND::C" if $stopper[2] eq 'Emp';
- $stopper[0] = "${ND::C}13$stopper[0]$ND::C" if $stopper[2] eq 'Steal';
- $text .= " $ND::B$needed$ND::B $stopper[0] ($stopper[5]:$value),";
- }
- chop $text;
- $ND::server->command("notice $ND::target $text");
- }
- #print $text;
-}
-
-sub calcXp {
- my ($x,$y,$z,$roids,$cap) = @_;
-
- my ($avalue,$ascore) = $ND::DBH->selectrow_array(q{
- SELECT value,score FROM current_planet_stats WHERE
- id = (SELECT planet FROM users WHERE hostmask ILIKE ?);
- }, undef, $ND::address);
- my ($tvalue,$tscore,$tsize) = $ND::DBH->selectrow_array(q{
- SELECT value,score,size FROM current_planet_stats WHERE
- x = ? AND y = ? and z = ?;
- }, undef, $x,$y,$z);
- $cap = 0.25 unless $cap;
- unless($roids){
- $roids = int($tsize*$cap);
- }elsif ($roids < 10){
- $tsize = ceil($tsize*.75**($roids-1));
- $roids = int($cap*$tsize);
- }
- $tsize -= $roids;
- unless (defined $avalue && defined $ascore){
- $ND::server->command("notice $ND::target You don't have a planet specified");
- return;
- }
- unless (defined $tvalue && defined $tscore){
- $ND::server->command("notice $ND::target Doesn't seem to be a planet at $x:$y:$z");
- return;
- }
- my $xp = pa_xp($roids,$ascore,$avalue,$tscore,$tvalue);
- my $score = 60 * $xp;
- my $value = $roids*200;
- my $totscore = prettyValue($score + $value);
- $ND::server->command("notice $ND::target You will gain $ND::B$xp$ND::B XP, $ND::B$score$ND::B score, if you steal $roids roids ($ND::B$value$ND::B value), from $ND::B$x:$y:$z$ND::B, who will have $ND::B$tsize$ND::B roids left, total score gain will be: $ND::B$totscore$ND::B in total,");
-}
-
-sub findCovOpper {
- my ($stolen) = @_;
-
- my $tick = $ND::tick;
- my $agents;
-
- if ($stolen =~ /(\d+) (\d+) (\d+)/){
- $tick = $1;
- $agents = $2;
- $stolen = $3;
- }elsif ($stolen =~ /(\d+) (\d+)/){
- $tick = $1;
- $stolen = $3;
- }
-
- my ($value,$score) = $ND::DBH->selectrow_array(q{
- SELECT value,score FROM planet_stats WHERE
- id = (SELECT planet FROM users WHERE hostmask ILIKE ?) AND tick = ?;
- }, undef, $ND::address,$tick);
- my ($coords) = $ND::DBH->selectrow_array(q{
- SELECT coords(p.x,p.y,p.z) FROM current_planet_stats p JOIN planet_stats ps using (id) WHERE
- ps.tick = ? AND (2000*?*?/ps.value)::int = $stolen ;
- }, undef, $tick,$agents,$value,$stolen);
- $ND::server->command("notice $ND::target The planet that cov opped you is: $coords");
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Quotes;
-use strict;
-use warnings;
-use ND::IRC::Access;
-use Tie::File;
-use File::Temp ();
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/quote addQuote lastQuote findQuote delQuote/;
-
-tie our @FILE, 'Tie::File', "/home/ndawn/.eos/scripts/quote.txt";
-tie our @OLDFILE, 'Tie::File',"/home/ndawn/.eos/scripts/oldquotes.txt" or die "test";
-
-sub quote {
- my ($n) = @_;
- $n = $n-1 if defined $n;
- $n = int(rand($#FILE)) unless defined $n;
- my $text = $FILE[$n];
- $text =~ s/(.*?)[\r\n]*$/$1/;
- $n++;
- my $num = $#FILE+1;
- $ND::server->command("msg $ND::target Quote $ND::B$n$ND::B of $ND::B$num:$ND::B $text");
-}
-
-sub addQuote {
- my ($quote) = @_;
- push @FILE, $quote;
- my $num = $#FILE+1;
- $ND::server->command("msg $ND::target Quote $ND::B$num$ND::B added");
-}
-sub lastQuote {
- my $n = $#FILE;
- my $text = $FILE[$n];
- $text =~ s/(.*?)[\r\n]*$/$1/;
- $n++;
- $ND::server->command("msg $ND::target Quote $ND::B$n$ND::B of $ND::B$n:$ND::B $text");
-}
-sub findQuote {
- my ($type,$pattern) = @_;
- my $matcher;
- if ($type eq 'qre'){
- if (defined (eval 'm/$pattern/ix')){
- $matcher = 'm/$pattern/ix';
- }else {
- $ND::server->command("msg $ND::target bad regexp");
- close FILE;
- return;
- }
- }else{
- $matcher = '(index uc($_), uc($pattern)) != -1';
- }
- #mkdir "/tmp/quotes";
- #my $file = "/tmp/quotes/$ND::address.txt";
- #open(FILE,'>',"$file");
- my $file = new File::Temp( SUFFIX => '.txt' );
- my $n = 1;
- my $match = 0;
- for $_ (@FILE){
- chomp;
- if (eval $matcher){
- $match = 1;
- print $file "$n: $_\n";
- }
- $n++;
- }
- if ($match){
- $ND::server->command("dcc send $ND::nick $file");
- }else{
- $ND::server->command("msg $ND::target $ND::nick: No quotes matching that.");
- }
-}
-sub delQuote {
- my ($n) = @_;
- if (hc){
- $n = $n-1;
- if (exists $FILE[$n]){
- my ($uid,$username) = $ND::DBH->selectrow_array(q{SELECT uid,username FROM users where hostmask ILIKE ?}
- ,undef,$ND::address);
- my $text = $FILE[$n];
- push @OLDFILE,"Removed by $username ($uid): $text";
- splice @FILE,$n,1;
- $n++;
- my $num = $#FILE+1;
- $ND::server->command("msg $ND::target Quote $ND::B$n$ND::B {$text} removed, number of quotes now: $ND::B$num$ND::B");
- }else{
- $ND::server->command("msg $ND::target No such quote.");
- }
- }else{
- $ND::server->command("msg $ND::target You don't have access to that!");
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Scans;
-use strict;
-use warnings;
-use ND::DB;
-use ND::IRC::Access;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/addScan addScanGroup sendScan/;
-
-sub addScan {
- my ($id,$verbose) = @_;
- DB();
- if (1){
- unless ($ND::DBH->selectrow_array("SELECT scan_id FROM scans WHERE scan_id = ? AND tick >= tick() - 168",undef,$id)){
- my @user = $ND::DBH->selectrow_array(q{SELECT uid,username, scan_points, tick()
- FROM users WHERE hostmask ILIKE ? },undef,$ND::address);
- if ($ND::DBH->do(q{INSERT INTO scans (scan_id,tick,"type") VALUES (?,tick(),COALESCE(?,'-1'))},
- undef,$id,$user[0]) == 1){
- if (@user){
- $ND::DBH->do('UPDATE users SET scan_points = scan_points + 1 WHERE uid = ? ',undef,$user[0]);
- $user[2] += 1;
- $ND::server->command("msg $ND::target Added scan, at tick $user[3]. $user[1] points now $user[2]");
- }elsif ($verbose){
- $ND::server->command("msg $ND::target Added scan, but unknown user, no points");
- }
- }
- }elsif ($verbose){
- $ND::server->command("msg $ND::target a scan with that id has already been added within the last 48 ticks");
- }
- }
-}
-sub addScanGroup {
- my ($id,$verbose) = @_;
- DB();
- if (1){
- unless ($ND::DBH->selectrow_array("SELECT scan_id FROM scans WHERE type = 'group' AND scan_id = ? AND tick >= tick() - 168",undef,$id)){
- my @user = $ND::DBH->selectrow_array(q{SELECT uid,username, scan_points, tick()
- FROM users WHERE hostmask ILIKE ? },undef,$ND::address);
- if ($ND::DBH->do(q{INSERT INTO scans (scan_id,tick,"type",scan) VALUES (?,tick(),'group',COALESCE(?,'-1'))},
- undef,$id,$user[0]) == 1){
- if (@user){
- $ND::server->command("msg $ND::target Added scan group, at tick $user[3]. Points will be added after parsing");
- }elsif ($verbose){
- $ND::server->command("msg $ND::target Added scan, but unknown user, no points");
- }
- }
- }elsif ($verbose){
- $ND::server->command("msg $ND::target a scan with that id has already been added within the last 48 ticks");
- }
- }
-}
-
-sub sendScan {
- my ($target,$msg) = @_;
- DB();
- if (scanner()){
- $ND::server->command("msg $target ".chr(2).$msg.chr(3)."4 (reply with /msg $ND::scanchan)");
- $ND::server->command("msg $ND::target ${ND::C}3$1 << $2");
- }
-}
-
-1;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# This program is free software; you can redistribute it and/or modify *
-# it under the terms of the GNU General Public License as published by *
-# the Free Software Foundation; either version 2 of the License, or *
-# (at your option) any later version. *
-# *
-# This program is distributed in the hope that it will be useful, *
-# but WITHOUT ANY WARRANTY; without even the implied warranty of *
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-# GNU General Public License for more details. *
-# *
-# You should have received a copy of the GNU General Public License *
-# along with this program; if not, write to the *
-# Free Software Foundation, Inc., *
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
-#**************************************************************************/
-package ND::IRC::Usermgm;
-use strict;
-use warnings;
-use ND::DB;
-use ND::IRC::Access;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/addUser whois flags flag laston addPoints chattrG setHost setPNick deactivateUser getShips/;
-
-sub addUser {
- my ($nick,$pnick) = @_;
- DB();
- if (hc()){
- $pnick = $nick unless $pnick;
- my $host = "$pnick.users.netgamers.org";
- my ($username,$hostname,$p_nick) = $ND::DBH->selectrow_array(q{SELECT username, hostmask,pnick
- FROM users WHERE username ILIKE ? OR hostmask ILIKE ? OR pnick ILIKE ?}
- ,undef,$nick,$host,$pnick);
- if ((not defined $username) && $ND::DBH->do("INSERT INTO users (username,hostmask,pnick,password) VALUES(?,?,?,'')"
- ,undef,$nick,$host,$pnick)){
- $ND::server->command("msg $ND::target Added $ND::B$nick(/$pnick)$ND::B with host: $ND::B$host$ND::B");
- }elsif(defined $username){
- $ND::server->command("msg $ND::target $ND::B$username ($p_nick)$ND::B already exists with host: $ND::B$hostname$ND::B.");
-
- }else{
- $ND::server->command("msg $ND::target Something went wrong when trying to add $ND::B$nick ($pnick)$ND::B with host: $ND::B$host$ND::B, ".$ND::DBH->errstr);
- }
- }else{
- $ND::server->command("msg $ND::target Only HCs are allowed to add users");
- }
-}
-sub whois {
- my ($nick) = @_;
- DB();
- if (officer()){
- my $f = $ND::DBH->prepare("SELECT username, hostmask, concat(flag) FROM users u LEFT OUTER JOIN (SELECT uid,flag FROM groupmembers NATURAL JOIN groups ORDER BY uid,flag ) g ON g.uid = u.uid WHERE username ILIKE ? GROUP BY username,hostmask");
- $f->execute($nick);
- while (my @row = $f->fetchrow()){
- $ND::server->command("msg $ND::target $row[0] flags: ($row[2]) host: $row[1]");
- }
- if ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }
- }else{
- $ND::server->command("msg $ND::target Only officers are allowed to check that");
- }
-}
-
-sub flags {
- my ($nick) = @_;
- DB();
- unless ($1){
- my ($flags) = $ND::DBH->selectrow_array("SELECT TRIM(', ' FROM concat(flag||':'||groupname||', ')) FROM groups");
- $ND::server->command("msg $ND::target $flags");
- }elsif (hc()){
- my $f = $ND::DBH->prepare("SELECT username, concat(flag), TRIM(', ' FROM concat(groupname||', ')) FROM users u LEFT OUTER JOIN (SELECT uid,flag,groupname FROM groupmembers NATURAL JOIN groups ORDER BY uid,flag ) g ON g.uid = u.uid WHERE username ILIKE ? GROUP BY username,hostmask");
- $f->execute($nick);
- while (my @row = $f->fetchrow()){
- $ND::server->command("msg $ND::target Flags for $row[0] on: $ND::target: $row[1]| (Global: $row[2])");
- }
- if ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }
- }else{
- $ND::server->command("msg $ND::target Only HCs are allowed to check that");
- }
-}
-
-sub flag {
- my ($flag) = @_;
-
- if (officer()|| ($ND::target eq $ND::scanchan && $flag eq 'S')){
- my $f = $ND::DBH->prepare(qq{
-SELECT TRIM(', ' FROM concat(username||', ')),count(username) FROM
- (SELECT uid, username FROM users ORDER BY username) u NATURAL JOIN groupmembers gm
- JOIN groups g ON g.gid = gm.gid
-WHERE flag = ?;
- });
- if (my ($users,$count) = $ND::DBH->selectrow_array($f,undef,$flag)){
- $ND::server->command("msg $ND::target $ND::B$count$ND::B Users with flag $ND::B$flag$ND::B: $users");
- }
- }else{
- $ND::server->command("msg $ND::target Only officers are allowed to check that");
- }
-}
-
-sub laston {
- my ($flag,$min) = @_;
-
- if (officer()){
- my $f = $ND::DBH->prepare(qq{SELECT username,last
- FROM (SELECT uid,username, date_part('day',now() - laston)::int AS last,laston FROM users) u NATURAL JOIN groupmembers NATURAL JOIN groups WHERE flag = ? AND (last >= ? OR last IS NULL) ORDER BY laston
- });
- $min = 0 unless defined $min;
- $f->execute($flag,$min);
- my $text;
- my $i = 0;
- while (my $user = $f->fetchrow_hashref){
- $user->{last} = '?' unless defined $user->{last};
- $text .= "$user->{username}($user->{last}) ";
- $i++;
- }
- $ND::server->command("msg $ND::target $ND::B$i$ND::B Users(days) with flag $ND::B$flag$ND::B: $text");
- }else{
- $ND::server->command("msg $ND::target Only officers are allowed to check that");
- }
-}
-
-
-sub getShips {
- my ($ship) = @_;
-
- if (officer() || dc()){
- my $f = $ND::DBH->prepare(qq{SELECT username,amount
- FROM users u JOIN fleets f USING (uid) JOIN fleet_ships fs ON f.id = fs.fleet WHERE f.fleet = 0 AND ship ILIKE ? ORDER BY amount DESC
- });
- $f->execute($ship);
- my $text;
- my $i = 0;
- my $total = 0;
- while (my $user = $f->fetchrow_hashref){
- $user->{last} = '?' unless defined $user->{last};
- $text .= "$user->{username}: $user->{amount} ";
- $i++;
- $total += $user->{amount};
- }
- if ($text){
- $ND::server->command("notice $ND::nick $ND::B$i$ND::B Users with $ND::B$total $ship$ND::B: $text");
- }else{
- $ND::server->command("msg $ND::target $ND::B$i$ND::B Couldn't find any user with $ND::B$ship$ND::B:");
- }
- }
-}
-
-sub addPoints {
- my ($t,$nick,$p) = @_;
- DB();
- if ( ($t eq "d" && dc())
- || ($t eq "a" && bc())
- || ($t eq "h" && officer())
- || ($t eq "s" && scanner())){
- my $points = 1;
- if ($p){
- $points = $p;
- }
- if ($points*$points > 400){
- $ND::server->command("msg $ND::target Values between -20 and 20 please");
- return;
- }
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my @row = $f->fetchrow();
- if ($f->rows == 1){
- my $type = "defense";
- $type = "attack" if $t eq "a";
- $type = "humor" if $t eq "h";
- $type = "scan" if $t eq "s";
- my ($fleets) = $ND::DBH->selectrow_array('SELECT count(*) FROM raids r JOIN raid_targets rt ON r.id = rt.raid JOIN raid_claims rc ON rt.id = rc.target WHERE not launched AND uid = ? AND tick + 24 > tick();',undef,$row[0]);
- if ($t eq 'a' && $fleets > 0 && $points > 0){
- $ND::server->command("msg $ND::target $row[1] has $fleets claimed waves the last 24 ticks that aren't marked as launched, so no points.");
- return;
- }
- $type .= "_points";
- $ND::DBH->do("UPDATE users SET $type = $type + ? WHERE uid = ?",undef,$points,$row[0]);
- $ND::server->command("msg $ND::target $row[1] has been given $points $type");
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
-
- }else{
- $ND::server->command("msg $ND::target You don't have access for that");
- }
-}
-
-sub chattrG {
- my ($nick, $flags) = @_;
- DB();
- if (hc() || ($flags =~ /^(\+|-)?x$/ && $ND::address eq 'Assassin.users.netgamers.org')){
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my @user = $f->fetchrow();
- if ($f->rows == 1){
- my $add = 1;
- $flags =~ /^(-)/;
- my $update;
- if ($1 eq "-"){
- $update = $ND::DBH->prepare("DELETE FROM groupmembers WHERE uid = ? AND gid = (SELECT gid FROM groups WHERE flag = ?)");
- }else{
- $update = $ND::DBH->prepare("INSERT INTO groupmembers (uid,gid) VALUES(?,(SELECT gid FROM groups WHERE flag = ?))");
- }
- while ($flags =~ m/(\w)/g){
- $update->execute($user[0],$1);
- }
- $update = $ND::DBH->prepare("SELECT concat(flag) FROM (SELECT uid,flag FROM groupmembers NATURAL JOIN groups ORDER BY uid,flag ) g WHERE uid = ? ");
- my @flags = $ND::DBH->selectrow_array($update,undef,$user[0]);
- $ND::server->command("msg $ND::target Global flags for $user[1] are now: $flags[0]");
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
- }
-}
-
-sub setHost {
- my ($nick, $host) = @_;
- DB();
- if (hc()){
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my ($uid,$nick) = $f->fetchrow();
- if ($f->rows == 1){
- my ($username,$hostname) = $ND::DBH->selectrow_array("SELECT username, hostmask FROM users WHERE hostmask ILIKE ? AND NOT (username ILIKE ?)",undef,$host,$nick);
- if ((not defined $username) && $ND::DBH->do("UPDATE users SET hostmask = ? WHERE uid = ?",undef,$host,$uid) > 0){
- $ND::server->command("msg $ND::target Updated $ND::B$nick${ND::B}'s host to: $ND::B$host$ND::B");
- }elsif(defined $username){
- $ND::server->command("msg $ND::target $ND::B$username$ND::B already exists with host: $ND::B$hostname$ND::B.");
- }else{
- $ND::server->command("msg $ND::target Couldn't update $ND::B$username${ND::B}'s host");
- }
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
- }
-}
-
-sub setPNick {
- my ($nick, $pnick) = @_;
- DB();
- if (hc()){
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my ($uid,$nick) = $f->fetchrow();
- if ($f->rows == 1){
- my ($username,$p_nick) = $ND::DBH->selectrow_array("SELECT username, pnick FROM users WHERE pnick ILIKE ? AND NOT (username ILIKE ?)",undef,$pnick,$nick);
- if ((not defined $username) && $ND::DBH->do("UPDATE users SET pnick = ? WHERE uid = ?",undef,$pnick,$uid) > 0){
- $ND::server->command("msg $ND::target Updated $ND::B$nick${ND::B}'s pnick to: $ND::B$pnick$ND::B");
- }elsif(defined $username){
- $ND::server->command("msg $ND::target $ND::B$username$ND::B already exists with pnick $ND::B$p_nick$ND::B.");
- }else{
- $ND::server->command("msg $ND::target Couldn't update $ND::B$username${ND::B}'s host");
- }
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
- }
-}
-
-sub deactivateUser {
- my ($nick) = @_;
- DB();
- if (hc()){
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my ($uid,$username) = $f->fetchrow();
- if ($f->rows == 1){
- my $updated = $ND::DBH->do("UPDATE users SET hostmask = ?, password = '' WHERE uid = ?",undef,$username,$uid);
- if ($updated > 0){
- my $groups = $ND::DBH->do("DELETE FROM groupmembers WHERE uid = ?",undef,$uid);
- $ND::server->command("msg $ND::target $ND::B$username$ND::B has been deactivated.");
- }else{
- $ND::server->command("msg $ND::target Something went wrong when trying to modify $ND::B$username$ND::B");
- }
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
- }
-}
-
-1;