fix(shard): 🐛 Messages raising an error if too long.
This commit is contained in:
+14
-16
@@ -12,7 +12,7 @@ import sentry_sdk
|
|||||||
from payphone.db import models
|
from payphone.db import models
|
||||||
from payphone.bot import Payphone
|
from payphone.bot import Payphone
|
||||||
from payphone.cogs import base
|
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):
|
class Calls(base.Cog):
|
||||||
@@ -257,7 +257,7 @@ class Calls(base.Cog):
|
|||||||
|
|
||||||
message_content = self.bot.clean_message(message)
|
message_content = self.bot.clean_message(message)
|
||||||
|
|
||||||
has_sent_attachments = False
|
notices = []
|
||||||
|
|
||||||
if message.stickers:
|
if message.stickers:
|
||||||
if participant.user.flag & (
|
if participant.user.flag & (
|
||||||
@@ -289,7 +289,7 @@ class Calls(base.Cog):
|
|||||||
if not message_content:
|
if not message_content:
|
||||||
return
|
return
|
||||||
|
|
||||||
has_sent_attachments = True
|
notices.append("The original message contained attachments.")
|
||||||
|
|
||||||
embeds = []
|
embeds = []
|
||||||
|
|
||||||
@@ -335,9 +335,7 @@ class Calls(base.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if replied_participant is None:
|
if replied_participant is None:
|
||||||
message_content += (
|
notices.append("In reply to a message from outside this call.")
|
||||||
"\n-# ⓘ In reply to a message from outside this call."
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
embeds.append(
|
embeds.append(
|
||||||
@@ -362,14 +360,10 @@ class Calls(base.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
message_content += (
|
notices.append("In reply to a message from outside this call.")
|
||||||
"\n-# ⓘ In reply to a message from outside this call."
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
message_content += (
|
notices.append("In reply to a message from outside this call.")
|
||||||
"\n-# ⓘ In reply to a message from outside this call."
|
|
||||||
)
|
|
||||||
|
|
||||||
if was_mask_toggled:
|
if was_mask_toggled:
|
||||||
if not participant.is_masked:
|
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:
|
async with aiohttp.ClientSession() as session:
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
try:
|
try:
|
||||||
@@ -422,8 +413,15 @@ class Calls(base.Cog):
|
|||||||
bot_token=constants.TOKEN,
|
bot_token=constants.TOKEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
notices_text = (
|
||||||
|
("\n-# ⓘ " + "\n-# ⓘ ".join(notices)) if notices else ""
|
||||||
|
)
|
||||||
|
|
||||||
propagated_msg = await webhook.send(
|
propagated_msg = await webhook.send(
|
||||||
content=message_content,
|
content=formatting.trim(
|
||||||
|
message_content, 2000 - len(notices_text)
|
||||||
|
)
|
||||||
|
+ notices_text,
|
||||||
username=participant.display_name,
|
username=participant.display_name,
|
||||||
avatar_url=participant.display_avatar_url,
|
avatar_url=participant.display_avatar_url,
|
||||||
embeds=embeds,
|
embeds=embeds,
|
||||||
|
|||||||
Reference in New Issue
Block a user