}
}
+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] == '#') {
}
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';
if(cbind->func->func == modcmd_linker) {
cbind = modcmd_linker_command(client, textclient, user, cbind, bind_index, &args);
if(cbind == NULL) break;
- }
+ } else if(cbind->flags & CMDFLAG_SUB_LINKER)
+ cbind = modcmd_sub_linker_command(client, textclient, user, cbind, bind_index, &args);
if(statistics_enabled)
statistics_commands++;
total_triggered++;
#define MAXPARAMETERS 50
-#define CMDFLAG_REQUIRE_CHAN 0x0001
-#define CMDFLAG_REQUIRE_AUTH 0x0002
-#define CMDFLAG_REQUIRE_GOD 0x0004
-#define CMDFLAG_CHECK_AUTH 0x0008
-#define CMDFLAG_REGISTERED_CHAN 0x0010
-#define CMDFLAG_OVERRIDE_GLOBAL_ACCESS 0x0020
-#define CMDFLAG_OVERRIDE_CHANNEL_ACCESS 0x0040
-#define CMDFLAG_CHAN_PARAM 0x0080
-#define CMDFLAG_LOG 0x0100
-#define CMDFLAG_OPLOG 0x0200
-#define CMDFLAG_EMPTY_ARGS 0x0400
-#define CMDFLAG_REQUIRED 0x0800
-#define CMDFLAG_TEMPONARY_BIND 0x1000
-#define CMDFLAG_FUNCMD 0x2000
-#define CMDFLAG_ESCAPE_ARGS 0x4000
-#define CMDFLAG_NO_CROSSCHAN 0x8000
+#define CMDFLAG_REQUIRE_CHAN 0x00001
+#define CMDFLAG_REQUIRE_AUTH 0x00002
+#define CMDFLAG_REQUIRE_GOD 0x00004
+#define CMDFLAG_CHECK_AUTH 0x00008
+#define CMDFLAG_REGISTERED_CHAN 0x00010
+#define CMDFLAG_OVERRIDE_GLOBAL_ACCESS 0x00020
+#define CMDFLAG_OVERRIDE_CHANNEL_ACCESS 0x00040
+#define CMDFLAG_CHAN_PARAM 0x00080
+#define CMDFLAG_LOG 0x00100
+#define CMDFLAG_OPLOG 0x00200
+#define CMDFLAG_EMPTY_ARGS 0x00400
+#define CMDFLAG_REQUIRED 0x00800
+#define CMDFLAG_TEMPONARY_BIND 0x01000
+#define CMDFLAG_FUNCMD 0x02000
+#define CMDFLAG_ESCAPE_ARGS 0x04000
+#define CMDFLAG_NO_CROSSCHAN 0x08000
+#define CMDFLAG_SUB_LINKER 0x10000
struct ClientSocket;
struct UserNode;
{"FUNCMD", CMDFLAG_FUNCMD},
{"ESCAPED_ARGS", CMDFLAG_ESCAPE_ARGS}, //allows arguments to be escaped ("a\ b" = "a b" as one argument)
{"NO_CROSSCHAN", CMDFLAG_NO_CROSSCHAN},
+ {"SUB_LINKER", CMDFLAG_SUB_LINKER}, //adds a "quiet" subcommand linker with the binding function as default
{NULL, 0}
};