]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
/ns mark
authorerry <redacted>
Thu, 27 Jun 2013 22:16:39 +0000 (22:16 +0000)
committererry <redacted>
Thu, 27 Jun 2013 22:16:39 +0000 (22:16 +0000)
git-svn-id: http://svn.tabris.net/repos/srsv@3616 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.4.3/SrSv/NickReg/NickText.pm
branches/0.4.3/help/nickserv.txt
branches/0.4.3/help/nickserv/mark.txt [new file with mode: 0644]
branches/0.4.3/modules/serviceslibs/nickserv.pm

index d774f0186a9f80b4fc0a452975a9604524ecc58d..778c1221f17213067685eee3d3bf3788ea4c9d94 100644 (file)
@@ -31,6 +31,7 @@ BEGIN {
                NTF_AUTHCODE    => 7,
                NTF_PROFILE     => 8,
                NTF_VHOST_REQ   => 9,
+        NTF_MARK    => 10
        );
        require constant; import constant \%constants;
        our @EXPORT = keys(%constants);
index 57d4b1db7f940ef99b36c92f300b923428cbcd18..24786c2255f807024d61783757125847fe279b09 100644 (file)
@@ -11,6 +11,7 @@ Commands:
   RECOVER   Recovers/jupes a nick to stop another user from using it.
   RELEASE   Releases your nick from services custody
   INFO      Get information about a nick
+  AJOIN     Maintain a channel autojoin list
   DROPGROUP Delete a registered nickname and all aliases
 
   LINK      Make an alias of your nick
@@ -20,7 +21,7 @@ Commands:
 
 Additional Commands:
   GLIST  ALIST  WATCH  SILENCE  ACC  SEEN  AJOIN   LISTEMAIL
-  LOGOUT  LIST   AUTH  AUTHCODE SENDPASS   PROFILE
+  LOGOUT  LIST   AUTH  AUTHCODE SENDPASS   PROFILE MARK
 
 %BNOTICE:%B This service is intended to provide a way for IRC users to
 ensure their identity is not compromised. It is NOT intended to
