2022-11-04 20:45:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								if  self . MESSAGE [ " text " ] . lower ( )  ==  " !пара " : 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        schedule  =  json . loads (  readfile ( self . path  +  " schedule.json " )  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        current_time  =  datetime . datetime . now ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        current_week  =  current_time . isocalendar ( ) [ 1 ]  %  2 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-05 18:42:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        current_day  =  current_time . weekday ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        current_seconds  =  current_time . hour  *  3600  +  current_time . minute  *  60  +  current_time . second 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-05 18:42:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        print ( " [DEBUG] Current day is  {} ( {} ) " . format ( type ( current_day ) ,  current_day ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        if  current_day  >  4  or  current_day  <  0 : 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            next_week  =  int ( not  bool ( current_week ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            day  =  - 1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            next_pair  =  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            pair_found  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            for  i  in  schedule [ next_week ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                if  not  pair_found : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    day  + =  1 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-05 18:42:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    for  j  in  schedule [ next_week ] [ day ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        next_pair  =  schedule [ next_week ] [ day ] [ j ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        pair_found  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2022-11-05 18:42:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								            self . RESPONCE  =  " Сьогодні вихідний, тому пар немає) \n Наступна пара -  {}  ( {} ) о    {}  у    {} \n Посилання (якщо воно чомусь треба):  {} " . format ( next_pair [ " subject " ] ,  next_pair [ " lector " ] ,  self . reverse_timetable [ int ( j ) ] ,  self . days_rod [ day ] ,  next_pair [ " link " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            for  i  in  self . timetable : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                if  current_seconds  <  i : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    print ( " [DEBUG] Looking up a relevant pair... " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    try : 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-05 18:42:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        relevant_pair  =  schedule [ current_week ] [ current_day ] [ str ( self . timetable [ i ] ) ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								                        self . RESPONCE  =  " Актуальна пара:  {}  ( {} ), початок о    {} \n Посилання:  {} " . format ( relevant_pair [ " subject " ] ,  relevant_pair [ " lector " ] ,  self . reverse_timetable [ self . timetable [ i ] ] ,  relevant_pair [ " link " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 20:12:48 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        print ( " [WARN] module: auto-schedule: exception  {}  while looking up the pair " . format ( e ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                self . RESPONCE  =  " Сьогодні більше немає пар " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        print ( " [WARN] module: auto-schedule: failed to process schedule.json ( {} ) " . format ( e ) )