Skip to content

Commit

Permalink
Support pulling pinned statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
dhjw committed Dec 8, 2023
1 parent 5c6b39e commit dd8e273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion truthbrush/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def pull_statuses(
Params:
created_after : timezone aware datetime object
since_id : number or string
pinned : get pinned posts only
Returns a list of posts in reverse chronological order,
or an empty list if not found.
Expand Down
9 changes: 7 additions & 2 deletions truthbrush/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@ def ads():
help="Only pull posts created on or after the specified datetime, e.g. 2021-10-02 or 2011-11-04T00:05:23+04:00 (defaults to none). If a timezone is not specified, UTC is assumed.",
type=datetime.datetime.fromisoformat,
)
def statuses(username: str, replies: bool = False, created_after: date = None):
@click.option(
"--pinned/--all",
default=False,
help="Only pull pinned posts (defaults to all)"
)
def statuses(username: str, replies: bool = False, created_after: date = None, pinned: bool = False):
"""Pull a user's statuses"""

# Assume UTC if no timezone is specified
if created_after and created_after.tzinfo is None:
created_after = created_after.replace(tzinfo=datetime.timezone.utc)

for page in api.pull_statuses(
username, created_after=created_after, replies=replies
username, created_after=created_after, replies=replies, pinned=pinned
):
print(json.dumps(page))

0 comments on commit dd8e273

Please sign in to comment.