made bind/unbind command bindings "required" (means: there has to be at least 1 comma...
[NeonServV5.git] / src / modcmd.c
index 301a50256806802ca6f4edd4647a5a360d835da0..90e46e069354775aea37408db06757ebd1e21a29 100644 (file)
@@ -701,3 +701,27 @@ struct cmd_binding *find_cmd_binding(int botid, char *cmd) {
     return NULL;
 }
 
+void bind_unbound_required_functions(int botid) {
+    struct cmd_function *cmdfunc;
+    int i, found;
+    struct cmd_binding *cbind;
+    for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
+        if(cmdfunc->botid == botid && (cmdfunc->flags & CMDFLAG_REQUIRED)) {
+            found = 0;
+            for(i = 0; i < 27; i++) {
+                for(cbind = cmd_binds[i]; cbind; cbind = cbind->next) {
+                    if(cbind->botid == botid && cbind->func == cmdfunc) {
+                        found = 1;
+                        break;
+                    }
+                }
+                if(found)
+                    break;
+            }
+            if(!found) {
+                bind_cmd_to_function(botid, cmdfunc->name, cmdfunc);
+            }
+        }
+    }
+}
+