Added cuss words as a txt file that cahces at bot startup. Also some regex stuff in there so it doesn't care about capitalization etc.
This commit is contained in:
39
Main.py
39
Main.py
@@ -5,6 +5,7 @@ from dotenv import load_dotenv
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import sqlite_utils
|
import sqlite_utils
|
||||||
|
import re
|
||||||
|
|
||||||
# Show the path we expect to load
|
# Show the path we expect to load
|
||||||
# Explicitly find the .env file in the same directory as the script
|
# Explicitly find the .env file in the same directory as the script
|
||||||
@@ -23,6 +24,15 @@ print(f"Loaded token Succesfully")
|
|||||||
if token is None:
|
if token is None:
|
||||||
raise RuntimeError(".env file not loaded or DISCORD_TOKEN not set.")
|
raise RuntimeError(".env file not loaded or DISCORD_TOKEN not set.")
|
||||||
|
|
||||||
|
# --- Load bad words from file into a set ---
|
||||||
|
with open("bad_words.txt", "r", encoding="utf-8") as f:
|
||||||
|
BAD_WORDS = {line.strip().lower() for line in f if line.strip()}
|
||||||
|
|
||||||
|
# Compile regex pattern for performance
|
||||||
|
# \b = word boundary, (?i) = case-insensitive
|
||||||
|
bad_words_pattern = re.compile(r"\b(" + "|".join(map(re.escape, BAD_WORDS)) + r")\b", re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
token = os.getenv("DISCORD_TOKEN")
|
token = os.getenv("DISCORD_TOKEN")
|
||||||
|
|
||||||
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
|
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
|
||||||
@@ -47,14 +57,17 @@ async def on_ready():
|
|||||||
async def on_member_join(member):
|
async def on_member_join(member):
|
||||||
await member.send(f"Welcome to the server {member.name}")
|
await member.send(f"Welcome to the server {member.name}")
|
||||||
|
|
||||||
|
#Responding to cuss words
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
if message.author == bot.user:
|
if message.author == bot.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
if "shit" in message.content.lower():
|
# Check if message contains a bad word
|
||||||
#await message.delete()
|
if bad_words_pattern.search(message.content):
|
||||||
await message.channel.send(f"{message.author.mention} - bro thats a bad worddddd!")
|
await message.channel.send(
|
||||||
|
f"{message.author.mention} - bro that’s a bad worddddd!"
|
||||||
|
)
|
||||||
|
|
||||||
await bot.process_commands(message)
|
await bot.process_commands(message)
|
||||||
|
|
||||||
@@ -150,22 +163,4 @@ async def points(ctx, member: discord.Member = None):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bot.run(token, log_handler=handler, log_level=logging.DEBUG)
|
bot.run(token, log_handler=handler, log_level=logging.DEBUG)
|
||||||
|
|
||||||
#Aaron is fun but dumb
|
|
||||||
#Didn't I say that Already "NO YOu SAiD BlAH BLaaah" Oh Wait I'm wrong babooo boo
|
|
||||||
|
|
||||||
# AAron doesn't pay attention
|
|
||||||
# John doesn't read the manual
|
|
||||||
#another example comment
|
|
||||||
# AAron does pay attention
|
|
||||||
# John doesn't read the manual - true
|
|
||||||
|
|
||||||
|
|
||||||
#wazzzzzzup
|
|
||||||
# //testy
|
|
||||||
|
|
||||||
|
|
||||||
# John make comment now
|
|
||||||
#Johms fault
|
|
||||||
# Aaron can suck these nuts. Hi Josh
|
|
||||||
33
bad_words.txt
Normal file
33
bad_words.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
ass
|
||||||
|
asshole
|
||||||
|
bastard
|
||||||
|
bitch
|
||||||
|
bollocks
|
||||||
|
bugger
|
||||||
|
bullshit
|
||||||
|
crap
|
||||||
|
cunt
|
||||||
|
damn
|
||||||
|
dick
|
||||||
|
douche
|
||||||
|
fag
|
||||||
|
faggot
|
||||||
|
fuck
|
||||||
|
fucker
|
||||||
|
fucking
|
||||||
|
goddamn
|
||||||
|
hell
|
||||||
|
horseshit
|
||||||
|
jackass
|
||||||
|
jerk
|
||||||
|
motherfucker
|
||||||
|
piss
|
||||||
|
prick
|
||||||
|
pussy
|
||||||
|
shit
|
||||||
|
shithead
|
||||||
|
slut
|
||||||
|
sonofabitch
|
||||||
|
twat
|
||||||
|
wanker
|
||||||
|
whore
|
||||||
Reference in New Issue
Block a user