Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .claude/skills/control-vinci/references/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subject bots' work itself. The Telegram column is what `telegram = true` brings
| Assignment detail | `ver_tarea` in `herramientas.py`, `src/aula_core/queries.py`, `materials.py` | ask «¿qué pide <tarea>?» through `chat`; check annexes, rubric and dates (uses the model) |
| Finding an assignment and searching its annexes | `queries.find_assignments` (`tareas` with `buscar`), `_search` with `tarea_id`, `search.search(file_ids=…)` | `vinci-check say "en el <tarea por su tema>, qué piden de …?"`, then `vinci-check whatsapp --chat dm`: hits marked `de_la_tarea` first |
| What happened to a submission | `conversation.submissions` (line «Entregas en el aula» of the turn context) | after a `prepare_submission`, the next DM turn says it waits for the vote |
| DSpace | `src/aula_core/dspace.py` | ask for past exams through `chat` (uses the model) |
| DSpace | `src/aula_core/dspace.py` (the «un momento» line goes to the chat that asked: `herramientas._working`; a terminal session sends nothing to a chat: `_no_chat`) | ask for past exams through `say` (uses the model) |
| Schedule | `src/espol_bot/horario.py` | `chat <subject bot> /start` |
| Chat context | `src/espol_bot/conversation.py`, `espol-bot contexto`, hook `pre_llm_call` in `hermes/plugins/vinci-botones/` | `vinci-check whatsapp --chat dm`: the user turn ends with «[Contexto de este chat…]» and today's clock |
| Focus and activities | `conversation.py` (`note_turn`, `open_activities`), `materias.mentioned`, `study_activity` and `send_quiz` in `herramientas.py`, `quiz.resend` | `vinci-check say "estamos en <materia>"`, then `vinci-check whatsapp --chat dm`: «Materia en foco» in the next turn |
Expand Down
3 changes: 2 additions & 1 deletion docs/guia/uso.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ las facultades, del 2007 a hoy, sin solución. Vinci y los bots de materia saben
les preguntas por exámenes: nada corre en segundo plano.

1. Le pides exámenes a Vinci (de cualquier materia) o al bot de la materia. Puedes pedir años o un parcial.
2. El bot te avisa «🔎 Un momento, busco exámenes anteriores en DSpace…» y busca en vivo. Una búsqueda tarda de 1 a
2. El bot te avisa «🔎 Un momento, busco exámenes anteriores en DSpace…» en el chat donde se lo pediste (por WhatsApp,
en tu chat o en el grupo) y busca en vivo. Una búsqueda tarda de 1 a
20 segundos.
3. Los títulos de DSpace no traen el código de la materia, así que el bot busca por el nombre y prueba otras formas
si la primera no encuentra nada: el nombre completo, abreviado («Prog. Orientada a Objetos»), el nombre viejo o
Expand Down
20 changes: 15 additions & 5 deletions src/espol_bot/herramientas.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def _stale_note(ctx: Ctx) -> str:
fix = ""
if ctx.stale.token and ctx.code is not None:
fix = ", y que renueve el token mandándole /token a Vinci"
elif ctx.stale.token and _whatsapp_chat(ctx) is not None:
elif ctx.stale.token and _whatsapp_chat(ctx, to_send=False) is not None:
fix = (", y mándale el formulario del token con show_page (page: token) si todavía no se lo mandaste en esta "
"conversación")
elif ctx.stale.token:
Expand Down Expand Up @@ -849,9 +849,11 @@ def _working(ctx: Ctx, kind: str, text: str):
the academic calendar."""
key = f"notice:{ctx.bot}:{kind}"
last = get_meta(ctx.conn, key)
if not last or time.time() - float(last) >= NOTICE_GAP:
if (not last or time.time() - float(last) >= NOTICE_GAP) and not _no_chat(ctx):
try:
Telegram(load_telegram_secrets(ctx.code), api=ctx.cfg.telegram_api).send(text)
group = _group_chat(ctx)
chat = WhatsApp(group, ctx.cfg.whatsapp_bridge) if group else _whatsapp_chat(ctx)
(chat or Telegram(load_telegram_secrets(ctx.code), api=ctx.cfg.telegram_api)).send(text)
except (TelegramError, ConfigError) as exc: # a courtesy: the work goes on without it
log.warning("aviso «%s»: %s", kind, exc)
try:
Expand Down Expand Up @@ -1323,9 +1325,17 @@ def _press(ctx: Ctx, data: str) -> dict:
"mensaje": "Confírmaselo en una línea, con tus palabras."}


def _whatsapp_chat(ctx: Ctx) -> WhatsApp | None:
def _no_chat(ctx: Ctx) -> bool:
"""A terminal session (`hermes chat`, `vinci-check eval`): it is nobody's chat, so nothing goes out to one."""
return _channel(ctx).get("canal") == "cli"


