Trying to fix AttributeError() on init

This commit is contained in:
Profitroll 2022-12-21 15:22:14 +01:00
parent bc54abcc97
commit a906c0a1cc

View File

@ -100,16 +100,18 @@ 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)):
if isinstance(user, User):
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.phone != user.phone_number) and (user.phone_number is not None)):
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.locale != user.language_code) and (user.language_code is not None)):
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 isinstance(user, User) and (self.username != user.username):
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:
@ -390,3 +392,6 @@ class HoloUser():
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")
else:
return