Skip to content

Hitchwiki/nostrhitch

Repository files navigation

Nostr Hitchhiking Bot

A vibe coded Go daemon that publishes Hitchwiki and Hitchmap content to Nostr relays.

It fetches a recent sqlite dump from hitchmap and then posts these notes as kind 34242 onto some nostr relays. Kinds 3xxxx are replaceable notes. (42 is the answer to everything.)

Nostrhitch also fetches recent changes across the different hitchwiki languages and posts them as (currently) kind 1 notes.

Hitchhikers will soon(tm) be able to see these notes and add new spots at https://maps.hitchwiki.org/ The nostr maps code for this lives at https://github.com/hitchwiki/hitchmap-nostr

See also https://hitchwiki.org/en/User:Nostrhitch

Quick Start

Local Development

# Build
go build -o nostrhitch-daemon main.go

# Configure
cp config.json.example config.json
# Edit config.json with your nsec key and relay URLs

# Run
./nostrhitch-daemon -once          # Test once
./nostrhitch-daemon -dry-run       # Test without posting
./nostrhitch-daemon                # Run daemon

Docker

# Run with Docker
docker-compose up -d

# View logs
docker-compose logs -f

# Reload after config changes
docker-compose restart

Configuration

Edit config.json:

{
  "nsec": "your_nsec_key_here",
  "post_to_relays": true,
  "relays": ["wss://relay.hitchwiki.org"],
  "hw_interval": 300,
  "hitch_interval": 86400,
  "secret_hitchwiki_url": "http://hitchwiki-alternative.example.net"
}

Features

  • Multi-language: Fetches from 17 Hitchwiki language versions
  • Duplicate Prevention: Two-tier system prevents reposting
  • Geo Tags: Automatic location detection and plus codes
  • Persistent Storage: SQLite database survives container restarts
  • NIP-05 Verification: Automatic profile management
  • Event Types: Hitchwiki uses kind 1 (text notes), Hitchmap uses kind 34242

Duplicate Prevention

The bot uses a robust two-tier system to avoid posting duplicates:

1. Session Tracking

  • In-memory map: Tracks notes posted during current session
  • Immediate prevention: Skips already processed entries

2. Relay-based Tracking

  • Startup scan: Queries all relays for existing notes at startup
  • Persistent detection: Uses RSS entry IDs and database record IDs as unique keys
  • Cross-session: Prevents duplicates even after bot restarts

3. Unique Identifiers

  • Hitchwiki: Uses RSS entry ID (full diff URL) as unique key
  • Hitchmap: Uses database record ID with hitchmap_ prefix
  • Nostr tags: r tag contains reference URL for future duplicate detection

Event Types

The bot publishes two different types of Nostr events:

Hitchwiki Events (Kind 1)

  • Kind: 1 (text note)
  • Content: Formatted as "📝 Author edited URL 📄 #hitchhiking"
  • Tags:
    • r tag: Full diff URL for duplicate checking
    • summary tag: HTML summary from RSS feed
    • t tags: hitchhiking, hitchwiki
    • g tags: Geographic coordinates and geohash
    • L/l tags: Open Location Code (plus codes)

Hitchmap Events (Kind 34242)

  • Kind: 34242 (custom event type for geographic data)
  • Content: Formatted as "hitchmap.com Author: Description #hitchhiking"
  • Tags:
    • d tag: Database record ID for duplicate checking
    • g tags: Geographic coordinates and geohash
    • L/l tags: Open Location Code with multiple precision levels
    • t tags: hitchmap, map-notes

Data Sources

  • Hitchwiki: Recent changes from RSS feeds (17 languages)
  • Hitchmap: Geographic hitchhiking data from SQLite database
  • Tags: #hitchhiking, #hitchwiki, #hitchmap, geo coordinates

Commands

# Local
./nostrhitch-daemon -once          # Run once
./nostrhitch-daemon -debug         # Debug mode
./nostrhitch-daemon -dry-run       # Test mode

# Docker
docker-compose up -d               # Start daemon
docker-compose down                # Stop daemon
docker-compose restart             # Reload config
docker-compose logs -f             # View logs

File Structure

nostrhitch/
├── main.go                 # Main daemon
├── config.json             # Configuration
├── docker-compose.yml      # Docker setup
├── hitchmap-dumps/         # SQLite databases (persistent)
└── logs/                   # Log files

About

A minimal, efficient Go daemon that publishes Hitchwiki and Hitchmap content to Nostr relays.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •