diff options
| author | 2020-05-10 18:55:24 -0700 | |
|---|---|---|
| committer | 2020-05-11 12:03:12 -0700 | |
| commit | 09a6c2e211c0f209b258a02d9677240282c4fab3 (patch) | |
| tree | 1287c5cbb7e89d322c38c92303e3f2f1109a0d4e | |
| parent | Token remover: split some of `take_action` into separate functions (diff) | |
Token remover: use a string template for the log message
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/token_remover.py | 15 | 
1 files changed, 11 insertions, 4 deletions
| diff --git a/bot/cogs/token_remover.py b/bot/cogs/token_remover.py index d6919839e..c576a67d0 100644 --- a/bot/cogs/token_remover.py +++ b/bot/cogs/token_remover.py @@ -16,6 +16,10 @@ from bot.constants import Channels, Colours, Event, Icons  log = logging.getLogger(__name__) +LOG_MESSAGE = ( +    "Censored a seemingly valid token sent by {author} (`{author_id}`) in {channel}," +    "token was `{user_id}.{timestamp}.{hmac}`" +)  DELETION_MESSAGE_TEMPLATE = (      "Hey {mention}! I noticed you posted a seemingly valid Discord API "      "token in your message and have removed your message. " @@ -97,10 +101,13 @@ class TokenRemover(Cog):      def format_log_message(msg: Message, found_token: str) -> str:          """Return the log message to send for `found_token` being censored in `msg`."""          user_id, creation_timestamp, hmac = found_token.split('.') -        return ( -            "Censored a seemingly valid token sent by " -            f"{msg.author} (`{msg.author.id}`) in {msg.channel.mention}, token was " -            f"`{user_id}.{creation_timestamp}.{'x' * len(hmac)}`" +        return LOG_MESSAGE.format( +            author=msg.author, +            author_id=msg.author.id, +            channel=msg.channel.mention, +            user_id=user_id, +            timestamp=creation_timestamp, +            hmac='x' * len(hmac),          )      @classmethod | 
