Skip to content

Commit 864fb62

Browse files
committed
Added command to list the registered mages
1 parent 1cc72ab commit 864fb62

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@ Para agendar los magos:
9393
* `/votar` envia opciones para votar (si está habilitada la votacion)
9494
* `/ver_cronograma` te muestra el cronograma!
9595
* `/ser_magx` te registra como mago.
96+
* `/ver_magx` Lista los magos registrados.
9697
* `/evocar_magx` llama al mago de turno para pedirle ayuda.
9798
* `/ver_agenda_magx completa` te muestra la agenda de magos del PyCamp. El parámetro `completa` es opcional, si se omite solo muestra los turnos pendientes.

src/pycamp_bot/commands/wizard.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def clean_wizards_free_slots(pycamp, slots):
4949

5050
def compute_wizards_slots(pycamp):
5151
"""
52-
* Magos trabajan de 9 a 19, sacando almuerzo (13 a 14).
53-
* Magos trabajan desde el mediodía del primer día, hasta el mediodía del último día.
52+
* Magxs trabajan de 9 a 19, sacando almuerzo (13 a 14).
53+
* Magxs trabajan desde el mediodía del primer día, hasta el mediodía del último día.
5454
Slots son [start; end)
5555
"""
5656
wizard_start = pycamp.init
@@ -84,9 +84,9 @@ def define_wizards_schedule(pycamp):
8484
wizard = wizards_list[idx%n_wizards]
8585
n_iter = 0 # railguard
8686
while wizard.is_busy(slot):
87-
logger.info('Mago {} con conflicto en el slot {}. Pruebo otro.'.format(wizard.username, slot))
87+
logger.info('Magx {} con conflicto en el slot {}. Pruebo otro.'.format(wizard.username, slot))
8888
if n_iter == n_wizards:
89-
logger.warning('Queda el mago {} con conflicto en el slot {}'.format(wizard, slot))
89+
logger.warning('Queda el magx {} con conflicto en el slot {}'.format(wizard, slot))
9090
break
9191
idx += 1
9292
wizard = wizards_list[idx%n_wizards]
@@ -116,6 +116,20 @@ async def become_wizard(update, context):
116116
)
117117

118118

119+
async def list_wizards(update, context):
120+
_, pycamp = get_active_pycamp()
121+
msg = ""
122+
for i, wizard in enumerate(pycamp.get_wizards()):
123+
msg += "{}) @{}\n".format(i+1, wizard.username)
124+
try:
125+
await context.bot.send_message(
126+
chat_id=update.message.chat_id,
127+
text=msg
128+
)
129+
except BadRequest as e:
130+
logger.exception("Coulnd't deliver the Wizards list to {}".format(update.message.from_user.username))
131+
132+
119133
async def summon_wizard(update, context):
120134
_, pycamp = get_active_pycamp()
121135
wizard = pycamp.get_current_wizard()
@@ -152,7 +166,7 @@ async def notify_scheduled_slots_to_wizard(update, context, pycamp, wizard, agen
152166
k = entry.init.strftime("%a %d de %b")
153167
per_day[k].append(entry)
154168

155-
msg = "Esta es tu agenda de mago para el PyCamp {}".format(pycamp.headquarters)
169+
msg = "Esta es tu agenda de magx para el PyCamp {}".format(pycamp.headquarters)
156170
for day, items in per_day.items():
157171
msg += "\nEl día _{}_:\n".format(day)
158172
for i in items:
@@ -229,7 +243,7 @@ def format_wizards_schedule(agenda):
229243
k = entry.init.strftime("%a %d de %b")
230244
per_day[k].append(entry)
231245

232-
msg = "Agenda de magos:"
246+
msg = "Agenda de magxs:"
233247
for day, items in per_day.items():
234248
msg += "\nEl día _{}_:\n".format(day)
235249
for i in items:
@@ -288,6 +302,8 @@ def set_handlers(application):
288302
CommandHandler('evocar_magx', summon_wizard))
289303
application.add_handler(
290304
CommandHandler('ser_magx', become_wizard))
305+
application.add_handler(
306+
CommandHandler('ver_magx', list_wizards))
291307
application.add_handler(
292308
CommandHandler('agendar_magx', schedule_wizards))
293309
application.add_handler(

0 commit comments

Comments
 (0)