@@ -144,6 +144,36 @@ async def summon_wizard(update, context):
144
144
text = "Tu magx asignadx es: @{}" .format (wizard .username )
145
145
)
146
146
147
+ async def notify_scheduled_slots_to_wizard (update , context , pycamp , wizard , agenda ):
148
+ per_day = defaultdict (list )
149
+ for entry in agenda :
150
+ k = entry .init .strftime ("%a %d de %b" )
151
+ per_day [k ].append (entry )
152
+
153
+ msg = "Esta es tu agenda de mago para el PyCamp {}" .format (pycamp .headquarters )
154
+ for day , items in per_day .items ():
155
+ msg += "\n El día _{}_:\n " .format (day )
156
+ for i in items :
157
+ msg += "\t \\ - {} a {}\n " .format (
158
+ i .init .strftime ("%H:%M" ),
159
+ i .end .strftime ("%H:%M" ),
160
+ )
161
+
162
+ await context .bot .send_message (
163
+ chat_id = wizard .chat_id ,
164
+ text = msg ,
165
+ parse_mode = "MarkdownV2"
166
+ )
167
+
168
+
169
+ async def notify_schedule_to_wizards (update , context , pycamp ):
170
+ for wizard in pycamp .get_wizards ():
171
+ wizard_agenda = WizardAtPycamp .select ().where (
172
+ WizardAtPycamp .pycamp == pycamp & WizardAtPycamp .wizard == wizard
173
+ ).order_by (WizardAtPycamp .init )
174
+
175
+ await notify_scheduled_slots_to_wizard (update , context , pycamp , wizard , wizard_agenda )
176
+
147
177
148
178
def persist_wizards_schedule_in_db (pycamp ):
149
179
"""
@@ -169,12 +199,7 @@ async def schedule_wizards(update, context):
169
199
170
200
persist_wizards_schedule_in_db (pycamp )
171
201
172
- # Mandar mensajes a los magos con su agenda propia
173
- msg = "Lista la agenda de magos."
174
- await context .bot .send_message (
175
- chat_id = update .message .chat_id ,
176
- text = msg
177
- )
202
+ notify_schedule_to_wizards (update , context , pycamp )
178
203
179
204
180
205
async def show_wizards_schedule (update , context ):
0 commit comments