Skip to content

Commit

Permalink
Spoiler tag messages
Browse files Browse the repository at this point in the history
  • Loading branch information
amadejkastelic committed Dec 18, 2023
1 parent 3c0eeaa commit 32d6b14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ async def _send_post(
try:
content = f'Here you go {author.mention} {random.choice(emoji)}.\n{str(post)}'
if len(content) > 2000:
content = content[:1997] + '...'
if not post.spoiler:
content = content[:1997] + '...'
else:
content = content[:1995] + '||...'

return await channel.send(
content=content,
Expand Down
4 changes: 3 additions & 1 deletion models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Post:
created: typing.Optional[datetime.datetime] = None

def __str__(self) -> str:
description = self.description or '❌'

return (
'🔗 URL: {url}\n'
'🧑🏻‍🎨 Author: {author}\n'
Expand All @@ -27,7 +29,7 @@ def __str__(self) -> str:
url=self.url,
author=self.author or '❌',
created=self._date_human_format(date=self.created) if self.created else '❌',
description=self.description or '❌',
description=description if not self.spoiler else f'||{description}||',
views=self._number_human_format(num=self.views) if self.views else '❌',
likes=self._number_human_format(num=self.likes) if self.likes else '❌',
)
Expand Down

0 comments on commit 32d6b14

Please sign in to comment.