mIRC Homepage
Posted By: OrionsBelt Bot output counter - 23/03/07 11:38 PM
Hi All,

I'm thinking of a system, that will count the amount of incoming request that my bot receives and processes over a period of time.

<me> !bot-stats
<bot> Last 24 hours: 55 incoming requests
<bot> Total: 5200 incoming requests

The default trigger for all requests is: !command
But many bots use this trigger, so I dont want my bot to count !command if it is not a command that is meant for my bot...

So, is there a way to count the output?
on:INPUT: doesnt work I think, since we're not inputting on the bot. Anyone with good idea's?

Appreciate it, thanks advance!
Posted By: Riamus2 Re: Bot output counter - 24/03/07 12:56 AM
Well, you'll need to have the script determine if the command is for the bot or not.

Basically:
Code:
on *:text:!command *:#: {
  if ($2 == something that means it's for your bot) {
    inc %request.cnt
  }
}


You'd have to figure out what !command * things your bot accepts and include them. Depending how your bot works, you might also use $istok instead of a lot of == comparisons. For a full script to be written from someone here, you'd need to list all possible commands that you want to track for your bot.

Then, just use this for the stats:
Code:
on *:text:!bot-stats:#: {
  msg $chan Total: %request.cnt incoming requests
}


For the 24 hour part, it will be more difficult. You'd basically need to have 24 different variables (one per hour of the day) and add them together (and reset the one you're on before you use it) and rotate through them over and over. It's not an ideal solution, but stats in a 24 hour block are a bit complicated.

Btw, you can also just have your bot /inc the counter whenever it PERFORMS a command rather than basing it on people typing the commands.
Posted By: DJ_Sol Re: Bot output counter - 24/03/07 01:46 AM
Yeah I was thinking you would inc the variable in your actual remote command code. Which would mean for each remote command, you would add the inc. You can name the variable the day if you like. So then you can see how many times the commands were requested for that certain day. May be easier than "in the last 24 hours."

inc %var. [ $+ [ $asctime(ddd) ] ]
Posted By: OrionsBelt Re: Bot output counter - 24/03/07 12:19 PM
Well, the bot as it is, already has A LOT of features and options, so adding a counter to all those remotes is not really handy.

Specifying all possible commands is also difficult, since the bot is changing constantly. Adding new features / removing others.

How about something like:
Code:
on *:TEXT:*:*:{
  if ($nick == $me) && (me.input == $false) {
     inc remote-counter
  }
}


I know the (me.input == $false) doesnt exist.
But is there a way to make this work?
It would be solution for this I think.
Posted By: Riamus2 Re: Bot output counter - 24/03/07 12:25 PM
$nick will never == $me. $nick is the person who triggered it (who typed the command).

Anyhow, you need to either specify what commands you're using, or include the /inc in every command, or have it accept all commands, but only in a given channel (I doubt you have multiple bots in your channel that accept !command commands). Btw, /inc'ing the variable inside each command on the bot is the most accurate method. The other methods all allow for error if someone who can't use a command tries to.

DJ_Sol: The day is a good suggestion. Rather than doing the last 24 hours, do "yesterday's stats" or else "today's stats" instead. That's much easier to work with than 24 hour stats.
Posted By: OrionsBelt Re: Bot output counter - 24/03/07 12:39 PM
Ok, in that case I'm not gonna add it.
It's to much hassle to add that to every remote, and integrate it all current scripts.

Thanks for all replies in any case!
© mIRC Discussion Forums