Fix attachment is_spoiler() and is_voice_message()

This commit is contained in:
dolfies 2025-03-02 22:38:53 -05:00 committed by GitHub
parent fbe2b358fc
commit de5720e659
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -254,11 +254,12 @@ class Attachment(Hashable):
def is_spoiler(self) -> bool:
""":class:`bool`: Whether this attachment contains a spoiler."""
return self.filename.startswith('SPOILER_')
# The flag is technically always present but no harm to check both
return self.filename.startswith('SPOILER_') or self.flags.spoiler
def is_voice_message(self) -> bool:
""":class:`bool`: Whether this attachment is a voice message."""
return self.duration is not None and 'voice-message' in self.url
return self.duration is not None and self.waveform is not None
def __repr__(self) -> str:
return f'<Attachment id={self.id} filename={self.filename!r} url={self.url!r}>'