From 488234ba79d92e1e7f984c1e9ccfdc0dfe7fc918 Mon Sep 17 00:00:00 2001 From: zevaryx Date: Sat, 7 May 2022 13:12:17 -0600 Subject: [PATCH] Fix reddit checking for crosspost --- jarvis_tasks/tasks/reddit.py | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jarvis_tasks/tasks/reddit.py b/jarvis_tasks/tasks/reddit.py index bf766af..b4e522d 100644 --- a/jarvis_tasks/tasks/reddit.py +++ b/jarvis_tasks/tasks/reddit.py @@ -42,7 +42,7 @@ async def post_embeds(sub: Sub, post: Submission, reddit: Reddit) -> Optional[Li fields = [] content = "" og_post = None - if not post.is_self: + if "crosspost_parent_list" in vars(post): og_post = post # noqa: F841 post = await reddit.submission(post.crosspost_parent_list[0]["id"]) await post.load() @@ -62,9 +62,14 @@ async def post_embeds(sub: Sub, post: Submission, reddit: Reddit) -> Optional[Li break if "selftext" in vars(post) and post.selftext: + text = post.selftext + if post.spoiler: + text = "||" + text + "||" content += "\n\n" + post.selftext if len(content) > 900: content = content[:900] + "..." + if post.spoiler: + content += "||" content += f"\n\n[View this post]({url})" if not images and not content: diff --git a/pyproject.toml b/pyproject.toml index 25176c7..7c53b2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "jarvis-tasks" -version = "0.7.0" +version = "0.7.1" description = "" authors = ["Your Name "]