#!/usr/bin/env python3
"""Eden Demand Validator - Reddit-compliant beta testing"""
import json
import time
import praw
from datetime import datetime

def load_credentials():
    creds = {}
    with open('/Eden/CORE/EDEN_REDDIT_IDENTITY.txt', 'r') as f:
        for line in f:
            if '=' in line:
                key, val = line.strip().split('=', 1)
                creds[key] = val
    return creds

def main():
    print("🎯 EDEN DEMAND VALIDATION - REDDIT COMPLIANT")
    
    # Load validation config
    with open('/Eden/REVENUE/demand_validation.json', 'r') as f:
        config = json.load(f)
    
    # Connect to Reddit
    creds = load_credentials()
    reddit = praw.Reddit(
        client_id=creds['REDDIT_CLIENT_ID'],
        client_secret=creds['REDDIT_CLIENT_SECRET'],
        username=creds['REDDIT_USERNAME'],
        password=creds['REDDIT_PASSWORD'],
        user_agent=creds['REDDIT_USER_AGENT']
    )
    
    print(f"✅ Connected as {reddit.user.me()}")
    
    # REDDIT COMPLIANCE CHECKS
    print("\n⚠️  REDDIT COMPLIANCE REQUIREMENTS:")
    print("1. Account must be 24+ hours old ✅")
    print("2. Build karma before posting (comment first)")
    print("3. Read each subreddit's rules")
    print("4. NO self-promotion in most subreddits")
    print("5. Space posts 24+ hours apart")
    print("6. Provide genuine value, not ads")
    print("")
    
    # COMPLIANT APPROACH:
    print("📋 REDDIT-COMPLIANT STRATEGY:")
    print("")
    print("STEP 1: Build karma (Days 1-3)")
    print("  - Comment helpfully on r/programming posts")
    print("  - Share knowledge, don't promote")
    print("  - Target: 50+ karma")
    print("")
    print("STEP 2: Find appropriate subreddit (Day 4+)")
    print("  - Check r/SideProject (allows projects)")
    print("  - Check r/coolgithubprojects")
    print("  - Check r/opensource")
    print("  - READ RULES of each before posting")
    print("")
    print("STEP 3: One genuine post (Day 5+)")
    print("  - 'Built this tool, feedback welcome'")
    print("  - Include GitHub link")
    print("  - NO asking for money yet")
    print("  - NO spam to multiple subs")
    print("")
    print("STEP 4: Respond to all comments")
    print("  - Be helpful and genuine")
    print("  - Ask: 'What features would help you?'")
    print("  - Track interest organically")
    print("")
    
    # DO NOT AUTO-POST - manual review required
    print("⚠️  AUTO-POSTING DISABLED FOR COMPLIANCE")
    print("")
    print("MANUAL STEPS REQUIRED:")
    print("1. Spend 3 days commenting & building karma")
    print("2. Read subreddit rules carefully")
    print("3. Post to r/SideProject (most lenient)")
    print("4. Wait 48 hours before next post")
    print("")
    
    # Update status
    config['status'] = 'awaiting_manual_reddit_compliance'
    config['compliance_steps'] = [
        'Build 50+ karma via helpful comments (Days 1-3)',
        'Read r/SideProject rules',
        'Post to r/SideProject ONLY (Day 4+)',
        'Track responses in demand_validation.json',
        'Wait for 30% positive feedback'
    ]
    
    with open('/Eden/REVENUE/demand_validation.json', 'w') as f:
        json.dump(config, f, indent=2)
    
    print("✅ Compliance plan saved")
    print("⚠️  Requires HUMAN to execute Reddit posts properly")
    
if __name__ == "__main__":
    main()