def _whatsapp_chat(ctx: Ctx, *, to_send: bool = True) -> WhatsApp | None:
"""The owner's private WhatsApp chat when this conversation happens on WhatsApp; a friend's Vinci lives there.
None: Telegram."""
None: Telegram. `to_send` False only asks where the conversation is."""
if to_send and _no_chat(ctx):
raise ToolError("Esta conversación es de la terminal, no de un chat: no hay a dónde mandarlo. Contesta con "
"texto.")
owner = None
if ctx.cfg.friend:
owner = load_secret_values().get("WHATSAPP_OWNER")
Expand Down
13 changes: 12 additions & 1 deletion tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
test_whatsapp_captain, the gateway serving the captain's chat: setup.sh routes his WhatsApp to Vinci (and anyone else
to Vinci's guest tools); his week; a question split across two bubbles answered once; work handed in outside the aula stays pending and late until he says it is done
(and back with «todavía no»), an exam held in class leaves on its own, and the summary lists the same; Física's
Modules gain a class recording, a Zoom ID subheader and Perusall, and Vinci gives each with its aula link; /start and /token without the model; the 07:00 summary in WhatsApp's format; the
Modules gain a class recording, a Zoom ID subheader and Perusall, and Vinci gives each with its aula link; past
exams from DSpace, whose «un momento» line goes to his WhatsApp chat; /start and /token without the model; the 07:00 summary in WhatsApp's format; the
brief before a class as a system task Vinci answers in his chat; Vinci writes the notebook of the subject he names,
and a note with no subject goes to the one he named a moment ago (the focus in every turn's context); a /quiz left
half answered stays open in that context («respondió 1 de 2») and «sigamos con el quiz» re-sends only the missing
Expand Down Expand Up @@ -2273,6 +2274,16 @@ def test_whatsapp_captain(tmp_path):
f"{canvas.base}/courses/102/modules/items/81093") in perusall, perusall
assert "CLASES VIRTUALES · título: ID ZOOM: 829 0000 0001" in recording, recording
md.append(f"→ Vinci (grabación): {normalize(recording)}\n→ Vinci (Perusall): {normalize(perusall)}\n")
# 10a-3. Past exams: the «un momento» line of a slow search goes to the chat that asked, not to Telegram
# (the world's tripwire records any request there).
exams = say(captain_jid, captain_jid, "búscame exámenes anteriores de POO", "Capitán", expect=2)
assert "busco exámenes anteriores en DSpace" in exams[0]["message"], exams
assert "Programación Orientada a Objetos" in text_of(exams[1:]), exams
assert w.tripwire.requests == [], w.tripwire.requests
report.append("«búscame exámenes anteriores de POO»: el aviso «Un momento, busco exámenes anteriores en "
"DSpace…» llega al chat de WhatsApp donde lo pidió, una sola vez aunque busque por dos nombres, "
"y después la lista")

# 10f'. «¿qué tengo pendiente?» in private: a short answer, with a button to his dashboard (show_page)
asked = say(captain_jid, captain_jid, "qué tengo pendiente esta semana", "Capitán", expect=2)
[panel] = [m for m in asked if m["path"] == "send-url-button"]
Expand Down
Loading