forked from dymik739/modular-bot-framework-for-telegram
		
	Typos.
This commit is contained in:
		
							parent
							
								
									38d8674bbd
								
							
						
					
					
						commit
						2206bf6319
					
				@ -1,33 +1,31 @@
 | 
				
			|||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def readfile(filename):
 | 
					def readfile(filename):
 | 
				
			||||||
    with open(module_path + filename) as f:
 | 
					    with open(module_path + filename) as f:
 | 
				
			||||||
        return f.read()
 | 
					        return f.read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# global constants
 | 
					# global constants
 | 
				
			||||||
# Accusative - znahidnyj
 | 
					# Accusative - znahidnyj
 | 
				
			||||||
WEEKDAYS_ACCUSATIVE = ["понеділок", "вівторок", "середу", "четвер",
 | 
					WEEKDAYS_ACCUSATIVE = ["понеділок", "вівторок", "середу", "четвер", "п'ятницю", "суботу", "неділю"]
 | 
				
			||||||
                            "п'ятницю", "суботу", "неділю"]
 | 
					 | 
				
			||||||
# Genitive - rodovyj
 | 
					# Genitive - rodovyj
 | 
				
			||||||
WEEKDAYS_GENITIVE_NEXT = ["наступного понеділка", "наступного вівторка",
 | 
					WEEKDAYS_GENITIVE_NEXT = ["наступного понеділка", "наступного вівторка", "наступної середи", "наступного четверга",
 | 
				
			||||||
                               "наступної середи", "наступного четверга",
 | 
					                          "наступної п'ятниці", "наступної суботи", "наступної неділі"]
 | 
				
			||||||
                               "наступної п'ятниці", "наступної суботи",
 | 
					 | 
				
			||||||
                               "наступної неділі"]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WEEKDAYS_GENITIVE_THIS = ["цього понеділка", "цього вівторка",
 | 
					 | 
				
			||||||
                               "цієї середи", "цього четверга",
 | 
					 | 
				
			||||||
                               "цієї п'ятниці", "цієї суботи",
 | 
					 | 
				
			||||||
                               "цієї неділі"]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WEEKDAYS_GENITIVE_THIS = ["цього понеділка", "цього вівторка", "цієї середи", "цього четверга", "цієї п'ятниці",
 | 
				
			||||||
 | 
					                          "цієї суботи", "цієї неділі"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# global variables
 | 
					# global variables
 | 
				
			||||||
module_path = ""
 | 
					module_path = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_human_readable_date(start_datetime, end_datetime,
 | 
					def get_human_readable_date(start_datetime, end_datetime,
 | 
				
			||||||
                            current_day, current_week):
 | 
					                            current_day, current_week):
 | 
				
			||||||
    human_readable_date = ""
 | 
					    human_readable_date = ""
 | 
				
			||||||
    if ((current_day + 2) == int(start_datetime.strftime("%u"))) or ((current_day == 6) and (start_datetime.strftime("%u") == "1")):
 | 
					    if ((current_day + 2) == int(start_datetime.strftime("%u"))) or (
 | 
				
			||||||
 | 
					            (current_day == 6) and (start_datetime.strftime("%u") == "1")):
 | 
				
			||||||
        human_readable_date += "завтра "
 | 
					        human_readable_date += "завтра "
 | 
				
			||||||
    elif current_week != int(start_datetime.strftime("%W")) % 2:
 | 
					    elif current_week != int(start_datetime.strftime("%W")) % 2:
 | 
				
			||||||
        human_readable_date += f"{WEEKDAYS_GENITIVE_NEXT[int(start_datetime.strftime('%u')) - 1]} "
 | 
					        human_readable_date += f"{WEEKDAYS_GENITIVE_NEXT[int(start_datetime.strftime('%u')) - 1]} "
 | 
				
			||||||
@ -45,9 +43,7 @@ def get_human_readable_date(start_datetime, end_datetime,
 | 
				
			|||||||
    return human_readable_date
 | 
					    return human_readable_date
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def generate_lesson_description(lesson, start_datetime, end_datetime,
 | 
					def generate_lesson_description(lesson, start_datetime, end_datetime, current_day, current_week, overrides={}):
 | 
				
			||||||
                                current_day, current_week, overrides = {}):
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    output_settings = {"name": True, "date": True, "teacher": True, "link": True}
 | 
					    output_settings = {"name": True, "date": True, "teacher": True, "link": True}
 | 
				
			||||||
    output_settings.update(overrides)
 | 
					    output_settings.update(overrides)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -75,12 +71,12 @@ def get_schedule_data_from(filename):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    baked_schedule = {}
 | 
					    baked_schedule = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for daynum, lesson_times in enumerate(raw_schedule):
 | 
					    for day_number, lesson_times in enumerate(raw_schedule):
 | 
				
			||||||
        for lesson_time in lesson_times:
 | 
					        for lesson_time in lesson_times:
 | 
				
			||||||
            timestamp = daynum*86400 + int(lesson_time.split(":")[0])*3600 \
 | 
					            timestamp = day_number * 86400 + int(lesson_time.split(":")[0]) * 3600 \
 | 
				
			||||||
                        + int(lesson_time.split(":")[1]) * 60
 | 
					                        + int(lesson_time.split(":")[1]) * 60
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            new_record = dict(raw_schedule[daynum][lesson_time])
 | 
					            new_record = dict(raw_schedule[day_number][lesson_time])
 | 
				
			||||||
            new_record["source"] = filename.split(".json")[0]
 | 
					            new_record["source"] = filename.split(".json")[0]
 | 
				
			||||||
            baked_schedule[timestamp] = new_record
 | 
					            baked_schedule[timestamp] = new_record
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -109,8 +105,7 @@ def process_arguments(args, base_day):
 | 
				
			|||||||
    return preferences, selected_day
 | 
					    return preferences, selected_day
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_lesson_description(schedule, reference_time, lesson_time,
 | 
					def get_lesson_description(schedule, reference_time, lesson_time, current_day, current_week, overrides={}):
 | 
				
			||||||
                           current_day, current_week, overrides = {}):
 | 
					 | 
				
			||||||
    lesson_record = schedule[lesson_time]
 | 
					    lesson_record = schedule[lesson_time]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lesson_start_datetime = datetime.fromtimestamp(reference_time + lesson_time)
 | 
					    lesson_start_datetime = datetime.fromtimestamp(reference_time + lesson_time)
 | 
				
			||||||
@ -143,9 +138,8 @@ def process(message, path):
 | 
				
			|||||||
    current_week = current_time.isocalendar()[1] % 2
 | 
					    current_week = current_time.isocalendar()[1] % 2
 | 
				
			||||||
    current_day = current_time.weekday()
 | 
					    current_day = current_time.weekday()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    current_seconds = current_week*604800 + current_day*86400 \
 | 
					    current_seconds = current_week * 604800 + current_day * 86400 + current_time.hour * 3600 + current_time.minute \
 | 
				
			||||||
                    + current_time.hour*3600 + current_time.minute*60 \
 | 
					                      * 60 + current_time.second
 | 
				
			||||||
                    + current_time.second
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    reference_time = int(current_time.strftime("%s")) - current_seconds
 | 
					    reference_time = int(current_time.strftime("%s")) - current_seconds
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -173,10 +167,8 @@ def process(message, path):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        lesson_list = [i for i in schedule if selected_day * 86400 <= i < (selected_day + 1) * 86400]
 | 
					        lesson_list = [i for i in schedule if selected_day * 86400 <= i < (selected_day + 1) * 86400]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        lesson_descriptions_list = ["Назва: " + get_lesson_description(schedule, reference_time,
 | 
					        lesson_descriptions_list = ["Назва: " + get_lesson_description(schedule, reference_time, lesson_time,
 | 
				
			||||||
                                                           lesson_time, current_day,
 | 
					                                                                       current_day, current_week, overrides=preferences)
 | 
				
			||||||
                                                           current_week, overrides = preferences)
 | 
					 | 
				
			||||||
                                    for lesson_time in lesson_list]
 | 
					                                    for lesson_time in lesson_list]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return f"Пари у {WEEKDAYS_ACCUSATIVE[selected_day % 7]}:\n" \
 | 
					        return f"Пари у {WEEKDAYS_ACCUSATIVE[selected_day % 7]}:\n" + "\n\n".join(lesson_descriptions_list)
 | 
				
			||||||
                + "\n\n".join(lesson_descriptions_list)
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user