From 86453cb58c50f64bff044e4c59c9920a53a71b1b Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Sun, 16 Mar 2025 12:23:29 -0300 Subject: [PATCH] feat(shard): :sparkles: Handle attachments on call. Attachments can now be sent by moderators. Users are now notified when they can't send attachments, and if their message has text other than attachments, the other party gets notified that attachments were removed from the message. --- payphone/cogs/calls/cog.py | 23 +++++++++++++++++++++++ uv.lock | 7 +++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/payphone/cogs/calls/cog.py b/payphone/cogs/calls/cog.py index 9791689..2952e8e 100644 --- a/payphone/cogs/calls/cog.py +++ b/payphone/cogs/calls/cog.py @@ -257,6 +257,8 @@ class Calls(base.Cog): message_content = self.bot.clean_message(message) + has_sent_attachments = False + if message.stickers: if participant.user.flag & ( models.UserFlag.SUPPORTER | models.UserFlag.MODERATOR @@ -272,6 +274,24 @@ class Calls(base.Cog): "page]()." ) + if message.attachments: + if participant.user.flag & models.UserFlag.MODERATOR + for attachment in message.attachments: + message_content += ( + f"[{constants.BRAILE_CHARACTER}]({attachment.url})" + ) + + else: + await message.channel.send( + f"❌ **{participant.display_name}** You can't send attachments in calls." + ) + + if not message_content: + return + + else: + has_sent_attachments = True + embeds = [] if message.reference: @@ -388,6 +408,9 @@ class Calls(base.Cog): ) ) + if has_sent_attachments: + message_content += "\n-# ⓘ Attachments were removed from this message." + async with aiohttp.ClientSession() as session: for _ in range(3): try: diff --git a/uv.lock b/uv.lock index 5f3e603..c433da5 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,4 @@ version = 1 -revision = 1 requires-python = ">=3.12" [[package]] @@ -128,7 +127,7 @@ version = "8.1.8" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, - { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "colorama", marker = "platform_system == 'Windows'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/cb/b5/e1e5fdf1c1bb7e6e614987c120a98d9324bf8edfaa5f5cd16a6235c9d91b/asyncclick-8.1.8.tar.gz", hash = "sha256:0f0eb0f280e04919d67cf71b9fcdfb4db2d9ff7203669c40284485c149578e4c", size = 232900 } wheels = [ @@ -198,7 +197,7 @@ name = "click" version = "8.1.8" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "colorama", marker = "platform_system == 'Windows'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 } wheels = [ @@ -414,7 +413,7 @@ wheels = [ [[package]] name = "payphone" -version = "0.54.0" +version = "0.55.0" source = { virtual = "." } dependencies = [ { name = "aerich" },