m1ndl3ss commented on a Page, Quote Script  -  Oct 23, 2013

I am having trouble with what I think should be a simple script...I have a text file which contains one quote per line. I want to randomly read a quote once per hour in the channel I am an op for. Here is what I have;
on *:JOIN:#:{
/timergreet 0 3600 /msg $chan - Quote of the Day: $read(biqquotes.txt)
}
Where the problem is, it randomly selects one quote initially, but then will repeat the same quote it originally selected. How can I get it to randomly select a quote the 2nd and 3rd, etc time after the first selection?

Vegito  -  Oct 23, 2013

Do you want it to read a random quote everytime someone joins?
Quote of the day should change daily right?

m1ndl3ss  -  Oct 23, 2013

Yes, I figured it out... in the $read function, if you make it $!read it forces it to re-evaluate (in this case pick a new random line) every time. Woo Hoo!!!!

KilllerX  -  Oct 23, 2013

3600 is 3600 seconds, which translates to 60 minutes, translating to 1 hour. Do you just want a different message each join? Or different message each day?

.timerquote 86400 .set %dailyQuote $rand(0,$!lines(bigquotes.txt)) - this will read how many lines are in, and choose a random one from the 0th (first) line, and the last line in bigquotes.

Then you can do

msg # $read(bigquotes.txt, %dailyQuote)

I would have these sperate, as setting the greet, is requested upon someone joining.

Alias DailyQuote {
  set %dailyQuote $rand(0,$!lines(bigquotes.txt))
 .timerquote 86400 set %dailyQuote $rand(0,$!lines(bigquotes.txt))
} 

-this will set it upon use then every day (if you keep the bot running 24/7 will reset the daily quote.

ON !*:JOIN:*:{
 if (!%qotdFlood) {
 msg # Quote of the Day - $read(bigquotes.txt, %dailyQuote) | .inc %qotdFlood -z 60
 }
}

The .inc is for a flood protections so if 20 people join at once, it doesn't spam it. It can only be said, omn a join once a minute.

and so you know, inside the actual code. You don't need all the / and . Although infront of the timer to my knowledge makes the event 'silent' or that it won't post it. # is the same as $chan.

If you use this. and you put the Alias in your 'alias' file, MAke sure you don't have Alias, So I would put it in the remote with the Alias. Then on

KilllerX  -  Oct 23, 2013

To start the setting of it. You would have to type /DailyQuote in the bots talk bar. Oh, ok. You did say once an hour. So, yes 3600 is an hour. Use that instead of the 86400. And I would change the "Quote of the Day" to something more like "Quote of the Hour."

Vegito  -  Oct 23, 2013

For quote of the day
This works also if bot is not 24/7 online .

if ($1 = !qotd) {
  if (%date != $date) var -g %date $v2, %qotd %rx 
  msg # 10Quote of the the Day: 12 $+ $read(%file, n, %qotd) 
}
Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.