From a906c0a1cc9061f784550ceed641cb2b5f3b36b4 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 21 Dec 2022 15:22:14 +0100 Subject: [PATCH] Trying to fix AttributeError() on init --- classes/holo_user.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/classes/holo_user.py b/classes/holo_user.py index 4c4c03c..7454141 100644 --- a/classes/holo_user.py +++ b/classes/holo_user.py @@ -100,17 +100,19 @@ class HoloUser(): self.locale = holo_user["tg_locale"] self.username = holo_user["tg_username"] - if isinstance(user, User) and ((self.name != user.first_name) and (user.first_name is not None)): - self.set("tg_name", user.first_name) + if isinstance(user, User): - if isinstance(user, User) and ((self.phone != user.phone_number) and (user.phone_number is not None)): - self.set("tg_phone", user.phone_number) + if (self.name != user.first_name) and hasattr(user, "first_name") and (user.first_name is not None): + self.set("tg_name", user.first_name) - if isinstance(user, User) and ((self.locale != user.language_code) and (user.language_code is not None)): - self.set("tg_locale", user.language_code) + if (self.phone != user.phone_number) and hasattr(user, "phone_number") and (user.phone_number is not None): + self.set("tg_phone", user.phone_number) - if isinstance(user, User) and (self.username != user.username): - self.set("tg_username", user.username) + if (self.locale != user.language_code) and hasattr(user, "language_code") and (user.language_code is not None): + self.set("tg_locale", user.language_code) + + if (self.username != user.username) and hasattr(user, "username") and (user.username is not None): + self.set("tg_username", user.username) def set(self, key: str, value: Any) -> None: """Set attribute data and save it into database @@ -389,4 +391,7 @@ class HoloUser(): col_tmp.update_one({"user": {"$eq": self.id}, "type": {"$eq": "application"}}, {"$set": {"application": progress["application"], "stage": progress["stage"]+1}}) await msg.reply_text(locale(f"question{stage+1}", "message", locale=self.locale), reply_markup=ForceReply(placeholder=str(locale(f"question{stage+1}", "force_reply", locale=self.locale)))) - logWrite(f"User {self.id} completed stage {stage} of application") \ No newline at end of file + logWrite(f"User {self.id} completed stage {stage} of application") + + else: + return \ No newline at end of file