Finished writing the main function. Detects cheese keywords in messages and added user/server blacklist/whitelist.

This commit is contained in:
2026-01-12 16:05:48 -03:00
parent 903ccf91b2
commit c8e77e1cff
7 changed files with 368 additions and 7 deletions

View File

@@ -0,0 +1,50 @@
# cheeseBot
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
require_relative '../modules/cheese_checker'
require_relative '../modules/database'
module MessageCheck
def self.register(bot)
bot.message do |event|
next if event.user.bot_account || event.server.nil?
cheese_content = CheeseChecker.check_content(event.content)
next unless cheese_content
event.message.react("🧀")
next if Database.server_blacklisted?(event.server.id)
next if Database.user_blacklisted?(event.user.id)
begin
event.user.pm.send_embed do |embed|
embed.title = "Cheese Detected!"
embed.description = cheese_content
embed.color = rand(0xFFFFFF)
embed.timestamp = Time.now
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
text: "Use /blacklist to not receive DMs anymore"
)
end
rescue Discordrb::Errors::NoPermission
puts "Could not DM user #{event.user.username} (#{event.user.id})"
end
end
end
end