Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
63129da
feat: add professional application entrypoint
Drako01 Aug 24, 2026
90955b5
chore: initialize pybot package
Drako01 Aug 24, 2026
601da14
feat: add typed environment configuration
Drako01 Aug 24, 2026
6384e6c
feat: add structured logging configuration
Drako01 Aug 24, 2026
780e964
feat: add sqlite persistence layer
Drako01 Aug 24, 2026
e47a1a2
feat: add extensible Discord bot core
Drako01 Aug 24, 2026
d1e9370
chore: initialize cogs package
Drako01 Aug 24, 2026
baca310
feat: add core slash commands
Drako01 Aug 24, 2026
da401fb
feat: add community events and guild configuration
Drako01 Aug 24, 2026
ce015a5
feat: add moderation toolkit and audit log
Drako01 Aug 24, 2026
b8a34dc
chore: initialize utilities package
Drako01 Aug 24, 2026
18ac22d
feat: add human duration parser
Drako01 Aug 24, 2026
941da08
feat: add useful community utility commands
Drako01 Aug 24, 2026
69faf5d
feat: add persistent reminder system
Drako01 Aug 24, 2026
b3799d7
chore: modernize production dependencies
Drako01 Aug 24, 2026
db1c925
chore: add development quality dependencies
Drako01 Aug 24, 2026
d702f3b
chore: configure Python tooling
Drako01 Aug 24, 2026
5c64d74
docs: add environment template
Drako01 Aug 24, 2026
c9f20c6
chore: harden Python gitignore
Drako01 Aug 24, 2026
f8b9076
chore: run Discord bot as worker process
Drako01 Aug 24, 2026
05a5689
ci: add Python quality pipeline
Drako01 Aug 24, 2026
331f44a
test: cover reminder duration parser
Drako01 Aug 24, 2026
00ba26c
test: cover environment configuration
Drako01 Aug 24, 2026
e57e488
test: cover sqlite persistence
Drako01 Aug 24, 2026
2ee97e3
chore: add production container image
Drako01 Aug 24, 2026
09220fd
chore: add dockerignore
Drako01 Aug 24, 2026
dd2e00c
feat: add secure self-assignable roles persistence
Drako01 Aug 24, 2026
c29d456
feat: add safe self-assignable roles
Drako01 Aug 24, 2026
c452580
refactor: remove legacy monolithic bot entrypoint
Drako01 Aug 24, 2026
4f74f6f
refactor: remove legacy event handlers
Drako01 Aug 24, 2026
0acdaa7
refactor: remove obsolete web entrypoint
Drako01 Aug 24, 2026
c059f37
chore: remove tracked Python bytecode
Drako01 Aug 24, 2026
22b9c01
chore: remove tracked Python bytecode
Drako01 Aug 24, 2026
bc6382c
docs: rewrite README as professional PyBot guide
Drako01 Aug 24, 2026
018e014
docs: document PyBot architecture
Drako01 Aug 24, 2026
91dceb1
docs: add complete command reference
Drako01 Aug 24, 2026
7376cba
docs: add deployment guide
Drako01 Aug 24, 2026
c766cf5
docs: add security policy
Drako01 Aug 24, 2026
bf3c182
docs: add contribution guide
Drako01 Aug 24, 2026
c16a913
docs: add v2 changelog
Drako01 Aug 24, 2026
56d45f5
docs: prepare PyBot v2 release notes
Drako01 Aug 24, 2026
1fc1449
docs: normalize MIT license filename
Drako01 Aug 24, 2026
1a00ebd
docs: remove noncanonical license filename
Drako01 Aug 24, 2026
242fb9b
test: cover self-role allowlist persistence
Drako01 Aug 24, 2026
689c625
docs: expose role commands in in-app help
Drako01 Aug 24, 2026
d9219b5
style: modernize Settings return annotation
Drako01 Aug 24, 2026
043f641
ci: focus Ruff on correctness rules
Drako01 Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.github
.env
.venv
venv
__pycache__
.pytest_cache
.ruff_cache
data
*.db
*.db-shm
*.db-wal
*.log
tests
README.md
docs
23 changes: 23 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Discord Developer Portal -> Bot -> Token
DISCORD_TOKEN=replace-me

# Opcional: guild de desarrollo para sincronizar slash commands inmediatamente.
# Si queda vacío, los comandos se sincronizan globalmente.
DEV_GUILD_ID=

# Persistencia local de configuración y recordatorios.
DATABASE_PATH=data/pybot.db

# INFO, DEBUG, WARNING, ERROR
LOG_LEVEL=INFO

# true para sincronizar comandos al iniciar.
SYNC_COMMANDS=true

# No es necesario para los slash commands actuales.
# Activarlo exige habilitar Message Content Intent en Discord Developer Portal.
ENABLE_MESSAGE_CONTENT_INTENT=false

BOT_STATUS=Usá /ayuda
CURRENCY_API_BASE_URL=https://dolarapi.com/v1
HTTP_TIMEOUT_SECONDS=8
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
contents: read

jobs:
quality:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements.txt
requirements-dev.txt

- name: Install dependencies
run: python -m pip install --upgrade pip && pip install -r requirements-dev.txt

- name: Ruff
run: ruff check .

- name: Compile
run: python -m compileall -q main.py pybot