diff --git a/branches/0.4.3/help/nickserv/mark.txt b/branches/0.4.3/help/nickserv/mark.txt
new file mode 100644 (file)
index 0000000..1ea7018
--- /dev/null
@@ -0,0 +1,30 @@
+%BNickServ MARK%B stores information about a user that
+is only visible for network staff.
+This allows staff to keep private notes on a user.
+
+Syntax: %BMARK LIST%B <%Unick%U> [%Unick%U ...]
+        %BMARK%B [%Unick%U] %BADD%B %Udata%U
+        %BMARK%B [%Unick%U] %BDEL%B %Unumber%U
+        %BMARK%B [%Unick%U] %BWIPE%B
+
+The %BMARK LIST%B command displays MARK data for you
+or for a list of registered nicks.
+
+The %BMARK ADD%B command adds a MARK for you
+or a registered user.
+
+%BExamples:%B
+    /ns MARK EvilPikachu ADD Known trouble maker, keep an eye on.
+    /ns MARK d1g1t ADD cheap indian callcentre
+    /ns MARK erry ADD implements mark feature in order
+    to keep cruel marks about other staff.
+
+The %BMARK DEL%B command removes a mark entry from
+yourself or a given user. If you are HELPOP, you can
+only delete marks you set. If you are OPER or above, you
+can delete any mark.
+
+The %BPROFILE WIPE%B command deletes all marks on yourself
+or a user.
+
+%BThis command is limited to network staff.%B
index 3e88500be8821712a99a474e2815bb8ab46f1bc8..0d3f87cc940597659b7242e4127a1c84daebce53 100644 (file)
@@ -491,6 +491,36 @@ import SrSv::MySQL::Stub {
                FROM nicktext
                JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
                WHERE nicktext.type=@{[NTF_JOIN]} AND nickalias.alias=? LIMIT 1 OFFSET ?"],
+
+       add_mark_ntf => ['INSERT', "INSERT INTO nicktext SELECT nickreg.id, @{[NTF_MARK]}, ?, ?, ?
+               FROM nickreg JOIN nickalias ON (nickreg.id=nickalias.nrid) WHERE nickalias.alias=?"],
+       get_mark_ntf => ['ARRAY', "SELECT nickreg.nick, data FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+        JOIN nickreg ON (nicktext.chan=nickreg.id)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=?
+        ORDER BY nicktext.id ASC"],
+       del_mark_ntf => ['NULL', "DELETE nicktext.* FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=? AND nicktext.id=?"],
+       wipe_mark_ntf => ['NULL', "DELETE nicktext.* FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=?"],
+       max_mark_ntf => ['SCALAR', "SELECT MAX(id) FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=?"],
+    count_mark_ntf => ['SCALAR', "SELECT COUNT(chan) FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=?"],
+       get_mark_id_by_num => ['SCALAR', "SELECT nicktext.id
+               FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=? LIMIT 1 OFFSET ?"],
+       get_mark_setter_by_num => ['SCALAR', "SELECT nicktext.chan
+               FROM nicktext
+               JOIN nickalias ON (nicktext.nrid=nickalias.nrid)
+               WHERE nicktext.type=@{[NTF_MARK]} AND nickalias.alias=? LIMIT 1 OFFSET ?"],
+
+    get_nickreg_id => ['SCALAR', "SELECT nickreg.id FROM nickreg WHERE nickreg.nick=?"]
 };
 
 
@@ -868,8 +898,10 @@ sub dispatch($$$) {
                        notice($user, 'Syntax: AUTHCODE <nick> <code> [newpassword]');
                }
        }
-       elsif($cmd =~ /^profile$/i) {
-               ns_profile($user, @args);
+       elsif($cmd =~ /^(profile|mark)$/i) {
+               my $type = $1;
+
+               ns_profile($user, $type, @args);
        }
        elsif($cmd =~ /^liste?mail/i) {
                if ($#args == 0) {
@@ -2286,41 +2318,74 @@ sub ns_authcode($$$;$) {
 }
 
 sub ns_profile($@) {
-       my ($user, $first, @args) = @_;
-       
-       my %profile_dispatch = (
-               'read'   => \&ns_profile_read,
-               'info'   => \&ns_profile_read,
-
-               'del'    => \&ns_profile_del,
-               'delete' => \&ns_profile_del,
-
-               'set'    => \&ns_profile_update,
-               'update' => \&ns_profile_update,
-               'add'    => \&ns_profile_update,
-
-               'wipe'   => \&ns_profile_wipe,
-       );
-
-       no warnings 'misc';
-       if(my $sub = $profile_dispatch{$args[0]}) {
-               # Second command with nick
-               shift @args;
-               $sub->($user, $first, @args);
-       }
-       elsif(my $sub = $profile_dispatch{$first}) {
-               # Second command without nick
-               $sub->($user, get_user_nick($user), @args);
-       }
-       elsif(@args == 0) {
-               # No second command
-               ns_profile_read($user, ($first || get_user_nick($user)));
-       }
-       else {
-               notice $user,
-                       "Syntax: PROFILE [nick] [SET|DEL|READ|WIPE ...]",
-                       "For help, type: \002/ns help profile\002";
-       }
+    my ($user, $type, $first, @args) = @_;
+
+    my %profile_dispatch = (
+        'read'   => \&ns_profile_read,
+        'info'   => \&ns_profile_read,
+
+        'del'    => \&ns_profile_del,
+        'delete' => \&ns_profile_del,
+
+        'set'    => \&ns_profile_update,
+        'update' => \&ns_profile_update,
+        'add'    => \&ns_profile_update,
+
+        'wipe'   => \&ns_profile_wipe,
+    );
+
+    my %mark_dispatch = (
+        'list'   => \&ns_mark_list,
+
+        'del'    => \&ns_mark_del,
+        'delete' => \&ns_mark_del,
+
+        'add'    => \&ns_mark_add,
+
+        'wipe'   => \&ns_mark_wipe,
+    );
+
+    no warnings 'misc';
+
+    if ( lc $type eq 'profile' ) {
+        if(my $sub = $profile_dispatch{$args[0]}) {
+            # Second command with nick
+            shift @args;
+            $sub->($user, $first, @args);
+        }
+        elsif(my $sub = $profile_dispatch{$first}) {
+            # Second command without nick
+            $sub->($user, get_user_nick($user), @args);
+        }
+        elsif(@args == 0) {
+            # No second command
+            ns_profile_read($user, ($first || get_user_nick($user)));
+        }
+        else {
+            notice $user,
+                "Syntax: PROFILE [nick] [SET|DEL|READ|WIPE ...]",
+                "For help, type: \002/ns help profile\002";
+        }
+    } elsif ( lc $type eq 'mark' ) {
+        if(my $sub = $mark_dispatch{$args[0]}) {
+            # Second command with nick
+            shift @args;
+            $sub->($user, $first, @args);
+        }
+        elsif(my $sub = $mark_dispatch{$first}) {
+            # Seciond command without nick
+            $sub->($user, get_user_nick($user), @args);
+        }
+        elsif(@args == 0) {
+            # No second command
+            ns_mark_list($user, ($first || get_user_nick($user)));
+        }
+        else {
+            notice $user,
+                "Syntax: MARK [nick] [ADD|DEL|LIST|WIPE ...]",
+                "For help, type: \002/ns help mark\002";
+        }
+    }
 }
 
 sub ns_profile_read($$@) {
@@ -2341,6 +2406,36 @@ sub ns_profile_read($$@) {
        }
 }
 
+sub ns_mark_list($$@) {
+    my ($user, $target, @args) = @_;
+
+    if (!adminserv::is_svsop($user, adminserv::S_HELP())) {
+        notice $user, $err_deny;
+        return;
+    }
+
+    foreach my $nick ((scalar(@args) ? @args : $target)) {
+        next unless chk_registered($user, $nick);
+        my @mark_entries = get_mark_ntf($nick);
+
+        if (scalar(@mark_entries)) {
+            my @entries;
+            my $i;
+
+            foreach my $entry (@mark_entries) {
+                push @entries, [ ++$i, "$entry->[0]: $entry->[1]" ];
+            }
+
+            notice $user, columnar ({TITLE => "\002$nick\002 has been \002marked\002 by the following opers:",
+                    NOHILIGHT => nr_chk_flag_user ($user, NRF_NOHIGHLIGHT)},
+                    @entries
+                    );
+        } else {
+            notice $user, "\002$nick\002 has not been marked.";
+        }
+    }
+}
+
 sub ns_profile_update($$@) {
        my ($user, $target, @args) = @_;
 
@@ -2378,6 +2473,39 @@ sub ns_profile_update($$@) {
        notice($user, "\002$target\002's \002$key\002 is now \002$data\002");
 }
 
+sub ns_mark_add($$@) {
+    my ($user, $target, @args) = @_;
+
+    if (!adminserv::is_svsop($user, adminserv::S_HELP())) {
+        notice $user, $err_deny;
+        return;
+    }
+
+    my $data = join ' ', @args;
+
+    return unless chk_registered($user, $target);
+
+    unless ($data) {
+        notice $user, "Syntax: MARK [nick] ADD <data>",
+            "For help, type: \002/ns help mark\002";
+        return;
+    }
+
+    if (length($data) > MAX_PROFILE_LEN) {
+        my $over = length($data) - MAX_PROFILE_LEN;
+        notice ($user, "Your entry is $over characters too long. (".MAX_PROFILE_LEN." max.)");
+        return;
+    }
+
+    my $best = adminserv::is_svsop($user, adminserv::S_HELP());
+
+    my $ns_id = get_nickreg_id($best);
+    my $id = max_mark_ntf($target)+1;
+
+    add_mark_ntf($id, $ns_id, $data, $target);
+    notice($user, "\002$target\002 is now marked.");
+}
+
 sub ns_profile_del($$@) {
        my ($user, $target, @args) = @_;
 
@@ -2405,6 +2533,56 @@ sub ns_profile_del($$@) {
        }
 }
 
+sub ns_mark_del($$@) {
+    my ($user, $target, @args) = @_;
+
+    return unless chk_registered($user, $target);
+
+    if (!adminserv::is_svsop($user, adminserv::S_HELP())) {
+        notice $user, $err_deny;
+        return;
+    }
+
+    my @entries;
+    my @errors;
+    my $success = 0;
+    my $count = 0;
+
+    my $best = adminserv::is_svsop($user, adminserv::S_HELP());
+
+    foreach my $arg (@args) {
+        if ($arg =~ /^[0-9\.,-]+$/) {
+            foreach my $num (makeSeqList($arg)) {
+                my $id = get_mark_id_by_num($target, $num - 1);
+                my $nrid = get_mark_setter_by_num($target, $num - 1);
+
+                if ($id && $nrid) {
+                    if ( $nrid == get_nickreg_id($best) || adminserv::can_do ($user, 'SUPER') ) {
+                        push @entries, $id;
+                        $success++;
+                    } else {
+                        push @errors, $num;
+                    }
+                } else {
+                    notice($user, "No entry \002#$num\002 was found in $target 's mark list");
+                    push @errors, $num;
+                }
+                $count++;
+            }
+        }
+    }
+    foreach my $entry (@entries) {
+        del_mark_ntf($target, $entry);
+    }
+
+    notice($user, "Successfully removed $success marks");
+
+    if ($success != $count) {
+        notice($user, "Could not remove marks " . join (', ', @errors) . ". Note that if you're a helpop you can only remove your own.");
+    }
+}
+
+
 sub ns_profile_wipe($$@) {
        my ($user, $target, undef) = @_;
 
@@ -2423,6 +2601,20 @@ sub ns_profile_wipe($$@) {
        notice($user, "Profile for \002$target\002 wiped.");
 }
 
+sub ns_mark_wipe($$@) {
+    my ($user, $target, undef) = @_;
+
+    if (!adminserv::can_do($user, 'SUPER')) {
+        notice $user, $err_deny;
+        return;
+    }
+
+    return unless chk_registered($user, $target);
+
+    wipe_mark_ntf($target);
+    notice ($user, "Mark for \002$target\002 wiped.");
+}
+
 sub ns_listemail($$) {
        my ($user, $email) = @_;
        unless(adminserv::is_svsop($user, adminserv::S_HELP())) {