From 36b2ae7ef3d130114867f3739cdd3c529bc3703f Mon Sep 17 00:00:00 2001 From: fzorb Date: Fri, 4 Oct 2024 09:59:00 +0300 Subject: [PATCH] add showquote & change categories to quotecategories --- bot.rb | 2 +- systems/quote.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bot.rb b/bot.rb index e28ad52..57d0609 100644 --- a/bot.rb +++ b/bot.rb @@ -13,7 +13,7 @@ bot.message do |event| 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! \n\n**Quote system**\n```;quote - displays a quote from the category\n;addquote - adds a quote into a category\n;categories - shows all categories```") + 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! \n\n**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```") event.message.delete nil end diff --git a/systems/quote.rb b/systems/quote.rb index 460722a..c1cdf69 100644 --- a/systems/quote.rb +++ b/systems/quote.rb @@ -31,9 +31,19 @@ module QuoteSystem nil end - command :categories do |event, *message| + command :quotecategories do |event, *message| categories = db.execute("SELECT DISTINCT category FROM quotes") event.channel.send_message("**Categories**: #{categories[0..].join(' ')}") nil end + + command :showquote do |event, *message| + quote = db.execute("SELECT * FROM quotes WHERE id = ?", [message[0]]) + if quote == nil + event.channel.send_message("Quote doesn't exist") + return + end + event.channel.send_message("##{quote[0][0]}: #{quote[0][3]}") + nil + end end \ No newline at end of file