- name: Tests
run: pytest -q
47 changes: 40 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
nuevaenv/*
myenv/*
/nuevaenv/*
/myenv/*
# Environment and secrets
.env
docker-compose.yml
/docker-compose.yml
Dockerfile
.env.*
!.env.example

# Virtual environments
.venv/
venv/
env/
myenv/
nuevaenv/

# Python
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
.ruff_cache/
.mypy_cache/
.coverage
htmlcov/

# Local data / persistence
data/
*.db
*.db-shm
*.db-wal

# IDE / OS
.vscode/
.idea/
.DS_Store
Thumbs.db

# Logs
*.log

# Build artifacts
build/
dist/
*.egg-info/
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Changelog

Todos los cambios relevantes de PyBot se documentan en este archivo.

El versionado sigue [Semantic Versioning](https://semver.org/).

## [2.0.0] — 2026-08-23

### Added

- arquitectura modular basada en Cogs;
- slash commands como interfaz principal;
- configuración tipada por variables de entorno;
- persistencia SQLite con `aiosqlite`;
- configuración por servidor para bienvenida, despedida, mod-log y autorol;
- self roles con allowlist administrativa;
- recordatorios persistentes;
- moderación con timeout, untimeout, kick, ban, purge y slowmode;
- validaciones de permisos y jerarquías;
- auditoría de acciones de moderación;
- consulta asíncrona de cotizaciones mediante DolarAPI;
- encuestas, elección aleatoria, dados, moneda y Google Maps;
- error handler global para application commands;
- una única `aiohttp.ClientSession` administrada por lifecycle;
- Dockerfile;
- CI para Python 3.11 y 3.12;
- Ruff, compile checks y pytest;
- tests de configuración, parsing de duración y persistencia;
- documentación de arquitectura, comandos, despliegue y seguridad;
- `CONTRIBUTING.md` y `.env.example`.

### Changed

- `discord.py` actualizado de 2.3.2 a 2.7.1;
- entrypoint movido a `main.py`;
- proceso Heroku/Procfile cambiado de `web` a `worker`;
- el bot deja de depender del parsing de mensajes libres para sus funciones centrales;
- `Message Content Intent` pasa a ser opcional y deshabilitado por defecto;
- la consulta de dólar deja de usar `requests` síncrono;
- roles por reacción reemplazados por self roles explícitos y seguros;
- README reescrito como guía completa de producto e ingeniería.

### Removed

- implementación monolítica antigua de `bot.py`;
- `events.py` legacy;
- `wsgi.py` obsoleto;
- bytecode `__pycache__` versionado;
- dependencias antiguas/no utilizadas como `requests`, `youtube-dl` y paquetes transitivos fijados manualmente.

### Security

- token exclusivamente desde entorno;
- `.env` ignorado;
- permisos mínimos documentados;
- controles de jerarquía para moderación y roles;
- Message Content Intent no requerido en operación estándar.
77 changes: 77 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Contribuir a PyBot

## Flujo recomendado

1. Crear una rama desde `main`.
2. Mantener cada cambio enfocado en un dominio.
3. Agregar o actualizar tests cuando corresponda.
4. Ejecutar lint y tests localmente.
5. Abrir PR explicando problema, solución y validación.

## Setup

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env
```

En Windows PowerShell:

```powershell
.\.venv\Scripts\Activate.ps1
Copy-Item .env.example .env
```

## Calidad

Antes del PR:

```bash
ruff check .
python -m compileall -q main.py pybot
pytest -q
```

## Arquitectura

- Los comandos deben vivir en el Cog del dominio correspondiente.
- No crear una `ClientSession` por request/comando.
- No usar librerías HTTP síncronas dentro de coroutines.
- El acceso SQLite debe pasar por `Database`.
- No leer variables de entorno directamente desde Cogs; usar `Settings`.
- Las acciones destructivas deben validar permisos y jerarquía.
- Evitar habilitar intents privilegiados si una feature no los necesita.

## Nuevos comandos

Al agregar un comando:

- usar slash commands;
- escribir `description` clara;
- usar tipos de Discord cuando corresponda (`Member`, `Role`, `TextChannel`);
- aplicar rangos con `app_commands.Range`;
- aplicar checks de permisos;
- responder `ephemeral=True` cuando la información sea administrativa o sensible;
- documentarlo en `docs/COMMANDS.md`.

## Persistencia

Los cambios de esquema deben ser compatibles con instalaciones existentes. `CREATE TABLE IF NOT EXISTS` es suficiente para tablas nuevas, pero cambios de columnas deben tratarse como migraciones explícitas en futuras versiones.

## Commits

Se recomienda Conventional Commits:

```text
feat: add ticket system
fix: prevent role hierarchy escalation
docs: explain production deployment
test: cover reminder parser
refactor: isolate external API client
```

## Seguridad

No incluir tokens reales, IDs privados innecesarios, `.env`, databases ni dumps de servidores en commits o fixtures.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1

WORKDIR /app

COPY requirements.txt .
RUN python -m pip install --upgrade pip && pip install -r requirements.txt

COPY . .
RUN mkdir -p /app/data

CMD ["python", "main.py"]
2 changes: 1 addition & 1 deletion LICENCE → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: python3.9 bot.py
worker: python main.py
Loading
Loading