made bind/unbind command bindings "required" (means: there has to be at least 1 comma...
[NeonServV5.git] / src / bot_NeonServ.c
index 53ad3512f03ab090b8531bdad6ba896e616b91be..97f4f246f6c7ead35c3c3f1ae84e03dbb649ab66 100644 (file)
@@ -313,6 +313,7 @@ static const struct default_language_entry msgtab[] = {
     {"NS_RENAME_DONE", "Renamed $b%s$b to $b%s$b."},
     {"NS_RENAME_FAIL", "Failed renaming $b%s$b."},
     {"NS_FUN_DISABLED", "Fun commands are disabled in %s."},
+    {"NS_UNBIND_REQUIRED", "%1$s is a required function and there is no other command bound to %1$s. Bind anothjer command to %1$s first."}, /* {ARGS: bind} */
     {NULL, NULL}
 };
 
@@ -387,7 +388,6 @@ static void start_bots() {
     res = mysql_use();
     
     while ((row = mysql_fetch_row(res)) != NULL) {
-        
         user = addUser(row[0]);
         strcpy(user->ident, row[1]);
         strcpy(user->realname, row[2]);
@@ -398,22 +398,24 @@ static void start_bots() {
         client->botid = BOTID;
         client->clientid = atoi(row[7]);
         connect_socket(client);
-        printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", client->botid);
-        res2 = mysql_use();
-        while ((row = mysql_fetch_row(res2)) != NULL) {
-            if(bind_cmd_to_command(BOTID, row[0], row[1])) {
-                if(row[2] && strcmp(row[2], "")) {
-                    bind_set_parameters(BOTID, row[0], row[2]);
-                }
-                if(row[3]) {
-                    bind_set_global_access(BOTID, row[0], atoi(row[3]));
-                }
-                if(row[4]) {
-                    bind_set_channel_access(BOTID, row[0], row[4]);
-                }
+    }
+    
+    printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
+    res2 = mysql_use();
+    while ((row = mysql_fetch_row(res2)) != NULL) {
+        if(bind_cmd_to_command(BOTID, row[0], row[1])) {
+            if(row[2] && strcmp(row[2], "")) {
+                bind_set_parameters(BOTID, row[0], row[2]);
+            }
+            if(row[3]) {
+                bind_set_global_access(BOTID, row[0], atoi(row[3]));
+            }
+            if(row[4]) {
+                bind_set_channel_access(BOTID, row[0], row[4]);
             }
         }
     }
+    bind_unbound_required_functions(BOTID);
 }
 
 void init_NeonServ() {
@@ -488,8 +490,8 @@ void init_NeonServ() {
     OPER_COMMAND("csuspend",     neonserv_cmd_csuspend,  1,     100,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
     OPER_COMMAND("cunsuspend",   neonserv_cmd_cunsuspend,1,     100,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
     OPER_COMMAND("move",         neonserv_cmd_move,      2,     300,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
-    OPER_COMMAND("bind",         neonserv_cmd_bind,      2,     900,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
-    OPER_COMMAND("unbind",       neonserv_cmd_unbind,    1,     900,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+    OPER_COMMAND("bind",         neonserv_cmd_bind,      2,     900,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+    OPER_COMMAND("unbind",       neonserv_cmd_unbind,    1,     900,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
     OPER_COMMAND("oplog",        neonserv_cmd_oplog,     0,     1,    CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
     OPER_COMMAND("search",       neonserv_cmd_search,    1,     400,  CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
     OPER_COMMAND("setaccess",    neonserv_cmd_setaccess, 2,     1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);