Skip to content

feat: add bluesky.py for interacting with bluesky #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2025

Conversation

0xbrayo
Copy link
Member

@0xbrayo 0xbrayo commented Mar 27, 2025

Important

Add bluesky.py script for CLI interactions with Bluesky, supporting posting, reading feeds, and managing replies.

  • New Script:
    • Adds bluesky.py for CLI interactions with Bluesky.
    • Supports posting, replying, reading user feeds, and checking replies.
  • Authentication:
    • Uses .env for BLUESKY_HANDLE and BLUESKY_PASSWORD.
    • Validates credentials and logs in using load_bluesky_client().
  • Commands:
    • post: Post messages, supports replies and threads.
    • feed: View posts from followed accounts.
    • me: View user's own posts and reposts.
    • user: View posts from a specific user.
    • replies: View replies to user's posts, with filters for time and unanswered.
  • Utilities:
    • validate_post_uri(), format_post_stats(), format_post_time(), display_post(), display_posts() for handling and displaying posts.
    • process_post_text() for processing mentions, links, and tags in posts.

This description was created by Ellipsis for e8167a1. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to e8167a1 in 5 minutes and 46 seconds

More details
  • Looked at 703 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. scripts/bluesky.py:70
  • Draft comment:
    Consider stricter URI validation. Splitting URI with '/' and expecting exactly 5 parts may fail with extra slashes.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. scripts/bluesky.py:432
  • Draft comment:
    Thread posting splits posts on '\n---\n'. Consider trimming whitespace or supporting alternative delimiters to improve usability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. scripts/bluesky.py:67
  • Draft comment:
    Consider using a regex for URI parsing to avoid potential issues with varying slash counts.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The current implementation is actually quite thorough - it validates the format step by step with clear error messages. While regex could work, it wouldn't necessarily be more robust or clearer. The current approach handles all edge cases by checking length and prefixes explicitly. Regex would make the validation less readable and harder to maintain.
    The comment might have a point about handling varying slash counts - what if there are double slashes or trailing slashes? However, the AT protocol URI format is very strict.
    The AT protocol has a strict URI format that must be exactly "at://did:plc:xyz/app.bsky.feed.post/123". The current validation is appropriate for this strict format.
    The current string splitting approach is appropriate and clear for the strict AT protocol URI format. Using regex would add complexity without clear benefits.
4. scripts/bluesky.py:342
  • Draft comment:
    Refactor nested try/except blocks in get_reply_refs for better clarity and error handling.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    While the error handling is complex, it seems to serve distinct purposes at each level - outer level for system errors, inner level for validation, and innermost for data structure issues. The code is working and the error handling, while nested, is actually quite clear in its intent. The comment doesn't provide specific suggestions for how to improve it. Just saying "refactor for better clarity" without specifics isn't very actionable.
    The error handling could potentially be simplified, and having multiple sys.exit(1) calls scattered through the function isn't ideal. Maybe there is room for improvement.
    While there might be room for improvement, the current structure is functional and clear in its purpose. Without specific suggestions for how to improve it, the comment isn't actionable enough to be useful.
    The comment should be deleted because it doesn't provide specific, actionable guidance on how to improve the code structure.
5. scripts/bluesky.py:289
  • Draft comment:
    Consider caching handle resolution in process_post_text to avoid repeated API calls for the same mentions.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
6. scripts/bluesky.py:120
  • Draft comment:
    Standardize attribute naming for engagement stats (likeCount vs. like_count); this inconsistency can lead to confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
7. scripts/bluesky.py:430
  • Draft comment:
    Thread posting split delimiter ("\n---\n") may be brittle. Consider a configurable or more robust delimiter.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
8. scripts/bluesky.py:625
  • Draft comment:
    Avoid overwriting notifications.notifications when filtering; assign to a new variable to improve clarity.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
9. scripts/bluesky.py:696
  • Draft comment:
    Overall, excellent CLI documentation and informative error messages.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_hSepGbShwaxYltMr


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

console.print(f"[red]Login failed: {e}")
sys.exit(1)

def format_post_stats(post: models.AppBskyFeedDefs.PostView) -> str:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent attribute naming for engagement stats; earlier using likeCount versus later like_count. Ensure consistent API property names.

"""Get the URI and CID for a post"""
try:
# Parse the URI to get repo, collection, and rkey
parts = post_uri.split('/')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse validate_post_uri here for consistency instead of re-splitting the URI manually.

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, nice! Just some lints to fix

@0xbrayo 0xbrayo force-pushed the master branch 2 times, most recently from 60cb100 to f2f3aec Compare March 28, 2025 14:00
@0xbrayo
Copy link
Member Author

0xbrayo commented Mar 28, 2025

Woah, nice! Just some lints to fix

Fixed the lints :)

@ErikBjare ErikBjare merged commit 7aa1d69 into gptme:master Mar 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants