Skip to content

A scalable, extensible bot system built in Go (Golang) for handling direct messages (DMs), group chats, and automated event handling on the Nostr network.

License

Notifications You must be signed in to change notification settings

prorobot-ai/nostr-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– NOSTR-AGENT

A scalable, extensible bot system built in Go (Golang) for handling direct messages (DMs), group chats, and automated event handling on the Nostr network.

🌍 Features

  • βœ… Direct Message Bot (support_bot) – Handles user queries and support via encrypted direct messages.
  • βœ… Group Chat Bot (weather_bot) – Broadcasts weather updates to group channels.
  • βœ… Welcome Bot (welcome_bot) – Greets new users in group channels.
  • βœ… Session Manager Bot (session) – Manages multi-bot sessions (Yin and Yang) for interaction.
  • βœ… Extensible Plugin System – Supports global and handler-specific plugins (e.g., logging, notifications).
  • βœ… Dockerized Deployment – Easily deploy with Docker, including auto-restart capabilities.
  • βœ… Auto-Resilience – Automatically restarts if the bot crashes or encounters errors.
  • βœ… Dynamic Configuration – Load bot configurations via YAML files.

πŸš€ Getting Started

πŸ“¦ Prerequisites


πŸ”‘ Environment Variables

Create a .env file in the root directory with the following values:

METEOMATICS_USERNAME=
METEOMATICS_PASSWORD=

βš™οΈ Configuration

Create YAML configuration files inside the configs/ directory.

Example: configs/support_bot.yaml

bots:
  - name: "Support Bot"
    relay_url: "wss://relay.example.com"
    nsec: "your-secret-key"
    channel_id: "your-channel-id"
    listener: "DMListener"
    publisher: "DMPublisher"
    handler: "SupportHandler"
    event_type: "DMResponseEvent"

Example: configs/weather_bot.yaml

bots:
  - name: "Weather Bot"
    relay_url: "wss://relay.example.com"
    nsec: "your-secret-key"
    channel_id: "your-channel-id"
    listener: "GroupListener"
    publisher: "GroupPublisher"
    handler: "GroupHandler"
    event_type: "GroupResponseEvent"

Example: configs/welcome_bot.yaml

bots:
  - name: "Welcome Bot"
    relay_url: "wss://relay.example.com"
    nsec: "your-secret-key"
    channel_id: "your-channel-id"
    listener: "DMListener"
    publisher: "GroupPublisher"
    handler: "WelcomeHandler"
    event_type: "GroupResponseEvent"

Example: configs/session.yaml

bots:
  - name: "Yin Bot"
    relay_url: "wss://relay.example.com"
    nsec: "your-secret-key"
    channel_id: "your-channel-id"
    listener: "GroupListener"
    publisher: "GroupPublisher"
    handler: "ExchangeHandler"
    event_type: "GroupResponseEvent"

  - name: "Yang Bot"
    relay_url: "wss://relay.example.com"
    nsec: "your-secret-key"
    channel_id: "your-channel-id"
    listener: "GroupListener"
    publisher: "GroupPublisher"
    handler: "ExchangeHandler"
    event_type: "GroupResponseEvent"

πŸ”¨ Building and Running

βœ… 1. Running Locally (Without Docker)

Install dependencies:

go mod download

Run the bot:

go run main.go --config=configs/support_bot.yaml

🐳 2. Running with Docker

Step 1: Build the Docker image:

docker-compose build

Step 2: Start the bot using Docker Compose:

docker-compose up -d

Step 3: View logs:

docker logs -f support-bot

Step 4: Stop the bot:

docker-compose down

πŸ”₯ Commands

Command Description
agent --config=configs/support_bot.yaml Starts support bot
agent --config=configs/weather_bot.yaml Starts weather bot
agent --config=configs/welcome_bot.yaml Starts welcome bot
agent --config=configs/session.yaml Starts session with Yin and Yang bots

Generate project tree:

tree --prune -I "$(paste -sd'|' .treeignore)" > tree.txt

🐳 Docker Compose Configuration Example

version: "3.8"

services:
  support_bot:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: support-bot
    restart: unless-stopped
    env_file:
      - .env
    command: ["--config=configs/support_bot.yaml"]
    volumes:
      - ./logs/support:/app/logs

  weather_bot:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: weather-bot
    restart: unless-stopped
    env_file:
      - .env
    command: ["--config=configs/weather_bot.yaml"]
    volumes:
      - ./logs/weather:/app/logs

  welcome_bot:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: welcome-bot
    restart: unless-stopped
    env_file:
      - .env
    command: ["--config=configs/welcome_bot.yaml"]
    volumes:
      - ./logs/welcome:/app/logs

🀝 Contributing

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Create a new Pull Request.

πŸ“ License

This project is licensed under the MIT License.


πŸ“« Contact

For support or collaboration inquiries, reach out to:


🌟 Acknowledgments

  • Built using Go
  • Uses the Nostr protocol
  • Dockerized for easy deployment πŸš€

About

A scalable, extensible bot system built in Go (Golang) for handling direct messages (DMs), group chats, and automated event handling on the Nostr network.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published