Skip to content

Commit

Permalink
Fix for null postId, README adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanC committed Mar 4, 2024
1 parent 25aa804 commit 34d6b8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bluebird monitors users on X and reports new posts via Discord.

Although not required, a [Discord Webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) is recommended for notifications.

An X account is required for API credentials. It is recommended to use a throwaway account due to use of the internal API.
An X account is required. It is recommended to use a throwaway account due to use of the internal API.

**Environment Variables:**

Expand Down
11 changes: 10 additions & 1 deletion services/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,18 @@ def GetUserPosts(

continue

postId: str | None = result.get("rest_id")

# rest_id is sometimes within a tweet object.
if not postId:
postId = result.get("tweet", {}).get("rest_id")

if not postId:
raise Exception("rest_id is null")

posts.append(
{
"postId": int(result["rest_id"]),
"postId": postId,
"timestamp": int(
datetime.strptime(
result["legacy"]["created_at"],
Expand Down

0 comments on commit 34d6b8f

Please sign in to comment.