mIRC Homepage
Posted By: synth7 Random line from log from a certain user - 15/07/05 06:21 PM
Right now, I have a trigger so that when someone says @log, I'll say a certain line from the logs I have for that day. Here's what I have for that, because it may help with my problem, may not.

Code:
alias todayslog {
  return $logdir $+ $network $+ \ $+ $chan $+ . $+ $time(yyyymmdd) $+ .log
}

on *:TEXT:*:#digitaltoxicity: {
  if (@log isincs $1 && !$checkdelay(log)) { msg $chan $read($todayslog) | $delay(10,log) }
}


(Don't mind the $checkdelay and $delay, those are for trigger spam protection.)

Anyways, here's my dilemma. I want to make a trigger especially for one person in the channel. So when someone says @sour, it will look in $todayslog, and say a random line that 'sour' says. I tried this next bit of code, but it didn't work frown

Code:
on *:TEXT:*:#digitaltoxicity: {
  if (@log isincs $1 && !$checkdelay(log)) { msg $chan $read($todayslog, nw, *<sour>* ) | $delay(10,log) }
}


All that did was output the first line containing <sour> and not a random one like I had hoped. On a second reading though of the help documentation of $read() I noticed that it seems to only look for the first line. So, is what I want to do easily achieved, or no?
Posted By: Sigh Re: Random line from log from a certain user - 15/07/05 06:29 PM
Use /filter to get all matching lines to another file (or @window):

Code:
/filter -ffc $+(",$todayslog,") temp.txt *&lt;sour&gt;*


Then $read(temp.txt,n) to get a random line from it

*<sour>* could also locate <sour> in the middle of other people's messages. If you're worried about this you could improve your wildmatch to '& <sour> *' (for example) where & may represent your timestamp
Posted By: synth7 Re: Random line from log from a certain user - 15/07/05 08:04 PM
Thanks, that did it
© mIRC Discussion Forums