As has been told multiple times, you don't need to pass $chan to an alias from that event. And a while is a little better than using IF + GOTO.

To the OP...

Code:
on me:*:join:#: {
  .timerRandSaying 0 7200 msg $chan $!read(random.txt)
}


That will send a random line of text from the text file once every 12 minutes (720 seconds). That would be 10 times in 2 hours. If you want it done more often, you can make it more complicated by tracking every line, which is what RussellB was showing...

Code:
on me:*:join:#: {
  .timer 0 300 RandomText
}

alias RandomText {
  var %line = $rand(1,$lines(Random.txt))
  while ($($+(%,Random.,%line),2) >= 10) {
    var %line = $rand(1,$lines(Random.txt))
  }
  inc -u7200 %Random. $+ %line
  msg $chan $read(Random.txt,%line)
}


Note that the on JOIN is optional. You can just use the alias whenever you want with /RandomMessage . If you want to adjust the timer in the second one, change the 300 to whatever you want. 300 = every 5 minutes.

NOTE: It is very important when using either RussellB's code or my second code that your text file containing the random lines has a decent number of lines of text in it. If you only have one or two lines, it's possible to loop over and over because you're reading the same line multiple times. This really won't be much of an issue if you use the timer set to 5 minutes if you have at least 2 lines because no line will be used more than 10 times except unless 10 out of 12 times one of the two lines are used, which will be rare. If you only have 1 line, it will be an endless loop after the 10th display. It will really become an issue if you just use the alias or lower the timer delay because you can display messages a lot of times within 2 hours and if you use up your lines, it will be an endless loop. If you have at least 10 lines, you shouldn't have to worry unless you really get carried away using the alias. smile