Skip to content

benmoroney/BookStealer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anna's Archive Discord Book Bot 📚

A Discord bot that searches Anna's Archive for books and downloads them directly to your home server.

Features

  • 🔍 Search for books by title, author, or both
  • 📋 Get top 5 matching results with details (format, size, language)
  • 🖱️ Interactive button selection for easy downloading
  • 💾 Downloads books directly to your server
  • 🐳 Easy Docker deployment

Quick Start

1. Create a Discord Bot

  1. Go to the Discord Developer Portal
  2. Click "New Application" and give it a name
  3. Go to the "Bot" section and click "Add Bot"
  4. Under "Privileged Gateway Intents", enable:
    • Message Content Intent (required for prefix commands)
  5. Click "Reset Token" and copy your bot token
  6. Go to "OAuth2" → "URL Generator"
  7. Select scopes: bot, applications.commands
  8. Select permissions: Send Messages, Embed Links, Use Slash Commands
  9. Copy the generated URL and use it to invite the bot to your server

2. Deploy the Bot

# Clone or copy these files to your server
cd annas-discord-bot

# Create your .env file
cp .env.example .env

# Edit .env and add your Discord token
nano .env

# Start the bot
docker compose up -d

3. Use the Bot

Once the bot is online in your Discord server:

/book 1984                    # Search by title
/book Dune Frank Herbert      # Search by title and author
/search title:1984            # Alternative search command
!book Project Hail Mary       # Prefix command alternative
/help                         # Show help

Configuration

Environment Variables

Variable Required Default Description
DISCORD_TOKEN Yes - Your Discord bot token
BOOKS_DIR No /books Directory to save downloaded books
ANNAS_BASE_URL No https://annas-archive.org Anna's Archive URL

Customizing the Books Directory

By default, books are saved to ./books on your host machine. To change this, edit docker-compose.yml:

volumes:
  - /path/to/your/books:/books  # Change the left side

Commands

Command Description
/book <query> Search for a book
/search <title> [author] Search with separate title/author fields
!book <query> Prefix command (alternative to slash commands)
/help Show help information

How It Works

  1. Search: When you search, the bot queries Anna's Archive and parses the top 5 results
  2. Select: Results are displayed with interactive buttons - click to select
  3. Download: The bot fetches the download link and saves the file to your server
  4. Done: You get a confirmation with the filename

Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│  Discord User   │────▶│   Discord Bot    │────▶│ Anna's Archive  │
│                 │◀────│   (Container)    │◀────│                 │
└─────────────────┘     └────────┬─────────┘     └─────────────────┘
                                 │
                                 ▼
                        ┌─────────────────┐
                        │  /books volume  │
                        │  (Your Server)  │
                        └─────────────────┘

Troubleshooting

Bot not responding to commands

  1. Make sure the bot is online (check docker compose logs)
  2. Ensure you enabled "Message Content Intent" in Discord Developer Portal
  3. Wait a few minutes for slash commands to sync (can take up to an hour)

Downloads failing

  • Some books may have dead download links
  • Try a different search result
  • Check bot logs: docker compose logs -f

Permission errors

# Make sure the books directory is writable
chmod 755 ./books

View logs

docker compose logs -f book-bot

Restart the bot

docker compose restart

Rebuild after changes

docker compose up -d --build

Running Without Docker

If you prefer to run without Docker:

# Install Python 3.10+
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt

# Set environment variables
export DISCORD_TOKEN=your_token_here
export BOOKS_DIR=/path/to/books

# Run the bot
python bot.py

Legal Notice

This bot is for personal use only. Respect copyright laws in your jurisdiction. The bot simply automates searching and downloading from Anna's Archive - it does not host any content itself.

License

MIT License - feel free to modify and use as you wish.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published