From f2016da05abf7fe7c5e99bf2ea8703586601885c Mon Sep 17 00:00:00 2001 From: unfunny Date: Sun, 13 Sep 2026 01:06:50 -0400 Subject: [PATCH] docs: update deployment instructions with all three methods (.env file, docker run env vars, docker-compose) --- .env.example | 8 +++-- Dockerfile | 15 +++++++-- README.md | 87 ++++++++++++++++++++++++++++++++++------------------ 3 files changed, 77 insertions(+), 33 deletions(-) diff --git a/.env.example b/.env.example index 9057a62..4ae0de7 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,9 @@ # Matrix Ancestor Quote Bot Configuration -MATRIX_HOME_SERVER=https://your.matrix.server.com:443 +# Replace these values with your own: +MATRIX_HOME_SERVER=https://matrix.org MATRIX_ACCESS_TOKEN=your_access_token_here -BOT_COMMAND=!quote \ No newline at end of file +BOT_COMMAND=!quote + +# Optional: Enable debug logging (set to false in production) +DEBUG=false diff --git a/Dockerfile b/Dockerfile index 1fa0df2..d5d6b7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,18 @@ FROM node:18-alpine + WORKDIR /app + +# Copy package files first for better layer caching COPY package*.json ./ + +# Install dependencies (including dotenv) RUN npm install + +# Copy application source code COPY . . -RUN npm prune --production -CMD ["node", "index.js"] \ No newline at end of file + +# Expose port if needed (optional, Matrix uses websocket) +# EXPOSE 3000 + +# Run the bot (dotenv will auto-load from /app/.env or environment variables) +CMD ["node", "index.js"] diff --git a/README.md b/README.md index 8aa7abd..d9ec583 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,69 @@ -# Ancestor Quote Bot +# Ancestor Quote Bot 🎃 -A Matrix chatbot that responds to `/quote` commands with random quotes from Darkest Dungeons' Narrator/Ancestor. +A Matrix chatbot that responds to `!quote` commands with random quotes from Darkest Dungeons. -## Setup +## Quick Start -1. Copy `.env.example` to `.env` and fill in your credentials: - ```bash - cp .env.example .env - ``` +```bash +# 1. Update .env file (create from template) +cp .env.example .env +# Edit .env with your MATRIX_ACCESS_TOKEN and MATRIX_HOME_SERVER -2. Build the Docker image: - ```bash - docker build -t ancestor-quote-bot . - ``` +# 2. Build Docker image +docker build -t ancestor-quote-bot . -3. Run the bot: - ```bash - docker run --rm \ - -e MATRIX_HOME_SERVER=https://your.matrix.server.com \ - -e MATRIX_ACCESS_TOKEN=your_access_token_here \ - ancestor-quote-bot - ``` +# 3. Run the bot +docker run --rm \ + -e MATRIX_HOME_SERVER=https://matrix.org \ + -e MATRIX_ACCESS_TOKEN=your_token_here \ + ancestor-quote-bot +``` + +## Deployment Options + +### Option 1: Pass env vars via `docker run` (Recommended for Docker) +```bash +docker run --rm \ + -e MATRIX_HOME_SERVER=https://matrix.org \ + -e MATRIX_ACCESS_TOKEN=your_access_token_here \ + -e BOT_COMMAND=!quote \ + ancestor-quote-bot +``` + +### Option 2: Mount .env file directly +```bash +docker run --rm \ + -v $(pwd)/.env:/app/.env \ + ancestor-quote-bot +``` + +### Option 3: Use docker-compose.yml (Production) +```bash +docker compose up -d +# Or with custom env: +docker compose up -d \ + -e MATRIX_HOME_SERVER=https://matrix.org \ + -e MATRIX_ACCESS_TOKEN=your_access_token_here +``` ## Configuration -- `MATRIX_HOME_SERVER`: Your Matrix homeserver URL (e.g., https://matrix.org) -- `MATRIX_ACCESS_TOKEN`: Bot access token for authentication -- `BOT_COMMAND`: The command trigger (default: `!quote`) +| Variable | Description | Default | +|----------|-------------|---------| +| `MATRIX_HOME_SERVER` | Matrix homeserver URL (e.g., https://matrix.org) | https://matrix.org | +| `MATRIX_ACCESS_TOKEN` | Bot access token for authentication | REQUIRED | +| `BOT_COMMAND` | Command trigger to request a quote | !quote | -## Usage +## How It Works -Type the bot command in any room you've joined, and it will reply with a random Ancestor quote. +1. The bot connects to your Matrix homeserver using the provided access token +2. Once joined to a room, it listens for messages containing the trigger command +3. When triggered, it selects a random quote from `quotes.json` and replies instantly -Example: -``` -Room: #general:matrix.org -!quote -Bot: Dispatch this thug in brutal fashion, that all may hear of your arrival! -``` +## Getting an Access Token + +Use [this](https://matrix.org/docs/projects/registration/matrix-registration-api) or your Matrix admin panel to register a bot account. + +## License + +ISC