mirror of
https://github.com/status-im/status-python-sdk.git
synced 2026-08-31 06:01:19 +00:00
account: Message length property
This commit is contained in:
@@ -1908,6 +1908,33 @@ for chat in account.chats:
|
||||
print(f"{chat['type']}\t{chat['name']}\t{chat['id']}")
|
||||
```
|
||||
|
||||
#### `message_length`
|
||||
|
||||
The maximum number of characters a single message may contain, as enforced by Status App.
|
||||
|
||||
Returns `int`.
|
||||
|
||||
```python
|
||||
from status_sdk import Account
|
||||
|
||||
account = Account()
|
||||
params = {
|
||||
"name": "status-app-bot",
|
||||
"password": "SNTPUMP"
|
||||
}
|
||||
account.login(**params)
|
||||
|
||||
print(account.message_length)
|
||||
|
||||
# This is under the assumption you already have a contact / joined a community
|
||||
chat = account.chats[0]
|
||||
report = "A very long report..."
|
||||
|
||||
# Split a long text into messages the app accepts
|
||||
for index in range(0, len(report), account.message_length):
|
||||
account.send_message(chat["id"], report[index:index + account.message_length])
|
||||
```
|
||||
|
||||
### Wallet
|
||||
|
||||
#### `chains`
|
||||
|
||||
@@ -13,7 +13,6 @@ from .signal import Signal
|
||||
from .logger import Logger
|
||||
|
||||
class Account:
|
||||
|
||||
# Enum mappings from original wakuext.py
|
||||
__mappings = {
|
||||
"contact_request": {
|
||||
@@ -594,6 +593,10 @@ class Account:
|
||||
balance.insert(0, "timestamp", datetime.datetime.now())
|
||||
return balance.copy()
|
||||
|
||||
@property
|
||||
def message_length(self) -> int:
|
||||
return 2_000
|
||||
|
||||
@property
|
||||
def status(self) -> str:
|
||||
"""
|
||||
@@ -738,7 +741,7 @@ class Account:
|
||||
if not message:
|
||||
message = ""
|
||||
|
||||
if len(message) > 2_000:
|
||||
if len(message) > self.message_length:
|
||||
raise exceptions.MessageTooLongError(f"Message cannot be longer than 2000 characters (got {len(message)})...")
|
||||
|
||||
msg_params = {
|
||||
|
||||
Reference in New Issue
Block a user