diff --git a/daemons/notify.py b/daemons/notify.py index 47b10a9..f89c234 100644 --- a/daemons/notify.py +++ b/daemons/notify.py @@ -50,7 +50,8 @@ def process(): try: bot.send_message( user["chat_id"], - f"Уведомляю о занятиях! Твое расписание на {'сегодня' if user_model.daily_notify_today else 'завтра'}:\n" + text + f"Уведомляю о занятиях! Твое расписание на {'сегодня' if user_model.daily_notify_today else 'завтра'}:\n" + text, + parse_mode='Markdown' ) except: pass @@ -59,7 +60,7 @@ def process(): {"$set": {"next_daily_notify_time": user_model.next_daily_notify_time + datetime.timedelta(days=1)}} ) - for user in mongo.users_collection.find({"first_lesson_notify": {"$ne": None}, "hse_id": {"$ne": None}}): + for user in mongo.users_collection.find({"first_lesson_notify": {"$exists": True}, "first_lesson_notify": {"$ne": None}, "hse_id": {"$ne": None}}): time_now = now(UserSchema().load(user)) for lesson in mongo.lessons_collection.find({ "hse_user_id": user["hse_id"], @@ -91,7 +92,7 @@ def process(): except ApiTelegramException: pass start_of_day = datetime.datetime(year=time_now.year, month=time_now.month, day=time_now.day) - mongo.lessons_collection.update_many({"begin": {"$gte": start_of_day, "$lt": (start_of_day + datetime.timedelta(days=1))}}, {"$set": {"notified_today": True}}) + mongo.lessons_collection.update_many({"begin": {"$gte": start_of_day, "$lt": (start_of_day + datetime.timedelta(days=1))}, "hse_user_id": user["hse_id"]}, {"$set": {"notified_today": True}}) break