1313}
1414
1515
16- def _dictToString (dicto ):
17- if dicto :
18- return str (dicto ).replace (', ' , '\r \n ' ).replace ('}' , '\r \n ' ).replace ("u'" , "" ) \
19- .replace ("'" , "" ).replace ('[' , '\r \n ' ).replace (']' , '\r \n \r \n ' ) \
20- .replace (': {' , '\r \n ' )[1 :- 1 ]
21- else :
22- return "No tengo un cronograma para darte. Pedile a unx admin que haga /cronogramear"
16+ DIAS = {
17+ 'A' :'Jueves' ,
18+ 'B' :'Viernes' ,
19+ 'C' :'Sabado' ,
20+ 'D' :'Domingo' ,
21+ 'E' :'Lunes' ,
22+ 'F' :'Martes' ,
23+ 'G' :'Miercoles' ,
24+ }
2325
2426
2527async def cancel (update , context ):
@@ -79,6 +81,7 @@ async def define_slot_ammount(update, context):
7981 )
8082 return 2
8183
84+
8285async def define_slot_times (update , context ):
8386 text = update .message .text
8487 day = DAY_SLOT_TIME ['day' ][0 ]
@@ -124,7 +127,7 @@ async def create_slot(update, context):
124127 chat_id = update .message .chat_id ,
125128 text = "Genial! Slots Asignados"
126129 )
127- make_schedule (context .bot , update )
130+ await make_schedule (context .bot , update )
128131 return ConversationHandler .END
129132
130133
@@ -149,21 +152,33 @@ async def make_schedule(update, context):
149152 )
150153
151154
155+ async def check_day_tab (day , slots , cronograma , i ):
156+ try :
157+ if day != DIAS [slots [i - 1 ].code [0 ]]:
158+ cronograma += f'\n *{ day } :*\n '
159+ except Exception as e :
160+ print ("ERROR " , e )
161+ return cronograma
162+
163+
152164async def show_schedule (update , context ):
153165 slots = Slot .select ()
154166 projects = Project .select ()
155- cronograma = {}
167+ cronograma = "*Crónograma:* \n "
168+
169+ for i , slot in enumerate (slots ):
170+ day = DIAS [slot .code [0 ]]
171+ cronograma = await check_day_tab (day , slots , cronograma , i )
156172
157- for slot in slots :
158- cronograma [f'({ slot .code } ) { slot .start } :00hs' ] = []
159173 for project in projects :
160174 if project .slot_id == slot .id :
161- cronograma [ f'( { slot . code } ) { slot .start } :00hs' ]. append (project .name )
162- cronograma [ f'( { slot . code } ) { slot . start } :00hs' ]. append ( '@' + project .owner .username )
175+ cronograma += f'*-* { slot .start } :00hs = * { (project .name ). capitalize () } .* \n '
176+ cronograma += f'A cargo de 👉🏼 { "@" + project .owner .username } \n '
163177
164178 await context .bot .send_message (
165179 chat_id = update .message .chat_id ,
166- text = _dictToString (cronograma )
180+ text = cronograma ,
181+ parse_mode = 'Markdown'
167182 )
168183
169184
0 commit comments