a digital person for bluesky

Add priority queue for cameron.pfiffer.org messages

Implemented a priority queue system that ensures messages from cameron.pfiffer.org are processed first:

- Modified save_notification_to_queue() to add priority prefix to filenames
- cameron.pfiffer.org messages get "0_" prefix (high priority)
- All other messages get "1_" prefix (normal priority)
- Queue processing sorts by filename, so high priority messages process first
- Added clear logging to indicate when high priority notifications are queued
- Updated function documentation to reflect priority ordering

File naming format:
- High priority: 0_YYYYMMDD_HHMMSS_{reason}_{hash}.json
- Normal priority: 1_YYYYMMDD_HHMMSS_{reason}_{hash}.json

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

+11 -5
+11 -5
bsky.py
··· 520 521 522 def save_notification_to_queue(notification): 523 - """Save a notification to the queue directory with hash-based filename.""" 524 try: 525 # Check if already processed 526 processed_uris = load_processed_notifications() ··· 537 # Generate hash for filename (to avoid duplicates) 538 notif_hash = hashlib.sha256(notif_json.encode()).hexdigest()[:16] 539 540 - # Create filename with timestamp and hash 541 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") 542 - filename = f"{timestamp}_{notification.reason}_{notif_hash}.json" 543 filepath = QUEUE_DIR / filename 544 545 # Skip if already exists (duplicate) ··· 551 with open(filepath, 'w') as f: 552 json.dump(notif_dict, f, indent=2) 553 554 - logger.info(f"Queued notification: {filename}") 555 return True 556 557 except Exception as e: ··· 560 561 562 def load_and_process_queued_notifications(void_agent, atproto_client): 563 - """Load and process all notifications from the queue.""" 564 logger.info("Loading queued notifications from disk...") 565 try: 566 # Get all JSON files in queue directory (excluding processed_notifications.json) 567 queue_files = sorted([f for f in QUEUE_DIR.glob("*.json") if f.name != "processed_notifications.json"]) 568 569 if not queue_files:
··· 520 521 522 def save_notification_to_queue(notification): 523 + """Save a notification to the queue directory with priority-based filename.""" 524 try: 525 # Check if already processed 526 processed_uris = load_processed_notifications() ··· 537 # Generate hash for filename (to avoid duplicates) 538 notif_hash = hashlib.sha256(notif_json.encode()).hexdigest()[:16] 539 540 + # Determine priority based on author handle 541 + author_handle = getattr(notification.author, 'handle', '') if hasattr(notification, 'author') else '' 542 + priority_prefix = "0_" if author_handle == "cameron.pfiffer.org" else "1_" 543 + 544 + # Create filename with priority, timestamp and hash 545 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") 546 + filename = f"{priority_prefix}{timestamp}_{notification.reason}_{notif_hash}.json" 547 filepath = QUEUE_DIR / filename 548 549 # Skip if already exists (duplicate) ··· 555 with open(filepath, 'w') as f: 556 json.dump(notif_dict, f, indent=2) 557 558 + priority_label = "HIGH PRIORITY" if priority_prefix == "0_" else "normal" 559 + logger.info(f"Queued notification ({priority_label}): {filename}") 560 return True 561 562 except Exception as e: ··· 565 566 567 def load_and_process_queued_notifications(void_agent, atproto_client): 568 + """Load and process all notifications from the queue in priority order.""" 569 logger.info("Loading queued notifications from disk...") 570 try: 571 # Get all JSON files in queue directory (excluding processed_notifications.json) 572 + # Files are sorted by name, which puts priority files first (0_ prefix before 1_ prefix) 573 queue_files = sorted([f for f in QUEUE_DIR.glob("*.json") if f.name != "processed_notifications.json"]) 574 575 if not queue_files: