diff --git a/payphone/cogs/calls/cog.py b/payphone/cogs/calls/cog.py index 4820e52..a14bbcc 100644 --- a/payphone/cogs/calls/cog.py +++ b/payphone/cogs/calls/cog.py @@ -12,7 +12,7 @@ import sentry_sdk from payphone.db import models from payphone.bot import Payphone from payphone.cogs import base -from payphone.core import constants, censorship, messages, masks, checks +from payphone.core import constants, censorship, messages, masks, checks, formatting class Calls(base.Cog): @@ -257,7 +257,7 @@ class Calls(base.Cog): message_content = self.bot.clean_message(message) - has_sent_attachments = False + notices = [] if message.stickers: if participant.user.flag & ( @@ -289,7 +289,7 @@ class Calls(base.Cog): if not message_content: return - has_sent_attachments = True + notices.append("The original message contained attachments.") embeds = [] @@ -335,9 +335,7 @@ class Calls(base.Cog): ) if replied_participant is None: - message_content += ( - "\n-# ⓘ In reply to a message from outside this call." - ) + notices.append("In reply to a message from outside this call.") else: embeds.append( @@ -362,14 +360,10 @@ class Calls(base.Cog): ) else: - message_content += ( - "\n-# ⓘ In reply to a message from outside this call." - ) + notices.append("In reply to a message from outside this call.") else: - message_content += ( - "\n-# ⓘ In reply to a message from outside this call." - ) + notices.append("In reply to a message from outside this call.") if was_mask_toggled: if not participant.is_masked: @@ -408,9 +402,6 @@ class Calls(base.Cog): ) ) - if has_sent_attachments: - message_content += "\n-# ⓘ The original message contained attachments." - async with aiohttp.ClientSession() as session: for _ in range(3): try: @@ -422,8 +413,15 @@ class Calls(base.Cog): bot_token=constants.TOKEN, ) + notices_text = ( + ("\n-# ⓘ " + "\n-# ⓘ ".join(notices)) if notices else "" + ) + propagated_msg = await webhook.send( - content=message_content, + content=formatting.trim( + message_content, 2000 - len(notices_text) + ) + + notices_text, username=participant.display_name, avatar_url=participant.display_avatar_url, embeds=embeds,