mIRC Home    About    Download    Register    News    Help

Print Thread
#205456 23/10/08 05:43 PM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
I want to display random announcements in the channel every 20 minutes or so. The bot gets the announcements from a TXT file and returns a random line using $read. Problem is, how do I go about doing that, exactly?

If I used...
Code:
on *:text:*:#chan: { timer 1 1200 msg $chan $read(file.txt) }


mIRC would activate a crap load of timers and later on we'd be flooded with announcements. smirk

Joe_Dean #205457 23/10/08 05:51 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Originally Posted By: Joe_Dean

mIRC would activate a crap load of timers and later on we'd be flooded with announcements



You could name the timer and only start it if it's not already running. Try this...

Code:

on *:TEXT:*:#chan: {
  if (!$timer(Announce)) timerAnnounce 0 1200 msg # $!read(file.txt,n)
}


RoCk #205462 23/10/08 06:34 PM
Joined: Sep 2007
Posts: 202
F
Fjord artisan
Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
why not just

alias announce {
timer 1 1200 msg $chan $read(file.txt)
}

firefox #205470 23/10/08 10:48 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Because you're not using the ! in the $read, your timer will always msg the same line, and .timername should be used.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
firefox #205473 24/10/08 12:13 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Additionally, the 1 in the timer line means that it would execute only once, not every 20 minutes.

firefox #205484 24/10/08 03:50 AM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
! in this instance makes mirc evaluate the identifier when the timer goes off instead of @ the initial command.

Joe_Dean #205500 24/10/08 02:43 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
Originally Posted By: Joe_Dean
I want to display random announcements in the channel every 20 minutes or so. The bot gets the announcements from a TXT file and returns a random line using $read. Problem is, how do I go about doing that, exactly?

If I used...
Code:
on *:text:*:#chan: { timer 1 1200 msg $chan $read(file.txt) }


mIRC would activate a crap load of timers and later on we'd be flooded with announcements. smirk


Why have a random announcement controlled by chat in the channel?

Code:
on me:*:join:#channel: { timer $+ . $+ #channel 1 1200 msg #channel $read(file.txt)


This gives you a unique timer (timer.#channel) and announces every 20 minutes based on the time the bot actually joins the channel.


I refuse to engage in a battle of wits with an unarmed person. wink

Link Copied to Clipboard