From 93b88dfeb6c67ac71e2f94f6c56f0a1a223b01ef Mon Sep 17 00:00:00 2001 From: fzorb Date: Thu, 3 Oct 2024 08:17:41 +0300 Subject: [PATCH] add quotes and stuff --- .gitignore | 2 ++ Gemfile | 3 +++ bot.rb | 31 +++++++++++++++++++++++++++++++ jon.sqlite | Bin 0 -> 8192 bytes 4 files changed, 36 insertions(+) create mode 100644 Gemfile create mode 100644 bot.rb create mode 100644 jon.sqlite diff --git a/.gitignore b/.gitignore index 4c49bd7..d49608e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .env +jon.db +Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f399110 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +gem 'dotenv', groups: [:development, :test] +gem 'discordrb' +gem 'sqlite3' diff --git a/bot.rb b/bot.rb new file mode 100644 index 0000000..337127d --- /dev/null +++ b/bot.rb @@ -0,0 +1,31 @@ +require 'discordrb' +require 'dotenv' +require 'sqlite3' + +Dotenv.load + +bot = Discordrb::Commands::CommandBot.new token: ENV['TOKEN'], client_id: ENV['CLIENT_ID'], prefix: ENV['PREFIX'] +db = SQLite3::Database.new("jon.sqlite") + +bot.message do |event| + if ENV['FORBIDDEN_WORDS'].split(",").any? { |word| event.message.content.downcase.include?(word.downcase)} + event.author.pm("Garfield, watch your tone!") + end +end + +bot.command :addquote do |event, *message| + category = message[0] + quote = message[1..].join(" ") + event.channel.send_message("I'm adding the quote '#{quote}' under the category #{category}") + db.execute("INSERT INTO quotes (author, category, quote) VALUES (?, ?, ?)", [event.author.id, category, quote]) + nil +end + +bot.command :quote do |event, *message| + category = message[0] + quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category]) + event.channel.send_message(quotes.sample[3]) + nil +end + +bot.run diff --git a/jon.sqlite b/jon.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..21d147a47fe8f7c3e9988ca6e4266dd6cb47aa6c GIT binary patch literal 8192 zcmeI#F-yZh6bJCT8WmeY1SzH4BTG{dm%6z$>M6k(HKt(4RHF^r#wORH4uXCMKaGQn zpTpg6;iYXxOTkI_KknsTa_@5Cx8?G}jb%i)NjeB6wb&-(oVAGDu z6bt4G+j$!4s(~B3ObrACAOHafKmY;|fB*y_009U<;NJ+mIDEZUuk+V|40{jJXq?C> zn_Wu>zOVy9fxYhvGG`A>vh?zX8Q+-Xc!4+;K6z&Wc^%i?&KJV5>?i3ji`Suy?viw3 zQXsC>rujxX6i0T)4XDwWzGHgQ;+}KgIko*Roro@3`PVe{ax?!o*Nl5+d>bFen<@|x zfB*y_009U<00Izz00bZa0SNp>z|vOPT6NEOfBtHHwplNo3}ru}$1sx=XA}>qxV2W6 S?kp|aS>>v8t5%#I&Ep46YH^ML literal 0 HcmV?d00001