added support for an external statistics script
[NeonServV5.git] / src / modcmd.c
index 6b769eac56c6b2017cac2268cd3854d1e907148c..b20a39e26dc40e5e9fcf8e3e90f83723c9cc135f 100644 (file)
@@ -57,6 +57,7 @@ static struct cmd_function *cmd_functions = NULL;
 static struct trigger_callback *trigger_callbacks = NULL;
 static struct cmd_bot_alias *bot_aliases = NULL;
 static struct ClientSocket *tmp_text_client;
+int statistics_commands = 0;
 
 static const struct default_language_entry msgtab[] = {
     {"MODCMD_LESS_PARAM_COUNT", "This command requires more parameters."},
@@ -153,6 +154,13 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
     struct cmd_binding *cbind;
     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
         if(cbind->botid == client->botid && stricmp(cbind->cmd, message) == 0) {
+            if(statistics_enabled)
+                statistics_commands++;
+            if((cbind->func->flags & CMDFLAG_FUNCMD)) {
+                if(!sent_chan)
+                    break;
+                chan = sent_chan;
+            }
             //get a text bot
             tmp_text_client = get_prefered_bot(client->botid);
             //parse the arguments...
@@ -768,7 +776,7 @@ void bind_unbound_required_functions(int botid) {
     }
 }
 
-void register_bot_alias(int botid, char *alias) {
+void register_command_alias(int botid, char *alias) {
     struct cmd_bot_alias *botalias;
     for(botalias = bot_aliases; botalias; botalias = botalias->next) {
         if(!stricmp(botalias->alias, alias))
@@ -785,3 +793,20 @@ void register_bot_alias(int botid, char *alias) {
     bot_aliases = botalias;
 }
 
+struct cmd_binding *getAllBinds(struct cmd_binding *last) {
+    int bind_index;
+    if(last) {
+        if(last->next)
+            return last->next;
+        bind_index = get_binds_index(last->cmd[0]) + 1;
+        if(bind_index > 26)
+            return NULL;
+    } else
+        bind_index = 0;
+    do {
+        if(cmd_binds[bind_index])
+            return cmd_binds[bind_index];
+        bind_index++;
+    } while(bind_index < 27);
+    return NULL;
+}