-/* cmd_global_commands.c - NeonServ v5.2
- * Copyright (C) 2011 Philipp Kreil (pk910)
+/* cmd_global_commands.c - NeonServ v5.3
+ * Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
struct cmd_binding *cbind;
int bindcount = 0;
for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
- if(cbind->botid == client->botid && !(cbind->func->flags & CMDFLAG_FUNCMD))
+ if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && !(cbind->func->flags & CMDFLAG_FUNCMD))
bindcount++;
}
struct cmd_binding *binds[bindcount];
bindcount = 0;
for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
- if(cbind->botid == client->botid && !(cbind->func->flags & CMDFLAG_FUNCMD))
+ if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && !(cbind->func->flags & CMDFLAG_FUNCMD))
binds[bindcount++] = cbind;
}
qsort(binds, bindcount, sizeof(struct cmd_binding *), global_cmd_commands_sort);
char caccess[5];
char gaccess[5];
char triggered[10];
+ char funcname[MAXLEN];
+ int funcpos;
for(i = 0; i < bindcount; i++) {
cbind = binds[i];
content[0] = cbind->cmd;
content[1] = caccess;
sprintf(gaccess, "%d", global_cmd_commands_operaccess(cbind));
content[2] = gaccess;
- sprintf(triggered, "%d", cbind->func->triggered);
+ sprintf(triggered, "%d", cbind->triggered);
content[3] = triggered;
- content[4] = cbind->func->name;
+ funcpos = sprintf(funcname, "%s", cbind->func->name);
+ if(cbind->paramcount) {
+ int j;
+ for(j = 0; j < cbind->paramcount; j++) {
+ funcpos += sprintf(funcname + funcpos, " %s", cbind->parameters[j]);
+ }
+ }
+ content[4] = funcname;
table_add(table, content);
}
//send the table
for(i = 0; i < table->entrys; i++) {
reply(getTextBot(), user, table_lines[i]);
}
-
+ table_free(table);
}
static int global_cmd_commands_sort(const void *a, const void *b) {
*str_b = '\0';
str_b++;
}
+ if(*str_a == '@' || *str_a == '+') {
+ //privs can override this access requirement
+ str_a++;
+ }
if(*str_a == '#') {
str_a++;
access_pos += sprintf(access_list+access_pos, (access_pos ? ", `%s`" : "`%s`"), str_a);