diff options
| author | 2020-03-28 18:05:26 +0200 | |
|---|---|---|
| committer | 2020-03-28 18:05:26 +0200 | |
| commit | 3482471cd013bfc0102cc3b80c71e04dfc30349c (patch) | |
| tree | fc3a6851279091d7f27ab4f76888035a53dfcc32 | |
| parent | (Webhook Detection): Created `delete_and_respond` helper function to handle W... (diff) | |
(Webhook Detection): Added URL returning to `scan_message` helper function.
| -rw-r--r-- | bot/cogs/webhook_remover.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/cogs/webhook_remover.py b/bot/cogs/webhook_remover.py index a19f9c196..d0d604bc7 100644 --- a/bot/cogs/webhook_remover.py +++ b/bot/cogs/webhook_remover.py @@ -1,5 +1,6 @@ import logging import re +import typing as t from discord import Colour, Message from discord.ext.commands import Cog @@ -31,13 +32,13 @@ class WebhookRemover(Cog): """Get current instance of `ModLog`.""" return self.bot.get_cog("ModLog") - async def scan_message(self, msg: Message) -> bool: + async def scan_message(self, msg: Message) -> t.Tuple[bool, t.Optional[str]]: """Scan message content to detect Webhook URLs. Return `bool` about does this have Discord webhook URL.""" matches = WEBHOOK_URL_RE.search(msg.content) if matches: - return True + return True, matches[0] else: - return False + return False, None async def delete_and_respond(self, msg: Message, url: str) -> None: """Delete message and show warning when message contains Discord Webhook URL.""" |