Updated README, added Dockerfile
This commit is contained in:
1 parent
7ba729f372
commit
dd671dba8c
3 files changed
+234
-1
No files matched your search
@@ -0,0 +1,36 @@
|
|||||||
|
# Version control
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
*.egg-info
|
||||||
|
*.egg
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.whl
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
bot-env/
|
||||||
|
.venv/
|
||||||
|
env/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Token (sensitive!)
|
||||||
|
.token
|
||||||
|
|
||||||
|
# Docker files (avoid recursive builds)
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
# ---- Base image ----
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install system dependencies (if needed by native extensions)
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy and install Python dependencies
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy plugin assets
|
||||||
|
COPY plugins/pepe/pepes.txt ./plugins/pepe/pepes.txt
|
||||||
|
|
||||||
|
# Copy the rest of the application
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Create a non-root user for security
|
||||||
|
RUN useradd -m -s /bin/bash botuser && chown -R botuser:botuser /app
|
||||||
|
USER botuser
|
||||||
|
|
||||||
|
# Expose nothing by default (Discord bot doesn't need a public port)
|
||||||
|
|
||||||
|
# Run the bot
|
||||||
|
CMD ["python", "main.py"]
|
||||||
@@ -1 +1,169 @@
|
|||||||
Dankbot, now even danker!
|
# 🐸 Dank Bot
|
||||||
|
|
||||||
|
A Discord bot built with [discord.py](https://github.com/Rapptz/discord.py), featuring a plugin-based architecture for extensible functionality.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Plugin System**: Easily add new features by dropping a plugin into the `plugins/` directory
|
||||||
|
- **BotChat Plugin**: AI-powered chat responses with configurable prompts
|
||||||
|
- **Pepe Plugin**: Classic Pepe meme reactions
|
||||||
|
- **Logging**: Full command and message logging via Python's `logging` module
|
||||||
|
|
||||||
|
## Current Plugins
|
||||||
|
|
||||||
|
| Plugin | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `botchat` | AI chat plugin with prompt templates and censorship support |
|
||||||
|
| `pepe` | Pepe meme reaction plugin |
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- [Python 3.12+](https://www.python.org/downloads/)
|
||||||
|
- A [Discord Bot Token](https://discord.com/developers/docs/topics/oauth2#bot)
|
||||||
|
- A Discord application with the `MESSAGE CONTENT INTENT` enabled
|
||||||
|
|
||||||
|
## Quick Start (Docker)
|
||||||
|
|
||||||
|
### 1. Create a token file
|
||||||
|
|
||||||
|
Create a `.token` file with your Discord bot token:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "YOUR_DISCORD_BOT_TOKEN_HERE" > .token
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Build and run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the Docker image
|
||||||
|
docker build -t dank-bot .
|
||||||
|
|
||||||
|
# Run the bot
|
||||||
|
docker run -d \
|
||||||
|
--name dank-bot \
|
||||||
|
--env DISCORD_TOKEN=$(cat .token) \
|
||||||
|
dank-bot
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** The bot reads its token from a `.token` file at runtime. Mount it as a volume:
|
||||||
|
> ```bash
|
||||||
|
> docker run -d \
|
||||||
|
> --name dank-bot \
|
||||||
|
> -v $(pwd)/.token:/app/.token:ro \
|
||||||
|
> dank-bot
|
||||||
|
> ```
|
||||||
|
|
||||||
|
## Prerequisites (Local)
|
||||||
|
|
||||||
|
- [Python 3.12+](https://www.python.org/downloads/)
|
||||||
|
- [pip](https://pip.pypa.io/)
|
||||||
|
|
||||||
|
## Local Setup
|
||||||
|
|
||||||
|
### 1. Create a token file
|
||||||
|
|
||||||
|
Create a `.token` file with your Discord bot token:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "YOUR_DISCORD_BOT_TOKEN_HERE" > .token
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Run the bot
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
dank-bot-py/
|
||||||
|
├── main.py # Bot entry point
|
||||||
|
├── requirements.txt # Python dependencies
|
||||||
|
├── start.sh # Quick start script
|
||||||
|
├── .token # Discord bot token (DO NOT COMMIT)
|
||||||
|
├── .gitignore
|
||||||
|
├── .dockerignore
|
||||||
|
├── Dockerfile
|
||||||
|
├── README.md
|
||||||
|
└── plugins/
|
||||||
|
├── botchat/ # AI chat plugin
|
||||||
|
│ ├── plugin.py
|
||||||
|
│ ├── settings.yaml
|
||||||
|
│ └── prompts/ # Prompt templates
|
||||||
|
│ ├── default.txt
|
||||||
|
│ ├── default-censored.txt
|
||||||
|
│ ├── summarize.txt
|
||||||
|
│ └── summarize-search.txt
|
||||||
|
└── pepe/ # Pepe meme plugin
|
||||||
|
├── plugin.py
|
||||||
|
└── pepes.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Adding a New Plugin
|
||||||
|
|
||||||
|
1. Create a new directory under `plugins/`
|
||||||
|
2. Add a `plugin.py` file with your bot extension code
|
||||||
|
3. The bot will auto-discover and load it on startup
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `!help` | List available commands |
|
||||||
|
| `!chat <message>` | Send a message to the AI chat (via botchat plugin) |
|
||||||
|
| `!pepe` | Trigger a Pepe meme reaction |
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
- **BotChat**: Edit `plugins/botchat/settings.yaml` for plugin settings
|
||||||
|
- **Prompts**: Modify files in `plugins/botchat/prompts/` to customize AI behavior
|
||||||
|
- **Token**: Store in `.token` (never commit this file)
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t dank-bot .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name dank-bot \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-v $(pwd)/.token:/app/.token:ro \
|
||||||
|
dank-bot
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker logs -f dank-bot
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stop
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker stop dank-bot
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
| Variable | Description | Default |
|
||||||
|
|----------|-------------|---------|
|
||||||
|
| `LOG_LEVEL` | Logging verbosity | `INFO` |
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
- **Never commit your `.token` file** — it's included in `.gitignore` for this reason
|
||||||
|
- The Docker image runs as a non-root user (`botuser`) for added security
|
||||||
|
- Use Docker volume mounts for sensitive files instead of baking them into the image
|
||||||
Reference in new issue
Block a user