On approach 2, you're getting the wrong chan because you're doing your processing in an alias. If you notice the difference between #1 and #2 is that in #1 you pass the $chan into the msg command from the on TEXT event, whereas in #2 you give it $chan inside the alias. With timers, by the time the timer fires, it has forgotten what $chan means in context to your script, so it uses a different $chan (I forget what the rules for picking the other chan are).
To fix this, pass the $chan into your alias like:
on *:TEXT:!automode2:#: {
if ( $nick == hljiu) {
msg $chan Starting automode.
.timerLinks 0 30 myAlias $chan
}
}
alias myAlias {
var %chan = $$1
var %linenum = $r(1,34)$
msg %chan $read(facts.txt, n, %linenum )
}
*I am not saying that this is the better solution to your problem. Only trying to inform you as to why it was messaging the wrong $chan.