show how many times a command is triggered in cmd_commands
[NeonServV5.git] / src / modcmd.c
index 856da055dcf314d4b4b1f5aa1f6d33746098577c..ecb788adce3586d542c1c6d024074a4bc88f11ad 100644 (file)
@@ -57,6 +57,8 @@ 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;
+static int total_triggered = 0;
+int statistics_commands = 0;
 
 static const struct default_language_entry msgtab[] = {
     {"MODCMD_LESS_PARAM_COUNT", "This command requires more parameters."},
@@ -153,6 +155,10 @@ 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++;
+            total_triggered++;
+            cbind->func->triggered++;
             if((cbind->func->flags & CMDFLAG_FUNCMD)) {
                 if(!sent_chan)
                     break;
@@ -478,6 +484,7 @@ int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, ch
     cmdfunc->paramcount = paramcount;
     cmdfunc->channel_access = channel_access;
     cmdfunc->global_access = global_access;
+    cmdfunc->triggered = 0;
     cmdfunc->next = cmd_functions;
     cmd_functions = cmdfunc;
     return 1;