# 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 . require 'securerandom' 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("🧀") if Database.server_blacklisted?(event.server.id) puts "[DEBUG] Ignored: Server #{event.server.name} is blacklisted." next end if Database.user_blacklisted?(event.user.id) puts "[DEBUG] Ignored: User #{event.user.id} is blacklisted." next end begin view = Discordrb::Webhooks::View.new view.row do |r| r.button( label: "Toggle Blacklist", style: :secondary, custom_id: "toggle_cheese_blacklist" ) end random_color = ("0x" + Random.bytes(3).unpack1('H*')).to_i(16) author = event.user embed_generated = { title: "Cheese detected!", description: cheese_content, color: random_color, timestamp: Time.now.iso8601, footer: { text: "Click the button to stop these messages." } } # send_message(content, tts, embed, attachments, allowed_mentions, message_reference, components) event.user.pm.send_message(nil, false, [embed_generated], nil, nil, nil, view) rescue Discordrb::Errors::NoPermission puts "Could not DM user #{event.user.username} (#{event.user.id})" end end end end