PEP8 autoformat and message formatting changes. #9
4
main.py
4
main.py
|
@ -205,7 +205,8 @@ def queue_processor():
|
|||
updater.bot.send_message(chat_id=msg.chat.id, text=response,
|
||||
disable_web_page_preview=True,
|
||||
parse_mode=formatting)
|
||||
print(f"Responded using module {mod.path} ({mod.alias}) with text (using {formatting}): {response}")
|
||||
print(
|
||||
f"Responded using module {mod.path} ({mod.alias}) with text (using {formatting}): {response}")
|
||||
break
|
||||
|
||||
del message_queue[0]
|
||||
|
@ -247,7 +248,6 @@ mcu = ModuleControlUnit()
|
|||
processor_thread = threading.Thread(target=queue_processor, args=[])
|
||||
processor_thread.start()
|
||||
|
||||
|
||||
# connecting to Telegram servers and listening for messages
|
||||
|
||||
TOKEN = readfile("config/token")
|
||||
|
|
|
@ -24,10 +24,10 @@ lesson_types_to_strings = {
|
|||
"lab": "лабораторна"
|
||||
}
|
||||
|
||||
|
||||
# global variables
|
||||
module_path = ""
|
||||
|
||||
|
||||
def escaped_string_markdownV2(input_string):
|
||||
result_string = input_string
|
||||
|
||||
|
@ -85,21 +85,21 @@ def generate_lesson_description(lesson, start_datetime, end_datetime, current_da
|
|||
result = ""
|
||||
|
||||
if output_settings['name']:
|
||||
result += f"{custom_name_prefix}: {escaped_string_html(lesson['name'])} ({escaped_string_html(get_name_of_lesson_type(lesson['type']))})\n"
|
||||
result += f"<b>{escaped_string_html(lesson['name'])}<b> ({escaped_string_html(get_name_of_lesson_type(lesson['type']))})\n"
|
||||
|
||||
if output_settings['date']:
|
||||
human_readable_date = get_human_readable_date(start_datetime, end_datetime,
|
||||
current_day, current_week)
|
||||
result += f"<b>Дата</b>: {escaped_string_html(human_readable_date)}\n"
|
||||
result += f"<i>Дата</ii>: {escaped_string_html(human_readable_date)}\n"
|
||||
|
||||
if output_settings['teacher']:
|
||||
result += f"<b>Викладач</b>: {escaped_string_html(lesson['teacher'])}\n"
|
||||
result += f"<i>Викладач</i>: {escaped_string_html(lesson['teacher'])}\n"
|
||||
|
||||
if output_settings['link']:
|
||||
result += f"<b>Посилання</b>: {escaped_string_html(lesson['link'])}\n"
|
||||
result += f"<i>Посилання</i>: {escaped_string_html(lesson['link'])}\n"
|
||||
|
||||
if output_settings['comment'] and 'comment' in lesson:
|
||||
result += f"<b>Примітка</b>: {escaped_string_html(lesson['comment'])}\n"
|
||||
result += f"<i>Примітка</i>: {escaped_string_html(lesson['comment'])}\n"
|
||||
|
||||
return result
|
||||
|
||||
|
@ -163,7 +163,8 @@ def get_lesson_description(schedule, reference_time, lesson_time, current_day, c
|
|||
internal_overrides = dict(overrides)
|
||||
internal_overrides['date'] = False
|
||||
|
||||
description = generate_lesson_description(lesson_record, lesson_start_datetime, lesson_end_datetime, current_day,
|
||||
description = generate_lesson_description(lesson_record, lesson_start_datetime, lesson_end_datetime,
|
||||
current_day,
|
||||
current_week, overrides=internal_overrides)
|
||||
|
||||
if 'date' in user_defined_overrides and not user_defined_overrides['date']:
|
||||
|
@ -182,7 +183,8 @@ def get_lesson_description(schedule, reference_time, lesson_time, current_day, c
|
|||
internal_overrides['date'] = False
|
||||
|
||||
descriptions = [generate_lesson_description(i, lesson_start_datetime, lesson_end_datetime, current_day,
|
||||
current_week, overrides=internal_overrides, custom_name_prefix=custom_name_prefix) for i in lesson_record]
|
||||
current_week, overrides=internal_overrides,
|
||||
custom_name_prefix=custom_name_prefix) for i in lesson_record]
|
||||
|
||||
if 'date' in user_defined_overrides and not user_defined_overrides['date']:
|
||||
return "\n".join(descriptions)
|
||||
|
@ -254,7 +256,9 @@ def process(message, path):
|
|||
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_time, current_day,
|
||||
current_week, overrides=preferences, custom_name_prefix="<b>Назва</b>", force_date_at_top=True)
|
||||
current_week, overrides=preferences,
|
||||
custom_name_prefix="<b>Назва</b>", force_date_at_top=True)
|
||||
for lesson_time in lesson_list]
|
||||
|
||||
return f"<b><u>Пари у {WEEKDAYS_ACCUSATIVE[selected_day % 7]}</u></b>:\n\n\n" + "\n\n".join(lesson_descriptions_list), "HTML"
|
||||
return f"<b><u>Пари у {WEEKDAYS_ACCUSATIVE[selected_day % 7]}</u></b>:\n\n\n" + "\n\n".join(
|
||||
lesson_descriptions_list), "HTML"
|
||||
|
|
Loading…
Reference in New Issue