mIRC Homepage
Posted By: starpossen Execute .bat using !stats - 17/01/08 11:05 PM
I've got pisg for doing my stats, and all works as it should, I use a .bat file for executing the log generator and also for uploading to my site.

My question is:
Is it possible to make a script, where if a predifined user types !dostats
It will ececute the batfile, and then send a messages to the channel saying: Stats updated, have a look at http://blabla.bla

I hope this is possible.
Posted By: Riamus2 Re: Execute .bat using !stats - 17/01/08 11:09 PM
Code:
on *:text:!dostats:#: {
  run batchfilename.bat
  msg $chan Stats updated, check http://www....com/
}


Of course, you'll probably want to limit this to only voiced or opped users or use the userlist levels to limit it to specific user levels. Also, I'm assuming pisg takes awhile to create the file and get it uploaded, so you might want to put a timer on the msg line to send the msg 30-60 seconds (or whatever it takes to get it created/uploaded) after the /run command.
Posted By: starpossen Re: Execute .bat using !stats - 17/01/08 11:49 PM
Thanks for the quick reply, the !dostats would it be possible to add a hostmask for that command, so only 1 user could execute it?
And regarding the timer, the log isn't that big yet, so the generation of stats and uploads takes betqween 2-5 seconds, however, the timer idea sounds clever.

These two things, how would the code look like?
Once again, thanks for the quick reply.

*EDIT* I tried this:
Code:
on *:text:!dostats:#: {
  run d:\server\pisg\pisg.bat
  .timer 1 10 msg $chan Stats updated, check http://blabla.bla/
}

And it works, I know it might not be the best script, but it works.
Now I just need to add a nick or host to the !dostats command
so only a specified host or user can use the command, any help on this? I guess I could add an @ in on *:text:
But i'd really like to make so only one specific user can use it.
Posted By: Riamus2 Re: Execute .bat using !stats - 18/01/08 01:57 AM
The @ wouldn't do anything for you. That only checks to see if the client running the script is an op... not if the person typing the command is an op.

Do something like this:

Code:
on *:text:!dostats:#: {
  if ($address($nick,2) != *!*@host.com) { return }
  run d:\server\pisg\pisg.bat
  .timer 1 10 msg $chan Stats updated, check http://blabla.bla/
}


Or else put the person's host into your Users list and then use a level on the script:

Code:
on 100:text:!dostats:#: {
  run d:\server\pisg\pisg.bat
  .timer 1 10 msg $chan Stats updated, check http://blabla.bla/
}


That would be level 100+ user could access it. You can also use a named level if you want.
Posted By: starpossen Re: Execute .bat using !stats - 22/01/08 07:09 AM
Tahnks alot, after being away from home for a few days, I tried what you suggested and it works perfectly smile

Now, how would I add a timer sayin "Check stats at blahblah.blah"
And make it repeat everyday at midday?
I tried usin the exampl from /help timer :
/timer9 14:30 1 1 /say It's now 2:30pm

changed it to:
/timer9 08:00 1 1 /say Check out the stats at http://blabla.bla/

Added it to remote, but nothing happend, any ideas?
Posted By: Riamus2 Re: Execute .bat using !stats - 22/01/08 11:23 AM
You have the right idea. You just need to either type it from the edit line and hit enter, or add it to an alias and then run the alias, or put the time into an on START event so it starts automatically whenver you start mIRC.

Code:
on *:start: {
  .timerStatAd 8:00 1 1 msg #yourchannel Check out the stats at http://...../
}


Replace the channel name with your channel name. Also note that this will not start the timer until mIRC is restarted unless you manually start the timer from the edit line.
Posted By: starpossen Re: Execute .bat using !stats - 22/01/08 07:26 PM
Works nicely, but I have a weird problem/issue
When I execute my .bat file for pisg which works perfectly
on my server, everything is fine, but if I use the !dostats command from another computer, I can see the .bat file being executed on my server, but it's not updating the stats, like something is blocking
which seems very odd since it's working when I do it manually.

I hope I make sense.
Posted By: Riamus2 Re: Execute .bat using !stats - 22/01/08 09:09 PM
No idea there unless some program (AV/firewall/etc) is blocking it because of permissions. Or maybe it's just not set up correctly.
Posted By: starpossen Re: Execute .bat using !stats - 25/01/08 08:35 PM
Originally Posted By: Riamus2
You have the right idea. You just need to either type it from the edit line and hit enter, or add it to an alias and then run the alias, or put the time into an on START event so it starts automatically whenver you start mIRC.

Code:
on *:start: {
  .timerStatAd 8:00 1 1 msg #yourchannel Check out the stats at http://...../
}


Replace the channel name with your channel name. Also note that this will not start the timer until mIRC is restarted unless you manually start the timer from the edit line.


Im using the on START, but how would I make it so it would announce it without the need to restart it?

I mean repeat it everyday at the same time specified in the script? I thought it already did that, but it doesnt.
Posted By: Riamus2 Re: Execute .bat using !stats - 25/01/08 09:33 PM
Try the -o switch in the timer to make it an offline timer so it's not lost if you disconnect.
Posted By: starpossen Re: Execute .bat using !stats - 26/01/08 06:04 AM
I never really used timers before this, so bare with me the -o switch, would I place it like so:
Code:
on *:start: {
  .timerStatAd -o 8:00 1 1 msg #yourchannel Check out the stats at http://...../
}

Or am I just making stupid guesses? I did read in the /help /timer
but didnt find what i was looking for.
Posted By: Riamus2 Re: Execute .bat using !stats - 26/01/08 09:04 PM
Yeah. Oh, I just noticed one other thing... you told the timer to only repeat once instead of forever. Change the repetitions from 1 to 0.
Posted By: starpossen Re: Execute .bat using !stats - 26/01/08 10:13 PM
Is that the first or the second 1 ?

*EDIT* Unless I misread the helpfile, it would be the first.
Posted By: Riamus2 Re: Execute .bat using !stats - 26/01/08 10:19 PM
Yes, it's the first.
Posted By: starpossen Re: Execute .bat using !stats - 27/01/08 05:21 PM
That change made it spam the message continuesly untill I stopped the timer manually.
Posted By: starpossen Re: Execute .bat using !stats - 30/01/08 10:41 PM
Any help on why it made a massively spam?
I did exactly as told.
Posted By: Reaper Re: Execute .bat using !stats - 30/01/08 10:57 PM
try this
Code:
 on *:start: {
  .timerStatAd -o 8:00 0 1 msg #yourchannel Check out the stats at http://...../
}

Posted By: XTZGZoReX Re: Execute .bat using !stats - 01/02/08 12:31 PM
Heh. It's not the first. It's the second. Setting the first to 0 means it will do it forever every 1 second.
© mIRC Discussion Forums