Skip to content

Commit

Permalink
Prevent people from mentioning others in reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ceptoplex committed Apr 30, 2024
1 parent 58c4306 commit 595b98d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/trillbot/extensions/reactionchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


URL_PATTERN = re.compile(r'([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?')
MENTION_PATTERN = re.compile(r"<@&\d+>|<@!\d+>|<@\d+>|@everyone|@here")


class ReactionChannel(Cog):
Expand All @@ -29,6 +30,8 @@ async def on_message(self, message: Message):
await message.delete()
return

message_content = MENTION_PATTERN.sub("", message.content)

files = [await x.to_file() for x in message.attachments]

class ReportModal(Modal, title='Meldung (NICHT ANONYM!)'):
Expand Down Expand Up @@ -68,7 +71,7 @@ async def callback(self, interaction: Interaction):
view = View(timeout=None)
view.add_item(ReportButton())

new_message = await channel.send(content=message.content + f'\n⎯⎯⎯⎯⎯\nvon {author.mention}', files=files, view=view)
new_message = await channel.send(content=message_content + f'\n⎯⎯⎯⎯⎯\nvon {author.mention}', files=files, view=view)

emoji = '\N{UPWARDS BLACK ARROW}'
await new_message.add_reaction(emoji)
Expand Down

0 comments on commit 595b98d

Please sign in to comment.