1
0
Fork 0

style: paint it newer black

This commit is contained in:
nicoco 2024-02-11 06:58:29 +01:00
parent e404bc09fe
commit 6440e97331
2 changed files with 24 additions and 16 deletions

View File

@ -94,13 +94,15 @@ class MUC(LegacyMUC[str, str, Participant, str]):
def replace_mentions(self, t: str):
return replace_mentions(
t,
participants={
c.jid_username: c.name
for c, p in self._participants_by_contacts.items()
}
| {self.session.user_phone: self.user_nick}
if self.session.user_phone # user_phone *should* be set at this point,
else {}, # but better safe than sorry
participants=(
{
c.jid_username: c.name
for c, p in self._participants_by_contacts.items()
}
| {self.session.user_phone: self.user_nick}
if self.session.user_phone # user_phone *should* be set at this point,
else {} # but better safe than sorry
),
)
async def on_avatar(self, data: Optional[bytes], mime: Optional[str]) -> None:

View File

@ -345,9 +345,11 @@ class Session(BaseSession[str, Recipient]):
"""
receipt = whatsapp.Receipt(
MessageIDs=go.Slice_string([legacy_msg_id]),
JID=c.get_message_sender(legacy_msg_id)
if isinstance(c, MUC)
else c.legacy_id,
JID=(
c.get_message_sender(legacy_msg_id)
if isinstance(c, MUC)
else c.legacy_id
),
GroupJID=c.legacy_id if c.is_group else "",
)
self.whatsapp.SendReceipt(receipt)
@ -446,9 +448,11 @@ class Session(BaseSession[str, Recipient]):
return None
reply_to = MessageReference(
legacy_id=message.ReplyID,
body=message.ReplyBody
if muc is None
else muc.replace_mentions(message.ReplyBody),
body=(
message.ReplyBody
if muc is None
else muc.replace_mentions(message.ReplyBody)
),
)
if message.OriginJID == self.contacts.user_legacy_id:
reply_to.author = self.user
@ -532,9 +536,11 @@ class Attachment(LegacyAttachment):
return Attachment(
content_type=wa_attachment.MIME,
path=wa_attachment.Path,
caption=wa_attachment.Caption
if muc is None
else muc.replace_mentions(wa_attachment.Caption),
caption=(
wa_attachment.Caption
if muc is None
else muc.replace_mentions(wa_attachment.Caption)
),
name=wa_attachment.Filename,
)