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

Paginator

Aperta
#101 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

A `Paginator` class already exists in `matrix/help/pagination.py` and is used internally by the help command. It is not exported from the public API and provides no way to send pages to a room with reaction-based navigation, it only slices lists into `Page` objects.

The idea is to make `Paginator` a first-class public utility and extend it with a `send` method that posts the first page and handles ⬅️ / ➡️ reactions to let users navigate, making it straightforward to paginate any long output from a command.

**Proposed API**
```python
from matrix import Paginator

@bot.command()
async def members(ctx):
all_members = await ctx.room.get_members()
pages = Paginator(all_members, per_page=10, formatter=lambda m: f"- {m}")
await pages.send(ctx)
```

The existing `Paginator` and `Page` classes handle slicing correctly already; the work is adding the interactive layer. `send` would post the first page, add navigation reactions, then use `wait_for` (see related issue) to listen for reactions from the original sender and update the message in place. Editing a Matrix message uses the `m.replace` relationship type. The main question is whether to edit in place or post new messages per page, editing is cleaner but requires the bot to have the original event ID; posting new messages is simpler but noisy. Also worth exporting `Paginator` and `Page` from `matrix/__init__.py`.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Leggi prima matrix/help/pagination.py e matrix/__init__.py, poi esamina la issue correlata a wait_for e la relazione Matrix m.replace. Definisci se send modifica l’evento originale o pubblica nuovi messaggi e considera come vengono tracciati il mittente originale e le reazioni di navigazione; il lavoro è completato quando le esportazioni pubbliche e il comportamento di paginazione interattiva sono implementati coerentemente con tale decisione.

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

Valutazione

Stack tecnologico
python
Ambito
api, backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.