FuckingChat/README.md

98 lines
2.9 KiB
Markdown

# FuckingChat 🔒
Encrypted chat with multi-channel support and Tenor GIFs.
Messages encrypted at rest (Fernet + PBKDF2/SHA256).
## Quick start
```bash
pip install bottle cryptography sqlalchemy
# First run — configure everything interactively
python app.py -c
# Then start the server
python app.py
```
## Project structure (MVC)
```
├── app.py # Entry point
├── index.html # Frontend (single-page)
├── config/
│ ├── __init__.py
│ ├── schema.py # Dataclass definitions
│ └── config.py # JSON serializer / loader
├── models/
│ ├── __init__.py
│ ├── base.py # SQLAlchemy ORM + engine factory
│ └── db.py # DBfrontend (encrypted CRUD)
├── controllers/
│ ├── __init__.py
│ ├── chat.py # Chat API endpoints
│ └── tenor.py # Tenor GIF proxy
├── views/
│ ├── __init__.py
│ └── config_tui.py # curses TUI configuration wizard
├── Anime/README.md
├── Games/README.md
├── Politics/README.md
└── README.md
```
## Configuration
Run `python app.py -c` to open the curses TUI:
- **Server** — host, port, debug mode
- **Security** — encryption secret, salt, admin token, rate limits
- **Database** — SQLite (default) or MariaDB
- **Tenor API** — API key for GIF search
Config is saved as `chat_config.json` in the project root.
Override path: `python app.py --config /path/to/config.json`
### Environment overrides
| Variable | Overrides config field |
|---|---|
| `CHAT_CONFIG` | Config file path |
| `CHAT_SECRET` | Encryption secret |
| `CHAT_SALT` | Encryption salt |
| `CHAT_ADMIN_TOKEN` | Admin token |
| `CHAT_RATE_LIMIT` | Rate limit |
| `CHAT_RATE_WINDOW` | Rate window (sec) |
| `CHAT_MAX_MSG` | Max message length |
| `CHAT_DB_PATH` | SQLite path |
| `CHAT_HOST` | Listen address |
| `CHAT_PORT` | Listen port |
| `CHAT_DEBUG` | Debug mode (1/0) |
| `TENOR_API_KEY` | Tenor API key |
## MariaDB setup
1. Choose **mariadb** as engine in config TUI.
2. Fill in host, port, user, password, database name.
3. Install driver: `pip install pymysql`
4. Start the server.
## Security
- ✅ Messages encrypted at rest (AES via Fernet)
- ✅ Rate limiting (configurable)
- ✅ IP hashing (privacy)
- ✅ XSS protection (HTML tag stripping, inline-gif whitelist)
- ✅ Admin token required for DELETE
- ✅ No debug mode in production
- ✅ API keys stored server-side only (Tenor proxy)
## API
- `GET /api/channels` — list channels
- `GET /api/messages?channel=X` — get messages
- `POST /api/messages` — send message `{"channel":"X","message":"..."}`
- `DELETE /api/messages/:id` — delete (requires `Authorization: Bearer <admin_token>`)
- `GET /api/gifs/trending` — trending GIFs
- `GET /api/gifs/search?q=...` — search GIFs