mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2011
Posts: 32
F
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2011
Posts: 32
This is for a chatter/"atmosphere" bot that establishes a bar motif for a channel. When there's activity in the channel, the bot simply sits there and responds to keywords and keyphrases. What I'd like to add is some "idle time" activities - if the channel goes quiet for a period, the bot does something like "grabs a rag and polishes the bar to a gloss", and then goes into a new idle loop for a random amount of time within certain limits. I can handle the actual actions; I've got that part of the code working for other purposes already. It's the "idle time" activity that I can't seem to get my teeth into.

Problem 1: How to, in essence, start a timer to measure idle time, and have that timer stopped and reset if there's any channel activity.

Problem 2: How to have the repeat interval for the timer not be a constant - in other words, not "every ten minutes", but "ten minutes the first time, then eight minutes plus a random amount of time (between 0 and 250 seconds), recalculated each time"

I'm not, at this point, asking for actual code; I'm a perfectly competent programmer - just need the technique "hooks" to get started on this in mIRCscript.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
If you give a name to your timer, every time you [re]set a timer with the same name, the old timer gets destroyed. This will enable you to create a stateless random event by simply setting the timer every time someone speaks.

On *:TEXT:*:#cheers: {
  .timer_bartender 1 $r(600,3600) _timer_bartender $chan
}

Alias _timer_bartender {
  describe $1 $read(bartender.txt,n)
  .timer_bartender 1 $r(1800,7200) _timer_bartender $1
}


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Sep 2011
Posts: 32
F
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Sep 2011
Posts: 32
OK, thanks - this looks like it will do the trick for me (I'm assuming that $r() is actually $rand(), here). I thought I'd done something like this previously, back about version 6.21 or so, but had to kill it because I found that it defecated on itself, apparently because of poor garbage collection. I'll fiddle a little and try it with 7.41...

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Aye, $r() is a valid short form of $rand() that isn't going away, so feel free to use it. smile

Also, if you intend to use my above example, you can easily purpose it for multiple channels by changing:

.timer_bartender 1 ...

to

.timer_bartender $+ $cid $+ $chan 1 ...
.timer_bartender $+ $cid $+ $1 1 ...

respectively.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard