Code-Society-Lab / Code-Society-Lab/matrixpy

Dialog

Aperta
#92 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
blocked feature
Lingua principale
Python
Stelle
14
Fork
7
Merge medio
8g 19h
PR unite (30g)
5

Descrizione

There is no built-in way to hold a multi-step conversation. Developers who need to collect several pieces of information from a user in sequence have to manage state and event listeners by hand.

The idea is to introduce a `@bot.dialog()` decorator that provides a structured async API for step-by-step interactions. A dialog would expose `ctx.ask()` to send a prompt and `ctx.next_message()` to await the user's next reply in the same room, keeping the conversational state encapsulated in a single coroutine.

**Proposed API**
```python
@bot.dialog("setup")
async def setup_dialog(ctx):
name = await ctx.ask("What's your name?")
await ctx.reply(f"Nice to meet you, {name}!")
```

The main design challenges are timeout handling (what happens if the user never replies), cancellation (the user starts a second dialog mid-way), and isolation (messages from other users in the same room should not be captured as answers). A `timeout` parameter on the decorator and a room+sender keyed wait queue on the bot are the most likely implementation paths. Also worth considering: whether dialogs should be re-entrant or exclusive per user per room.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia esaminando come vengono gestiti i decoratori dei bot e gli event listener, quindi valuta come un dialogo potrebbe attendere le risposte isolandole per stanza e mittente. Prima dell’implementazione, stabilisci il timeout, l’annullamento e se i dialoghi sono rientranti o esclusivi; il lavoro è completato quando l’API asincrona proposta ha un comportamento definito per questi casi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.