From 1fa40df89e72e788585fe3d76647803d380daff5 Mon Sep 17 00:00:00 2001 From: Nick Ninov Date: Wed, 11 Mar 2026 16:22:25 +0000 Subject: [PATCH] properties: bio - Add bio functionality - Add documentation --- bot/account.py | 32 ++++++++++++++++++++++++- bot/docs/account.md | 57 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/bot/account.py b/bot/account.py index 6d8ec0b..7036d08 100644 --- a/bot/account.py +++ b/bot/account.py @@ -1,4 +1,4 @@ -from typing import Optional, Union, Generator +from typing import Optional, Union, Generator, Any import requests, datetime, re from .signal import Signal @@ -129,6 +129,7 @@ class Account: "compressed_key": event["compressedKey"], "mnemonic": event["mnemonic"], "display_name": event["display-name"], + "bio": event.get("bio", ""), "password": password, "wallet_address": event["address"], "logged_in_timestamp": datetime.datetime.now() @@ -180,6 +181,35 @@ class Account: self.signal.get("envelope.sent") self.__info["display_name"] = name + @property + def bio(self) -> str: + """ + Get the current bio + """ + return self.info["bio"] + + @bio.setter + def bio(self, bio: Any): + if isinstance(bio, type(None)): + bio = "" + + bio = str(bio).strip() + # Limit based from Status App + CHARACTERS = 240 + if len(bio) > CHARACTERS: + raise ValueError(f"Bio cannot be longer than {CHARACTERS} characters...") + + self.__call_rpc("messaging", "setBio", [bio]) + # It seems that if a valid bio is given, it will be instantly updated + # However after tracing the signals, an `envelope.sent` is sent a bit + # after the bio has been updated. + self.signal.get("envelope.sent") + self.__info["bio"] = bio + + @bio.deleter + def bio(self): + self.bio = "" + @property def contacts(self) -> dict[str, dict]: """ diff --git a/bot/docs/account.md b/bot/docs/account.md index b3a3ff1..217b153 100644 --- a/bot/docs/account.md +++ b/bot/docs/account.md @@ -530,7 +530,7 @@ account.login(**params) print(account.display_name) ``` -You can also update the display name by assigning a new value: +You can update the display name by assigning a new value: ```python from bot import Account @@ -548,3 +548,58 @@ print(account.display_name) ``` **Note**: Next time you login with the changed display name, you will have to put in the new display name, instead of the initial one. + +### `bio` + +Get or update the **bio** of the currently logged‑in account. The length of the bio (as in Status App) is 240 characters. + +Returns `str` when reading the property. + +```python +from bot import Account + +account = Account() +params = { + "display_name": "status-app-bot", + "password": "SNTPUMP" +} +account.login(**params) + +# Read the current bio +print(account.bio) +``` + +The value assigned to `bio` will automatically be converted to a string before being sent to the backend. You can update the bio by assigning a new value: + +```python +from bot import Account + +account = Account() +params = { + "display_name": "status-app-bot", + "password": "SNTPUMP" +} +account.login(**params) + +# Update the bio +account.bio = "Monitoring Status communities and chats" +print(account.bio) +``` + +You can also **clear the bio** by deleting the property: + +```python +from bot import Account + +account = Account() +params = { + "display_name": "status-app-bot", + "password": "SNTPUMP" +} +account.login(**params) + +# Clears the bio - same as: +# account.bio = "" +# account.bio = None +del account.bio +```