|
|
||
|---|---|---|
| Anime | ||
| Games | ||
| Politics | ||
| config | ||
| controllers | ||
| models | ||
| views | ||
| LICENSE | ||
| README.md | ||
| app.py | ||
| index.html | ||
README.md
FuckingChat 🔒
Encrypted chat with multi-channel support and Tenor GIFs. Messages encrypted at rest (Fernet + PBKDF2/SHA256).
Quick start
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
- Choose mariadb as engine in config TUI.
- Fill in host, port, user, password, database name.
- Install driver:
pip install pymysql - 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 channelsGET /api/messages?channel=X— get messagesPOST /api/messages— send message{"channel":"X","message":"..."}DELETE /api/messages/:id— delete (requiresAuthorization: Bearer <admin_token>)GET /api/gifs/trending— trending GIFsGET /api/gifs/search?q=...— search GIFs