X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodcmd.c;h=0c1e92e67571f7184904813271b7a6561d30857c;hp=f53a3c22a93bfa88dafc2820c288c7f80599f053;hb=88751acefe20e568fc945d7e5f5c11e0a9c7be60;hpb=fc61be208ca6dbf2fd915591c8dc7e5ef5779891 diff --git a/src/modcmd.c b/src/modcmd.c index f53a3c2..0c1e92e 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -27,6 +27,7 @@ #include "mysqlConn.h" #include "DBHelper.h" #include "EventLogger.h" +#include "tools.h" struct trigger_callback { int botid; @@ -179,6 +180,32 @@ static struct cmd_binding *modcmd_linker_command(struct ClientSocket *client, st } } +static struct cmd_binding *modcmd_sub_linker_command(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct cmd_binding *cbind, int bind_index, char **args_ptr) { + //links subcommands + char command[MAXLEN]; + struct cmd_binding *parent_bind = cbind; + char *args = *args_ptr; + if(args) { + char *subcmd = args; + args = strchr(args, ' '); + if(args) { + *args = '\0'; + args++; + } + sprintf(command, "%s %s", parent_bind->cmd, subcmd); + for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) { + if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && stricmp(cbind->cmd, command) == 0) + break; + } + *args_ptr = args; + if(cbind && cbind->func->func == modcmd_linker) { + return modcmd_linker_command(client, textclient, user, cbind, bind_index, args_ptr); + } + return (cbind ? cbind : parent_bind); + } else + return parent_bind; +} + static void handle_command(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *message) { struct ChanNode *sent_chan = chan; if(message[0] == '#') { @@ -193,7 +220,7 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s } message = strdup(message); int bind_index = get_binds_index(message[0]); - char *args = strstr(message, " "); + char *args = strchr(message, ' '); char *args_buffer = NULL; //we need this to save a possible pointer to a allocation we need to free if(args) { *args = '\0'; @@ -209,9 +236,9 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s if(cbind->func->func == modcmd_linker) { cbind = modcmd_linker_command(client, textclient, user, cbind, bind_index, &args); if(cbind == NULL) break; - } - if(statistics_enabled) - statistics_commands++; + } else if(cbind->flags & CMDFLAG_SUB_LINKER) + cbind = modcmd_sub_linker_command(client, textclient, user, cbind, bind_index, &args); + statistics_commands++; total_triggered++; cbind->triggered++; if((BIND_FLAGS(cbind) & CMDFLAG_FUNCMD)) {