int args_pos = 0;
char *uargs[MAXNUMPARAMS];
int uargc = 0;
- char *b;
+ char *b, *c;
int i;
int allargs, argi;
for(i = 0; i < cbind->paramcount; i++) {
b = cbind->parameters[i];
if(b[0] == '%') {
b++;
+ c = b;
+ while(*c && *c != ' ') {
+ if(*c == '|') break;
+ c++;
+ }
+ if(!*c || *c == ' ') c = NULL;
+ else {
+ *c = '\0';
+ c++;
+ }
if(b[strlen(b)-1] == '-') {
allargs = strlen(b)-1;
b[allargs] = '\0';
} else if((cbind->func->flags & CMDFLAG_EMPTY_ARGS)) {
uargs[uargc++] = args_buffer + args_pos;
args_buffer[args_pos++] = '\0';
+ } else if(c) {
+ uargs[uargc++] = args_buffer + args_pos;
+ args_pos += sprintf(args_buffer + args_pos, "%s", c) + 1;
}
} else if(!strcmp(b, "c")) {
uargs[uargc++] = args_buffer + args_pos;
uargs[uargc++] = args_buffer + args_pos;
args_pos += sprintf(args_buffer + args_pos, "%s", user->nick) + 1;
}
+ if(c) c[-1] = '|'; //reset \0 to |
} else {
uargs[uargc++] = args_buffer + args_pos;
args_pos += sprintf(args_buffer + args_pos, "%s", b) + 1;
for(i = 0; i < cbind->paramcount; i++)
free(cbind->parameters[i]);
}
+ if(cbind->channel_access)
+ free(cbind->channel_access);
free(cbind);
return 1;
} else
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;