mIRC Home    About    Download    Register    News    Help

Print Thread
Bot output counter #173337 23/03/07 11:38 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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!

Re: Bot output counter [Re: OrionsBelt] #173338 24/03/07 12:56 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: Bot output counter [Re: Riamus2] #173339 24/03/07 01:46 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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) ] ]

Re: Bot output counter [Re: Riamus2] #173345 24/03/07 12:19 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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.

Re: Bot output counter [Re: OrionsBelt] #173346 24/03/07 12:25 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
$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.


Invision Support
#Invision on irc.irchighway.net
Re: Bot output counter [Re: Riamus2] #173350 24/03/07 12:39 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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!