소스 검색

Merge branch 'ducch-77-multi-mns-user' into maint

* ducch-77-multi-mns-user:
  * Fix typo in UPDATES
  * Update docs
  * Only write userfile once in cmd_mns_user
  * Fixes a typo. (An hard->A hard)
  * Disallow removal of hard-coded owners through .-user
  * Multiply users input for .-user
  * bdlib fixes
  Update bdlib
  Fix typo (thanks geto)

Conflicts:
	doc/UPDATES
Bryan Drewery 14 년 전
부모
커밋
99cda806fd
3개의 변경된 파일48개의 추가작업 그리고 37개의 파일을 삭제
  1. 2 0
      doc/UPDATES
  2. 2 2
      doc/help.txt
  3. 44 35
      src/cmds.c

+ 2 - 0
doc/UPDATES

@@ -4,6 +4,8 @@ maint
   * Add an extra 2 second delay before releasing nick to aide in syncing and time to type /nick
   * When a nick is released, start regaining as soon as it is witnessed to have been taken again
   * Update server list, 'set -yes servers -' and 'set -yes servers6 -' to get new list.
+  * cmd_mns_user now accepts multiple users (fixes #77)
+  * Permanent owners can no longer be removed via cmd_mns_user
 
 1.3.2 - http://wraith.botpack.net/milestone/1.3.2
   * Misc bug fixes

+ 2 - 2
doc/help.txt

@@ -118,8 +118,8 @@ See also: +ignore, ignores
  
 See also: invites, +invite, stick, unstick
 ::-user
-###  $b-user$b <handle>
-   Removes the specified handle's user record.
+###  $b-user$b <handle> [anotherhandle] ...
+   Removes the specified handles user records.
  
 See also: +user%{+ai}, -bot%{-}%{+nai}, newleaf%{-}
 ::about:

+ 44 - 35
src/cmds.c

@@ -3474,54 +3474,63 @@ static void cmd_mns_user(int idx, char *par)
   putlog(LOG_CMDS, "*", "#%s# -user %s", dcc[idx].nick, par);
 
   if (!par[0]) {
-    dprintf(idx, "Usage: -user <hand>\n");
+    dprintf(idx, "Usage: -user <handle> [anotherhandle] ...\n");
     return;
   }
 
-  char *handle = newsplit(&par);
-  struct userrec *u2 = get_user_by_handle(userlist, handle);
+  struct userrec *u2 = NULL;
 
-  if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
-    dprintf(idx, "No such user!\n");
-    return;
-  }
-  if ((u2->flags & USER_OWNER) && !(dcc[idx].user->flags & USER_OWNER)) {
-    dprintf(idx, "You can't remove a bot owner!\n");
-    return;
-  }
+  while (par[0]) {
+    char *handle = newsplit(&par);
+    u2 = get_user_by_handle(userlist, handle);
 
-  if (u2->bot) {
-    if (!(dcc[idx].user->flags & USER_OWNER)) {
-        dprintf(idx, "You can't remove bots.\n");
-        return;
+    if (!u2 || (u2 && !whois_access(dcc[idx].user, u2))) {
+      dprintf(idx, "No such user: %s\n", handle);
+      continue;
     }
-    if (!strcasecmp(u2->handle, conf.bot->nick)) {
-      dprintf(idx, "The 'suicide' cmd should be used instead.\n");
-      return;
+    if (isowner(handle)) {
+      dprintf(idx, "A hard-coded owner is unremoveable: %s\n", handle);
+      continue;
+    }
+    if ((u2->flags & USER_OWNER) && !(dcc[idx].user->flags & USER_OWNER)) {
+      dprintf(idx, "You can't remove a bot owner: %s\n", handle);
+      continue;
     }
 
-    int i = nextbot(handle);
+    if (u2->bot) {
+      if (!(dcc[idx].user->flags & USER_OWNER)) {
+          dprintf(idx, "You can't remove bots!");
+          continue;
+      }
+      if (!strcasecmp(u2->handle, conf.bot->nick)) {
+        dprintf(idx, "Use 'suicide' to kill me.\n");
+        continue;
+      }
 
-    if (i < 0)
-      botunlink(idx, handle, "Bot removed.");
-    else if (!strcasecmp(dcc[i].nick, handle))
-      botunlink(idx, handle, "Bot removed.");
-    else {
-      char x[40] = "";
+      int i = nextbot(handle);
 
-      simple_snprintf(x, sizeof(x), "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, conf.bot->nick);
-      botnet_send_unlink(i, x, lastbot(handle), handle, "Bot removed.");
+      if (i < 0)
+        botunlink(idx, handle, "Bot removed.");
+      else if (!strcasecmp(dcc[i].nick, handle))
+        botunlink(idx, handle, "Bot removed.");
+      else {
+        char x[40] = "";
+
+        simple_snprintf(x, sizeof(x), "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, conf.bot->nick);
+        botnet_send_unlink(i, x, lastbot(handle), handle, "Bot removed.");
+      }
     }
+
+    if (!conf.bot->hub)
+      check_this_user(handle, 1, NULL);
+    if (deluser(handle)) {
+      dprintf(idx, "Removed %s: %s.\n", u2->bot ? "bot" : "user", handle);
+    } else
+      dprintf(idx, "Failed to remove %s: %s.\n", u2->bot ? "bot" : "user", handle);
   }
 
-  if (!conf.bot->hub)
-    check_this_user(handle, 1, NULL);
-  if (deluser(handle)) {
-    dprintf(idx, "Removed %s: %s.\n", u2->bot ? "bot" : "user", handle);
-    if (conf.bot->hub)
-      write_userfile(idx);
-  } else
-    dprintf(idx, "Failed.\n");
+  if (conf.bot->hub)
+    write_userfile(idx);
 }
 
 static void cmd_pls_host(int idx, char *par)