added MODCMD_UNKNOWN reply for unknown commands sent via query
authorpk910 <philipp@zoelle1.de>
Thu, 22 Dec 2011 00:32:51 +0000 (01:32 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 22 Dec 2011 00:34:12 +0000 (01:34 +0100)
src/modcmd.c

index 6f0ade7bd31efd52a261e21d409327d5ff4cf7f9..3cb9d0d6b403a4425170df4e0e31de208425df11 100644 (file)
@@ -70,6 +70,7 @@ static const struct default_language_entry msgtab[] = {
     {"MODCMD_ACCESS_DENIED",    "Access denied."},
     {"MODCMD_SUBCOMMANDS",      "Subcommands of %s: %s"}, /* {ARGS: "bot", "ADD, DEL, EDIT"} */
     {"MODCMD_CROSSCHAN",        "You must be in %s (or on its userlist) to use this command."},
+    {"MODCMD_UNKNOWN",          "$b%s$b is an unknown command."}, /* {ARGS: "bla"} */
     {NULL, NULL}
 };
 
@@ -161,8 +162,10 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
         args++;
     }
     struct cmd_binding *cbind;
+    int found_cmd = 0;
     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
         if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && stricmp(cbind->cmd, message) == 0) {
+            found_cmd = 1;
             //get a text bot
             tmp_text_client = get_botwise_prefered_bot(client->botid, (client->botid == 0 ? client->clientid : 0));
             if(cbind->func->func == modcmd_linker) {
@@ -361,6 +364,8 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
             break;
         }
     }
+    if(!found_cmd && !sent_chan)
+        reply(get_botwise_prefered_bot(client->botid, (client->botid == 0 ? client->clientid : 0)), user, "MODCMD_UNKNOWN", message);
     free(message);
     if(args_buffer)
         free(args_buffer);