mirror of
https://github.com/alterware/aw-bot.git
synced 2025-10-26 14:15:54 +00:00
feat: black list for memes
This commit is contained in:
@@ -3,7 +3,7 @@ from typing import Literal
|
||||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
from database import add_pattern
|
||||
from database import add_pattern, add_user_to_blacklist
|
||||
|
||||
from bot.config import update_patterns
|
||||
from bot.utils import compile_stats, fetch_game_stats, perform_search
|
||||
@@ -44,6 +44,21 @@ async def setup(bot):
|
||||
f"Pattern added!\n**Regex:** `{regex}`\n**Response:** `{response}`"
|
||||
)
|
||||
|
||||
@bot.tree.command(
|
||||
name="add_to_blacklist",
|
||||
description="Add a user to the blacklist.",
|
||||
guild=discord.Object(id=GUILD_ID),
|
||||
)
|
||||
@app_commands.checks.has_permissions(administrator=True)
|
||||
async def add_to_blacklist_cmd(
|
||||
interaction: discord.Interaction, user: discord.User, reason: str
|
||||
):
|
||||
"""Slash command to add a user to the blacklist."""
|
||||
add_user_to_blacklist(user.id, reason)
|
||||
await interaction.response.send_message(
|
||||
f"User **{user.name}** has been added to the blacklist.\n**Reason:** `{reason}`"
|
||||
)
|
||||
|
||||
@bot.tree.command(
|
||||
name="search",
|
||||
description="Search for servers by hostname or IP.",
|
||||
|
||||
@@ -5,7 +5,7 @@ import discord
|
||||
from bot.utils import timeout_member, aware_utcnow
|
||||
from bot.config import message_patterns
|
||||
|
||||
from database import add_user_to_role
|
||||
from database import add_user_to_role, is_user_blacklisted
|
||||
|
||||
BOT_LOG = 1112049391482703873
|
||||
|
||||
@@ -15,6 +15,7 @@ crazy_last_response_time = None
|
||||
|
||||
ALLOWED_CHANNELS = [
|
||||
1110531063744303138, # GENERAL_CHANNEL
|
||||
1112048063448617142, # off-topic
|
||||
1145458108190163014, # mw2 general
|
||||
1145456435518525611, # mw2 mp
|
||||
1112016681880014928, # mw2 sp
|
||||
@@ -327,6 +328,9 @@ async def handle_message(message, bot):
|
||||
if message.channel.id not in ALLOWED_CHANNELS:
|
||||
return
|
||||
|
||||
if is_user_blacklisted(message.author.id):
|
||||
return
|
||||
|
||||
# Check if any of the patterns match the message
|
||||
# print('Checking for patterns...')
|
||||
for pattern in message_patterns:
|
||||
|
||||
Reference in New Issue
Block a user