From 9d03e8ed6f5d3086bf04b0304c26189c80be3fdd Mon Sep 17 00:00:00 2001 From: fzorb Date: Thu, 3 Oct 2024 09:04:32 +0300 Subject: [PATCH] update gitignore --- .gitignore | 2 +- bot.rb | 27 ++++++++++++++++++++++++++- jon.sqlite | Bin 8192 -> 8192 bytes 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d49608e..d9b0090 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .env -jon.db +jon.sqlite Gemfile.lock diff --git a/bot.rb b/bot.rb index 337127d..adc7aa1 100644 --- a/bot.rb +++ b/bot.rb @@ -14,6 +14,14 @@ bot.message do |event| end bot.command :addquote do |event, *message| + if message[0] == nil + event.channel.send_message("You haven't specified a category for your quote.") + return + end + if message[1] == nil + event.channel.send_message("I can't quote air!") + return + end category = message[0] quote = message[1..].join(" ") event.channel.send_message("I'm adding the quote '#{quote}' under the category #{category}") @@ -23,8 +31,25 @@ end bot.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 + end quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category]) - event.channel.send_message(quotes.sample[3]) + quote = quotes.sample + event.channel.send_message("##{quote[0]}: #{quote[3]}") + nil +end + +bot.command :categories do |event, *message| + categories = db.execute("SELECT DISTINCT category FROM quotes") + event.channel.send_message("**Categories**: #{categories[0..].join(' ')}") + nil +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.message.delete nil end diff --git a/jon.sqlite b/jon.sqlite index 21d147a47fe8f7c3e9988ca6e4266dd6cb47aa6c..a8245136ee01b959ed31d9533a8becc74ef0af68 100644 GIT binary patch literal 8192 zcmeI1O>7%Q6vv&?Ce4TKmei!7(7vQmK1!Q-KfLQLgf>k!i4`Xfi39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