diff --git a/bot.rb b/bot.rb index a365cfb..cb6e432 100644 --- a/bot.rb +++ b/bot.rb @@ -15,7 +15,7 @@ end bot.command :help do |event, *message| event.author.pm("You've asked for help. In order not to flood the channel where you sent the command, I have sent the list of commands here, in your PMs. Enjoy! -**Quote system**\n```;quote - displays a quote from the category\n;addquote - adds a quote into a category\n;quotecategories - shows all categories\n;showquote - shows the quote with the id provided``` +**Quote system**\n```;quote - displays a quote from the category\n;addquote - adds a quote into a category\n;quotecategories - shows all categories\n;showquote - shows the quote with the id provided``` **Networking related commands**\n```;ip - Display basic information about an IP address. You can input multiple IPs. We are required to state that the information provided by this command comes from the IP2Location database.``` ") diff --git a/systems/quote.rb b/systems/quote.rb index 950226a..91a7ba2 100644 --- a/systems/quote.rb +++ b/systems/quote.rb @@ -26,13 +26,16 @@ module QuoteSystem command :quote do |event, *message| category = message[0] if category == nil - event.channel.send_message("You haven't specified a category from where to fetch a random quote!") - return + quotes = db.execute("SELECT * FROM quotes") + quote = quotes.sample + event.channel.send_message("##{quote[0]} <#{quote[2]}>: #{quote[3]}") + nil + else + quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category]) + quote = quotes.sample + event.channel.send_message("##{quote[0]}: #{quote[3]}") + nil end - quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category]) - quote = quotes.sample - event.channel.send_message("##{quote[0]}: #{quote[3]}") - nil end command :quotecategories do |event, *message|