Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:27:39+00:00 2026-06-01T09:27:39+00:00

I run an irc bot, written in ruby, running the cinch irc framework. The

  • 0

I run an irc bot, written in ruby, running the cinch irc framework. The bot replies with interesting facts and cycles through these facts so you won’t get bored of them. I have set a cool down, so they can’t be shown for 6 hours. Instead of showing the facts it first showed, it now shows randomly selected ones, which could be the ones that have been shown earlier.

line = IO.readlines("facts.txt")
factnumber = rand(line.length)
    if fact_not_next_6_hours[factnumber] == true
    factnumber = rand(line.length)
    m.reply "fact #{factnumber}: #{line[factnumber]}"
    fact_not_next_6_hours[factnumber] = true

fact_not_next_6_hours[factnumber] is the variable for the 6 hour cool down; if it’s set to true, cool down is active. I need to do:

factnumber = rand(line.length) 

until it gets one that dosen’t have the 6 hour cool down set to true, and then do

m.reply "fact #{factnumber}: #{line[factnumber]}"
fact_not_next_6_hours[factnumber] = true

My first idea was to do multiple ifs, but it didn’t work and I’m sure there is a better way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:27:40+00:00Added an answer on June 1, 2026 at 9:27 am

    You can do:

    factnumber = rand(line.length)
    while fact_not_next_6_hours[factnumber] == true
      factnumber = rand(line.length)
    end
    m.reply "fact #{factnumber}: #{line[factnumber]}"
    fact_not_next_6_hours[factnumber] = true
    

    Or:

    nil while fact_not_next_6_hours[factnumber = rand(line.length)] == true
    m.reply "fact #{factnumber}: #{line[factnumber]}"
    fact_not_next_6_hours[factnumber] = true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run an irc bot with cakephp. My problem is referencing the
I have made my IRC bot and I've run into the problem of flooding.
I run a game and the running is done by hand, I have a
I run a rather complex project with several independent applications. These use however a
We run an old Windows NT Machine, fully patched running IIS4.0. Today we were
I'm trying to develop a simple IRC bot. First I want to think out
This is a sample script. When I hit Ctrl+C, the bot quits IRC but
I'm writing an IRC bot in Python, due to the alpha nature of it,
Run into a rather interesting problem. An element generated as html and inserted into
I'm building an IRC bot in Python for fun. It is supposed to accept

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.