added cmd_setbot for dynamic bot management
[NeonServV5.git] / src / modcmd.c
index 9846db20115da854a7f7f0861214ac840762bee2..058612a2b353cd09887d543c67d5ddf000389947 100644 (file)
@@ -704,6 +704,8 @@ int unbind_botwise_cmd(int botid, int clientid, char *cmd) {
                 for(i = 0; i < cbind->paramcount; i++)
                     free(cbind->parameters[i]);
             }
+            if(cbind->channel_access)
+                free(cbind->channel_access);
             free(cbind);
             return 1;
         } else
@@ -712,6 +714,33 @@ int unbind_botwise_cmd(int botid, int clientid, char *cmd) {
     return 0;
 }
 
+int unbind_botwise_allcmd(int clientid) {
+    int i;
+    for(i = 0; i < 27; i++) {
+        struct cmd_binding *cbind, *next, *last = NULL;
+        for(cbind = cmd_binds[i]; cbind; cbind = next) {
+            next = cbind->next;
+            if(clientid == cbind->clientid) {
+                if(last)
+                    last->next = cbind->next;
+                else
+                    cmd_binds[i] = cbind->next;
+                free(cbind->cmd);
+                if(cbind->paramcount) {
+                    int j;
+                    for(j = 0; j < cbind->paramcount; j++)
+                        free(cbind->parameters[j]);
+                }
+                if(cbind->channel_access)
+                    free(cbind->channel_access);
+                free(cbind);
+            } else
+                last = cbind;
+        }
+    }
+    return 1;
+}
+
 struct cmd_function *find_cmd_function(int botid, char *name) {
     struct cmd_function *cmdfunc;
     char *c;