# Nostr Poster

An automated content posting bot for Nostr networks. This tool allows you to schedule regular posting of images and videos to Nostr relays, supporting both NIP-94 and Blossom upload services.


# Nostr Poster

## Table of Contents
- [Plan for Nostr Poster Improvements](#plan-for-nostr-poster-improvements)
- [To-Do List](#to-do-list)

### Priority Order

1. [ ] Bot Profile Management: Complete proper profile creation, editing, and publishing
2. [ ] Relay Management: Improve relay selection and management interface
3. [ ] Test Auto-Posting: Ensure the scheduling system works correctly

## To-Do List

### Bot Profile Management Enhancements

- [ ] Add upload fields to both the "Create Bot" modal and "Bot Settings" modal
- [ ] Create a consistent interface for profile images across both modals
- [ ] Implement preview functionality for selected images
- [ ] Connect these uploads to the NIP-96/Blossom media servers
- [ ] Ensure proper kind 0 event creation with all required metadata fields
- [ ] Display confirmation after successful publishing with NIP-19 encoded identifiers
- [ ] Add a visual indicator to show when a bot's profile needs publishing (outdated)
- [ ] Create new file input fields in both modals with preview capability
- [ ] Create a shared function for uploading profile images to media servers
- [ ] Update the `CreateAndSignMetadataEvent` function to include all necessary fields for a proper NIP-01 metadata event
- [ ] Add an explicit "Publish Profile" button to push the kind 0 event to relays

### Relay Management Improvements

- [ ] Create a more intuitive relay management interface
- [ ] Add ability to categorize relays (read, write, both)
- [ ] Include relay testing functionality
- [ ] Add a "recommended relays" quick-add option
- [ ] Create a dedicated relay management component in the bot settings modal
- [ ] Add quick-add buttons for popular relays
- [ ] Include relay status indicators
- [ ] Implement relay tests (ping/connection checks)

### Post Scheduling and Auto-Posting Testing

- [ ] Add detailed logging for scheduled posts
- [ ] Create a manual trigger for testing scheduled posts
- [ ] Implement a post history view
- [ ] Add a "test now" button that triggers an immediate post attempt
- [ ] Create a dedicated tab or view for post history
- [ ] Implement proper error logging and status tracking

### Code Changes Required

- [ ] Modify `index.html` - Add profile image/banner upload fields
- [ ] Modify `main.js` - Add functions for handling profile image uploads
- [ ] Create a new component for relay management
- [ ] Modify `events.go` - Ensure metadata events are properly formatted
- [ ] Modify `bot_service.go` - Enhance profile publishing logic
- [ ] Modify `routes.go` - Add endpoints for profile image management


## Features

- **Media Management**: Upload content to either NIP-94/96 compatible servers or Blossom storage servers
- **Scheduled Posting**: Configure posting intervals for automated content sharing
- **Multiple Bot Support**: Manage multiple bot identities, each with their own keypair
- **Keypair Management**: Create new keypairs or import existing ones
- **Relay Configuration**: Configure which relays to publish to for each bot
- **Profile Management**: Set up and publish bot profiles (name, bio, avatar, etc.)
- **Content Archiving**: Posted content gets archived to avoid duplicate posts

## Installation

### Requirements

- Go 1.18 or higher
- SQLite 3

### Building from Source

1. Clone the repository:
```bash
git clone https://github.com/yourusername/nostr-poster.git
cd nostr-poster
```

2. Build the application:
```bash
make build
```

3. Run the application:
```bash
make run
```

## Configuration

The application can be configured via a YAML file or environment variables. By default, the config file is located at `/config.yaml`.

### Example Configuration

```yaml
app_name: "Nostr Poster"
server_port: 8080
log_level: "info"

bot:
  keys_file: "./keys.json"
  content_dir: "./content"
  archive_dir: "./archive"
  default_interval: 60  # minutes

db:
  path: "./nostr-poster.db"

media:
  default_service: "nip94"
  nip94:
    server_url: "https://nostr.build/api/upload/nostr"
    require_auth: true
  blossom:
    server_url: "https://blossom.example.com"

relays:
  - url: "wss://relay.damus.io"
    read: true
    write: true
  - url: "wss://nostr.mutinywallet.com"
    read: true
    write: true
  - url: "wss://relay.nostr.band"
    read: true
    write: true
```

## Usage

### Set up a Bot

1. Navigate to the web interface at `http://localhost:8765`
2. Log in with your Nostr extension (NIP-07)
3. Create a new bot by providing a name and optional keypair
4. Configure the posting schedule, media upload service, and relays
5. Add content to the bot's content directory
6. Enable the bot to start automated posting

### Manual Posting

You can also trigger a post manually through the web interface

## NIPs Supported

- NIP-01: Basic protocol flow
- NIP-07: Browser extension authentication
- NIP-55: Android signer application (soon TM)
- NIP-94: File metadata
- NIP-96: HTTP file storage
- NIP-98: HTTP authentication

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.