diff --git a/helpers/alice.py b/helpers/alice.py index bb2aa87..67ecc38 100644 --- a/helpers/alice.py +++ b/helpers/alice.py @@ -17,7 +17,6 @@ class Processor: return None def process(self) -> dict: - user = None if "что ты умеешь" in self.message or "помощь" in self.message: return { "text": "Я буду тебе подсказывать расписание занятий из РУЗа. Чтобы подключить меня к своему расписанию, зайди в бота, нажми на кнопку \"Подключение Алисы\" и назови мне код из сообщения." @@ -44,7 +43,12 @@ class Processor: } else: hse_id = self.message.replace(' ', '') - user = mongo.users_collection.find_one({"hse_id": int(hse_id)}) + try: + user = mongo.users_collection.find_one({"hse_id": int(hse_id)}) + except KeyError: + return { + "text": "Извини, не могу разобрать код, назови его еще раз" + } if user is None: return { "text": "Извини, не могу разобрать код, назови его еще раз"