From a8c6adaa07d65f5a0f84e4c5b326fc256adf451f Mon Sep 17 00:00:00 2001 From: Ivan Hrabcak Date: Thu, 30 Mar 2023 14:26:17 +0200 Subject: [PATCH] Add a way to use `EduStudent` with a `StudentOnly` id --- edupage_api/messages.py | 2 +- edupage_api/people.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/edupage_api/messages.py b/edupage_api/messages.py index 0d60281..432ed0c 100644 --- a/edupage_api/messages.py +++ b/edupage_api/messages.py @@ -44,6 +44,6 @@ def send_message(self, recipients: Union[list[EduAccount], EduAccount, list[str] changes = response.get("changes") if changes == [] or changes is None: - raise RequestError("Failed to send message (edupage returned an empty 'changes' array)") + raise RequestError("Failed to send message (edupage returned an empty 'changes' array) - https://github.com/ivanhrabcak/edupage-api/issues/62") return int(changes[0].get("timelineid")) \ No newline at end of file diff --git a/edupage_api/people.py b/edupage_api/people.py index 0f9070e..32fe417 100644 --- a/edupage_api/people.py +++ b/edupage_api/people.py @@ -92,6 +92,17 @@ def __init__(self, person_id: int, name: str, gender: Gender, in_school_since: d self.class_id = class_id self.number_in_class = number_in_class + self.__student_only = False + + def get_id(self): + if not self.__student_only: + return super().get_id() + else: + return super().get_id().replace("Student", "StudentOnly") + + def set_student_only(self, student_only: bool): + self.__student_only = student_only + @dataclass class EduStudentSkeleton: