Skip to content

Commit 4729183

Browse files
committed
Merge branch 'dev'
2 parents 19b9d36 + 25a46a2 commit 4729183

5 files changed

Lines changed: 61 additions & 13 deletions

File tree

.github/workflows/releases.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
jobs:
9+
release:
10+
name: Create release with tag '${{ github.ref_name }}'
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Create GitHub Release
15+
env:
16+
GITHUB_TOKEN: ${{ github.token }}
17+
run: >
18+
gh release create '${{ github.ref_name }}'
19+
--repo '${{ github.repository }}'
20+
--generate-notes

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Historial con detalles de cambios entre versiones del asistente.
44

55
| | | | | Version |
66
|:----------------:|:----------------:|:----------------:|:----------------:|:----------------:|
7+
| | | | |**[2.0.1](#v201)**|
78
| | | | [1.4.1](#v141) |**[2.0.0](#v200)**|
89
| | | | |**[1.4.0](#v140)**|
910
| | | | [1.2.1](#v121) |**[1.3.0](#v130)**|
@@ -13,6 +14,12 @@ Historial con detalles de cambios entre versiones del asistente.
1314

1415
<hr/>
1516

17+
### v2.0.1
18+
19+
* _fixes_ para bugs de parámetros de búsqueda en `/random`
20+
21+
<hr style="height:2px" />
22+
1623
## v2.0.0
1724

1825
* **El bot ahora se llama *"Asistente de Fundamentos"*, ya no *"Lector de Ejercicios"***. Esto es para ser más conforme con futuras características.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
![status](https://dcbadge.limes.pink/api/shield/889312376036425810?bot=true?logoColor=presence&theme=discord)
88

9-
![version](https://img.shields.io/badge/version-2.0.0-brightgreen)
9+
![version](https://img.shields.io/badge/version-2.0.1-brightgreen)
1010
![estrellas](https://img.shields.io/github/stars/NLGS2907/Asistente-Fundamentos?label=Estrellas&style=social)
1111
![forks](https://img.shields.io/github/forks/NLGS2907/Asistente-Fundamentos?style=social)
1212
![Tests](https://github.com/NLGS2907/Asistente-Fundamentos/actions/workflows/tests.yml/badge.svg)

asistente/bot/asistente.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def version() -> tuple[int, int, int]:
4747
indicando una revisión importante, un parche mayor, o un parche menor respectivamente.
4848
"""
4949

50-
return (2, 0, 0)
50+
return (2, 0, 1)
5151

5252

5353
@staticmethod

asistente/cogs/comandos/ejercicios.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,17 @@ async def ejercicio_al_azar(self,
212212
"""
213213

214214
guia = get_guia_por_sv(interaccion.guild_id)
215+
guia.pop("version")
216+
217+
if isinstance(sentido, Choice):
218+
sentido_parseado = sentido.value
219+
else: # str
220+
sentido_parseado = sentido
215221

216222
unidad_posible_real = (unidad_posible if unidad_posible is None else unidad_posible.value)
217-
unidad_pivote = (unidad_posible_real
218-
if CogEjercicios.existe_unidad(unidad_posible_real, guia)
219-
else choice(list(guia.keys())))
223+
unidad_pivote = int(unidad_posible_real
224+
if CogEjercicios.existe_unidad(unidad_posible_real, guia)
225+
else choice(list(guia.keys())))
220226
unidad_elegida = ''
221227
ejercicio_elegido = ''
222228

@@ -226,29 +232,44 @@ def _expresion_busqueda(unidad: int) -> bool:
226232
incluirlo entre los candidatos.
227233
"""
228234

229-
match sentido:
235+
match sentido_parseado:
230236
case '=':
231-
return unidad == int(unidad_pivote)
237+
return unidad == unidad_pivote
232238

233239
case '<':
234-
return unidad < int(unidad_pivote)
240+
return unidad < unidad_pivote
235241

236242
case "<=":
237-
return unidad <= int(unidad_pivote)
243+
return unidad <= unidad_pivote
238244

239245
case '>':
240-
return unidad > int(unidad_pivote)
246+
return unidad > unidad_pivote
241247

242248
case ">=":
243-
return unidad >= int(unidad_pivote)
249+
return unidad >= unidad_pivote
244250

245251
case _:
246252
# Viene de un Choice, así que nunca va a ocurrir. Pero por si acaso, suponemos
247253
# que una expresión de 'sentido' inválida, hace incorrectas a todos los números.
248254
return False
249255

250-
unidad_elegida = choice([unidad for unidad in list(guia.keys())[1:]
251-
if _expresion_busqueda(int(unidad))])
256+
candidatos = [unidad for unidad in guia.keys() if _expresion_busqueda(int(unidad))]
257+
258+
# El usuario eligió justo un parámetro de búsqueda que no retorna ningún candidato viable:
259+
# Un ejemplo sería si se elige la unidad 1 de pivote pero con parámetro "Antes de".
260+
# Naturalmente, no va a retornar nada.
261+
if not candidatos:
262+
await interaccion.response.send_message(
263+
content="No hay unidades de la guía que coincidan con los parámetros de búsqueda "
264+
f"dados y la unidad pivote `{unidad_pivote}. "
265+
f"{guia[str(unidad_pivote)]['titulo']}`.",
266+
ephemeral=True
267+
)
268+
return
269+
270+
unidad_elegida = choice(candidatos)
271+
# para que no agarre el titulo ni por casualidad, lo sacamos
272+
guia[unidad_elegida].pop("titulo")
252273
ejercicio_elegido = choice(list(guia[unidad_elegida].keys()))
253274

254275
await self.mandar_ejercicio(interaccion,

0 commit comments

Comments
 (0)