diff --git a/comparer/comparer.py b/comparer/comparer.py index 33a05fe..ca5d39a 100644 --- a/comparer/comparer.py +++ b/comparer/comparer.py @@ -43,4 +43,4 @@ def compare(name: str, array: list, upper: bool = True) -> bool: elif len(name) <= 4 and k < 1: return True - return False \ No newline at end of file + return False diff --git a/editor/editor.py b/editor/editor.py index b9dcf2f..bc999de 100644 --- a/editor/editor.py +++ b/editor/editor.py @@ -1,4 +1,4 @@ -class Edit(): +class Edit: @staticmethod def clean_tag_from_str(string_line): @@ -48,4 +48,3 @@ def clean_str_from_symbol(string, open_symbol, close_symbol=None, clean_content= append = True return res - diff --git a/group_queue/person.py b/group_queue/person.py index ba1f84d..008a876 100644 --- a/group_queue/person.py +++ b/group_queue/person.py @@ -16,4 +16,4 @@ def get_name(self) -> str: return self._name def get_passed(self): - return self._passed \ No newline at end of file + return self._passed diff --git a/group_queue/queue.py b/group_queue/queue.py index b100f2a..520b038 100644 --- a/group_queue/queue.py +++ b/group_queue/queue.py @@ -111,7 +111,7 @@ def get_next_person_in_queue(self) -> Person: :return: Следующий в очереди """ if self._queue_value == len(self._queue_list) - 1: - return self._queue_list[0].get_name() + return self._queue_list[0] else: return self._queue_list[self._queue_value + 1] diff --git a/lilly.py b/lilly.py index a08fd09..20d4b4b 100644 --- a/lilly.py +++ b/lilly.py @@ -6,7 +6,6 @@ from client_server import server_client from parser_m import date from group_queue.queue import Queue -from input_manager import InputManager class Lilly: @@ -47,7 +46,7 @@ def __init__(self): ["HELP", "ПОМОЩЬ"], # 10 ["JAVA OOP", "ВОПРОС ПРО JAVA OOP", "ЗАДАЙ ВОПРОС ПРО JAVA"], # 11 ["СОЗДАЙ ОЧЕРЕДЬ"], # 12 - ["ОЧЕРЕДЬ","РЕДАКТИРОВАТЬ ОЧЕРЕДЬ"] # 13 + ["ОЧЕРЕДЬ", "РЕДАКТИРОВАТЬ ОЧЕРЕДЬ"] # 13 ] # TODO: convert it to file or sql data base @@ -123,8 +122,7 @@ def get_command(self, command): # TODO: realize it # Авторизация супер пользователя elif self.compare(command, self.COMMANDS[3]): - self.NEXT_INPUT = "admin_login" - return "Введите логин и пароль отдельными сообщениями" + return "Function not realized" # Отправление погоды сообщением elif self.compare(command, self.COMMANDS[6]): @@ -174,7 +172,6 @@ def get_command(self, command): elif self.compare(command, self.COMMANDS[13]): self.NEXT_INPUT = "queue_edit_mode" - self.im.set_next_method("queue_edit_mode") return self.queue_edit_mode(None) # Команда не распознана @@ -201,7 +198,7 @@ def java_questions_mode(self, command="@#"): # @# - если это первы # Следующий ввод перенаправляем в этот метод self.NEXT_INPUT = "java_questions_mode" - self.im.set_next_method("java_questions_mode") + if command == "@#": return ("Теперь я в режиме вопросов :)\n" "Доступные команды:\n" @@ -238,7 +235,6 @@ def java_questions_mode(self, command="@#"): # @# - если это первы elif self.compare(command.upper(), ["ЗАКОНЧИТЬ"]): self.NEXT_INPUT = "get_command" - self.im.set_next_method("get_command") return "Режим вопросов закончен" else: return "Не поняла вашего ответа, пожалуйста повторите" @@ -263,7 +259,7 @@ def queue_edit_mode(self, input_value): elif self.compare(input_value.split()[0], ["Добавить"]): if len(input_value.split()) > 2: - self.queue.add_person(input_value.split()[1],int(input_value.split()[3])) + self.queue.add_person(input_value.split()[1], int(input_value.split()[3])) else: self.queue.add_person(input_value.split()[1]) return f"{input_value.split()[1]} был добавлен в очередь" @@ -307,37 +303,11 @@ def queue_edit_mode(self, input_value): elif self.compare(input_value, ["Выйти", "Закончить"]): self.NEXT_INPUT = "get_command" - self.im.set_next_method("get_command") - return "Вы вышли из режима очереди" else: return self.get_command(input_value) - def get_schedule(self, tomorrow="no"): - - # TODO: Rewrite it to class Day - days = ["понедельник", "вторник", "среда", "четверг", "пятница", "суббота", "воскресенье"] - - # Файлы с разными кодрировками - sh_filename = "schedule/sh.txt" - - today_day = self.date.get_day_of_week().strip() - - # Получение следующего дня - if tomorrow == "tomorrow": - for i in range(len(days)): - if days[i] == today_day: - if i + 1 == len(days): - today_day = days[0] - break - else: - today_day = days[i+1] - break - - week_parity = self.date.get_week_parity() - return self.schedule.get_schedule_from_file(sh_filename, today_day, week_parity) - # TODO: Rewrite to class Recipe def get_breakfast_recipe(self, amount: int = 0) -> str: @@ -376,11 +346,11 @@ def get_breakfast_recipe(self, amount: int = 0) -> str: self.NEXT_INPUT = "breakfast_more_check" - self.im.set_next_method("breakfast_more_check") - self.RECIPE_WATCHED += temp return "Вот что я нашла: \n" + ret + # TODO: Rewrite and realize + """ im = InputManager() im.set_methods( java_questions_mode, @@ -391,6 +361,7 @@ def get_breakfast_recipe(self, amount: int = 0) -> str: def update_scr(self, input_value): self.im.update(input_value) + """ # TODO: Rewrite it to class CommandManager def update_screen(self, input_value): @@ -408,14 +379,6 @@ def update_screen(self, input_value): if self.NEXT_INPUT == "get_command": return self.get_command(input_value) - if self.NEXT_INPUT == "admin_login": - self.NEXT_INPUT = "admin_pwd" - return self.admin_login(input_value) - - if self.NEXT_INPUT == "admin_pwd": - self.NEXT_INPUT = "get_command" - return self.admin_pwd(input_value) - if self.NEXT_INPUT == "get_breakfast_recipe": return self.get_breakfast_recipe(input_value) @@ -428,13 +391,6 @@ def update_screen(self, input_value): if self.NEXT_INPUT == "queue_edit_mode": return self.queue_edit_mode(input_value) - def admin_login(self, login): - self.NEXT_INPUT = "admin_pwd" - - def admin_pwd(self, pwd): - if pwd == "123": - self.SUPER_USER = True - # TODO: Rewrite it to class Compare and upgrade algorithm @staticmethod @@ -483,9 +439,10 @@ def compare(name: str, array: list, upper: bool = True) -> bool: return False DOCUMENTATION = """ - РАСПИСАНИЕ - еще в разработке + РАСПИСАНИЕ - показывает расписание ПОГОДА - показывает погоду ЗАВТРАК - показывает рецепты блюд на завтрак - после команды ЗАВТРАК можно ввести "еще", чтобы посмотреть еще несколько рецпетов ЗАДАЙ ВОПРОС ПРО JAVA - задает вопросы по теме языка программирования Java + СОЗДАЙ ОЧЕРЕДЬ - создает очередь для сдачи лабы """ diff --git a/parser_m/recipe.py b/parser_m/recipe.py index d425143..8cca7f5 100644 --- a/parser_m/recipe.py +++ b/parser_m/recipe.py @@ -21,13 +21,13 @@ def get_breakfast(self, food_type="breakfast"): result = [0] if food_type == "breakfast": - self.b = self.set_http(self._BREAKFAST_HTTP) + b = self.set_http(self._BREAKFAST_HTTP) elif food_type == "lunch": - self.set_http(self._LUNCH_HTTP) + b = self.set_http(self._LUNCH_HTTP) else: - self.set_http(self._SUPPER_HTTP) + b = self.set_http(self._SUPPER_HTTP) - a = self.b.findAll(attrs={"class": "title"}) + a = b.findAll(attrs={"class": "title"}) for i in range(len(a)): temp = str(a[i]) if i > 2 & i < 70: diff --git a/questions/get_question.py b/questions/get_question.py index b60c939..e765d47 100644 --- a/questions/get_question.py +++ b/questions/get_question.py @@ -1,16 +1,13 @@ import random -import os + class GetQuestion: answers_file = None questions_file = None - # Проблемы с кодировками на разных системах - if os.name == "nt": - files_path = "questions/java/QaA_javaWindows" - else: - files_path = "questions/java/QaA_java" + files_path = "questions/java/QaA_java" + wasted_questions = [] last_question = None @@ -18,8 +15,8 @@ def __init__(self): self.q_a_a = self.get_questions_from_file() def update_file_open(self): - self.answers_file = open(self.files_path + "/java_oop_answers", "r") - self.questions_file = open(self.files_path + "/java_oop_questions", "r") + self.answers_file = open(self.files_path + "/java_oop_answers", "r", encoding="UTF-8") + self.questions_file = open(self.files_path + "/java_oop_questions", "r", encoding="UTF-8") self.answers_file = self.answers_file.read().split("$$") self.questions_file = self.questions_file.read().split("\n") @@ -55,4 +52,3 @@ def get_wasted_questions(self): return self.wasted_questions def get_last_question(self): return self.last_question def reset_wasted_questions(self): self.wasted_questions = [] - diff --git a/vk_server.py b/vk_server.py index da1d054..a9a62aa 100644 --- a/vk_server.py +++ b/vk_server.py @@ -1,7 +1,7 @@ from editor.editor import Edit from lilly import Lilly import vk_api.vk_api -from vk_api.bot_longpoll import VkBotLongPoll, VkBotMessageEvent +from vk_api.bot_longpoll import VkBotLongPoll from vk_api.bot_longpoll import VkBotEventType from config import vk_api_token @@ -29,4 +29,3 @@ Edit.clean_str_from_symbol(event.object.text, "[", "]")[1::])) print('Текст: ', event.object.text, end="\n") -