Update regex to close #59
This commit is contained in:
parent
4b32493cc8
commit
d2cf3549ec
2 changed files with 13 additions and 5 deletions
|
@ -25,7 +25,8 @@ intents.members = True
|
|||
restart_ctx = None
|
||||
|
||||
invites = re.compile(
|
||||
r"(https?://)?(www.)?(discord.(gg|io|me|li)|discordapp.com/invite)/([^\s/]+?)(?=\b)"
|
||||
r"(https?://)?(www.)?(discord.(gg|io|me|li)|discord(app)?.com/invite)/([^\s/]+?)(?=\b)",
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
|
@ -92,7 +93,7 @@ async def on_member_join(user: Member):
|
|||
async def on_message(message: Message):
|
||||
if (
|
||||
not isinstance(message.channel, DMChannel)
|
||||
and not message.author.id == get_config().client_id
|
||||
and message.author.id != jarvis.user.id
|
||||
):
|
||||
autoreact = db.jarvis.autoreact.find_one(
|
||||
{"guild": message.guild.id, "channel": message.channel.id}
|
||||
|
@ -192,9 +193,16 @@ async def on_message(message: Message):
|
|||
)
|
||||
if autopurge:
|
||||
await message.delete(delay=autopurge["delay"])
|
||||
matches = invites.match(message.content)
|
||||
content = re.sub(r"\s+", "", message.content)
|
||||
content = re.sub(r"[^\w\s]", "", content)
|
||||
matches = invites.match(content)
|
||||
if matches:
|
||||
if matches.group(5) not in ["dbrand", "VtgZntXcnZ"]:
|
||||
guild_invites = await message.guild.invites()
|
||||
allowed = [x.code for x in guild_invites] + [
|
||||
"dbrand",
|
||||
"VtgZntXcnZ",
|
||||
]
|
||||
if matches.group(6) not in allowed:
|
||||
await message.delete()
|
||||
db.jarvis.warns.insert_one(
|
||||
{
|
||||
|
|
|
@ -357,7 +357,7 @@ class ModlogCog(commands.Cog):
|
|||
async def on_message_edit(
|
||||
self, before: discord.Message, after: discord.Message
|
||||
):
|
||||
if before.author != self.bot.client.id:
|
||||
if before.author != self.bot.user.id:
|
||||
modlog = self.db.jarvis.settings.find_one(
|
||||
{"guild": after.guild.id, "setting": "modlog"}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue