Просмотр исходного кода

* Using a cmd with a cmdpass without proper flags now acts as if cmd is not valid (no longer spams wrong pass error)
* Changed cosmetics of wrong pass error


svn: 1781

Bryan Drewery 21 лет назад
Родитель
Сommit
5a127c4682
2 измененных файлов с 33 добавлено и 27 удалено
  1. 2 0
      doc/UPDATES
  2. 31 27
      src/core_binds.c

+ 2 - 0
doc/UPDATES

@@ -14,6 +14,8 @@ Lines prefixxed with '-' were disabled before release and are not finishsed.
 * Removed compatability code left from 1.2->1.2.1 switch
 * Removed/cleaned up more code left from eggdrop/modules
 * Fixed chanset (manop/mop/mdop/bad-cookie) to accept english parameters: ignore/deop/kick/delete/remove. 
+* cmd_cmdpass was not clear on usage.
+* Using a cmd with a cmdpass without proper flags now acts as if cmd is not valid (no longer spams wrong pass error)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 31 - 27
src/core_binds.c

@@ -37,7 +37,6 @@ void core_binds_init()
 void check_bind_dcc(const char *cmd, int idx, const char *text)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
-  bool found = 0;
   bind_entry_t *entry = NULL;
   bind_table_t *table = NULL;
   char *args = strdup(text);
@@ -45,35 +44,40 @@ void check_bind_dcc(const char *cmd, int idx, const char *text)
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
 
   table = bind_table_lookup("dcc");
+
   for (entry = table->entries; entry && entry->next; entry = entry->next) {
     if (!egg_strcasecmp(cmd, entry->mask)) {
-      found = 1;
-      break;
-    }
-  }
-
-  if (found) {
-    if (has_cmd_pass(cmd)) {
-      char *p = NULL, work[1024] = "", pass[128] = "";
-
-      p = strchr(args, ' ');
-      if (p)
-        *p = 0;
-      strlcpy(pass, args, sizeof(pass));
-
-      if (check_cmd_pass(cmd, pass)) {
-        if (p)
-          *p = ' ';
-        strlcpy(work, args, sizeof(work));
-        p = work;
-        newsplit(&p);
-        strcpy(args, p);
-      } else {
-        dprintf(idx, "Invalid command password. Use %scommand password arguments\n", settings.dcc_prefix);
-        putlog(LOG_MISC, "*", "%s attempted %s%s with missing or incorrect command password", dcc[idx].nick, settings.dcc_prefix, cmd);
-        free(args);
-        return;
+      if (has_cmd_pass(cmd)) {
+        if (flagrec_ok(&entry->user_flags, &fr)) {
+          char *p = NULL, work[1024] = "", pass[128] = "";
+
+          p = strchr(args, ' ');
+          if (p)
+            *p = 0;
+          strlcpy(pass, args, sizeof(pass));
+
+          if (check_cmd_pass(cmd, pass)) {
+            if (p)
+              *p = ' ';
+            strlcpy(work, args, sizeof(work));
+            p = work;
+            newsplit(&p);
+            strcpy(args, p);
+          } else {
+            dprintf(idx, "Invalid command password.\nUse: $b%scommand <password> [arguments]$b\n", settings.dcc_prefix);
+            putlog(LOG_CMDS, "*", "$ #%s# %s %s", dcc[idx].nick, cmd, args);
+            putlog(LOG_MISC, "*", "%s attempted %s%s with missing or incorrect command password", dcc[idx].nick, settings.dcc_prefix, cmd);
+            free(args);
+            return;
+          }
+        } else {
+          putlog(LOG_CMDS, "*", "! #%s# %s %s", dcc[idx].nick, cmd, args);
+          dprintf(idx, "What?  You need '%shelp'\n", settings.dcc_prefix);
+          free(args);
+          return;
+        }
       }
+      break;
     }
   }