Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,5 @@ __marimo__/
*.DS_Store
*.pkl
# Docker volumes for Status
/data-dir
data/
*.bkp
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ You can set it up in **two** ways.

#### With Python

Use [`launch_docker_container`](./docs/utils.md#launch_docker_containercommitnone-wait_seconds5-platformlinuxamd64), which builds and starts the container for you. This is the recommended option, as it handles platform selection and (on Windows) recovers from stale Docker mounts:
Use [`launch_docker_container`](./docs/utils.md#launch_docker_containercommitnone-wait_seconds5-platformlinuxamd64-data_foldernone), which builds and starts the container for you. This is the recommended option, as it handles platform selection and (on Windows) recovers from stale Docker mounts:

```python
from status_sdk import launch_docker_container
Expand All @@ -136,13 +136,14 @@ Run the compose file yourself. It lives inside the installed package, so point D
docker compose -f status_sdk/docker-compose.yaml up -d
```

The compose file reads two variables from the environment. Both have a default, so the command above works as-is, but they can be overridden:
The compose file reads three variables from the environment. All of them have a default, so the command above works as-is, but they can be overridden:

| Variable | Default | Description |
|-----|-----|-------------|
| `STATUS_GO_REF` | `develop` | The [`status-im/status-go`](https://github.com/status-im/status-go/) git ref (commit SHA, branch or tag) to build from. |
| `STATUS_GO_PLATFORM` | `linux/amd64` | The platform the image is built for. |
| `STATUS_GO_COMMIT` | `develop` | The [`status-im/status-go`](https://github.com/status-im/status-go/) git ref (commit SHA, branch or tag) to build from. |
| `PLATFORM` | `linux/amd64` | The platform the image is built for. |
| `DATA_DIR` | `./data` | The folder on your machine where Status Backend keeps the accounts it creates. Use an absolute path, or one starting with `./` - a bare relative path is read as a Docker volume name. Required for a community [control node](./docs/community.md#control-node). |

```
STATUS_GO_REF=2bee8b6a38cdc8f92d74e2dbb8c4e77fbbeea149 STATUS_GO_PLATFORM=linux/amd64 docker compose -f status_sdk/docker-compose.yaml up -d
STATUS_GO_COMMIT=2bee8b6a38cdc8f92d74e2dbb8c4e77fbbeea149 PLATFORM=linux/amd64 DATA_DIR=./data docker compose -f status_sdk/docker-compose.yaml up -d
```
102 changes: 99 additions & 3 deletions docs/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Where a list is accepted, the formats can even be **mixed within the same list**

![Community Settings](./images/account/public-keys.png)

**Note**: An **account URL** (`https://status.app/u/...`) is not the same as a **community URL** (`https://status.app/c/...`). Community URLs identify a community and belong in the [`Community`](./community.md#communityaccount-community_idnone-urlnone) constructor.
**Note**: An **account URL** (`https://status.app/u/...`) is not the same as a **community URL** (`https://status.app/c/...`). Community URLs identify a community and belong in the [`Community`](./community.md#communityaccount-community_idnone-urlnone-data_foldernone) constructor.

## Wallet

Expand Down Expand Up @@ -386,7 +386,7 @@ account.unsync("6a2f9c1e-...")

#### `send_message(chat_id, message, reply_to_message_id=None)`

Send a text message to a specific chat. This method currently supports **text messages only**. A message can also be sent as a **reply** to an existing message in the same chat, which renders in Status App with the original message quoted above it - the same as replying to a message in the app.
Send a text message to a specific chat. A message can also be sent as a **reply** to an existing message in the same chat, which renders in Status App with the original message quoted above it - the same as replying to a message in the app.

A message can be **at most 2000 characters long**, matching the limit enforced by Status App. Sending a longer message raises a custom exception.

Expand Down Expand Up @@ -439,6 +439,82 @@ account.send_message(
)
```

#### `send_image(chat_id, file_path, message=None, reply_to_message_id=None)`

Send an image to a specific chat, with an optional text message. The image renders inline in Status App, the same as attaching an image in the app. Like [`send_message`](./account.md#send_messagechat_id-message-reply_to_message_idnone), it can be sent as a **reply** to an existing message.

| Name | Type | Required | Description |
|-----|-----|-----|-------------|
| `chat_id` | `str` | Yes | Identifier of the chat where the image will be sent. All available chat IDs can be obtained from the [`chats`](./account.md#chats) property. |
| `file_path` | `str` | Yes | Local full path to the image file. |
| `message` | `str` | No | Caption sent together with the image. Cannot be longer than **2000 characters**. When omitted (default), the image is sent without any text. |
| `reply_to_message_id` | `str` | No | The `id` of the message being replied to. Message IDs can be obtained from the `id` key of [`get_messages`](./account.md#get_messageschat_id-start_timestampnone-end_timestampnone) or from a [`listen_messages`](./account.md#listen_messages) event. When omitted (default), the image is sent as a standalone message. |

Returns `str` - the `id` of the message that was just sent, exactly as [`send_message`](./account.md#send_messagechat_id-message-reply_to_message_idnone) does, so it can be passed straight into [`delete_message`](./account.md#delete_messageid) or used as the `reply_to_message_id` of a follow-up message.

```python
from status_sdk import Account

account = Account()
params = {
"name": "status-app-bot",
"password": "SNTPUMP"
}
account.login(**params)

# This is under the assumption you already have a contact / joined a community
chat = account.chats[0]
message_id = account.send_image(chat["id"], "/full/file-path/meme-67.png")
print(f"Sent image: {message_id}")
```

Send an image with a caption:

```python
from status_sdk import Account

account = Account()
params = {
"name": "status-app-bot",
"password": "SNTPUMP"
}
account.login(**params)

chat = account.chats[0]

account.send_image(
chat_id=chat["id"],
file_path="/full/file-path/meme-67.png",
message="Du bist gut genug"
)
```

Reply to a message with an image:

```python
from status_sdk import Account

account = Account()
params = {
"name": "status-app-bot",
"password": "SNTPUMP"
}
account.login(**params)

chat = account.chats[0]

# Messages are returned newest first, so this is the latest message in the chat
messages = account.get_messages(chat["id"])
latest = messages[0]

account.send_image(
chat_id=chat["id"],
file_path="/full/file-path/meme-67.png",
message="Du bist gut genug",
reply_to_message_id=latest["id"]
)
```

#### `get_messages(chat_id, start_timestamp=None, end_timestamp=None)`

Retrieve messages from the specified chat within an optional time range. Messages are returned in **descending order** (newest to oldest). The method automatically paginates through the backend until all messages in the specified range are collected. This method is ideal for backfilling, [batch processing](https://aws.amazon.com/what-is/batch-processing/) or [micro batch processing](https://www.dremio.com/wiki/micro-batch-processing/).
Expand Down Expand Up @@ -519,7 +595,6 @@ Listen for new incoming messages **in real time**. This method yields raw messag

```python
from status_sdk import Account
import datetime
# For terminal readability only
from rich import print as rprint
from rich.pretty import Pretty
Expand All @@ -537,6 +612,27 @@ for msg in account.listen_messages():

**Note**: If you receive multiple messages at once, `contacts` and `chats` will grow.

#### `listen_contact_requests()`

Listen for incoming contact requests **in real time**.

```python
from status_sdk import Account
# For terminal readability only
from rich import print as rprint
from rich.pretty import Pretty

account = Account()
params = {
"name": "status-app-bot",
"password": "SNTPUMP"
}
account.login(**params)

for request in account.listen_contact_requests():
rprint(Pretty(request))
```

#### `add_contact(public_key, display_name=None)`

Send a contact request or approve an existing contact request. The mode depends on how the contact shows up in [`contacts`](./account.md#contacts). Best practice would be to look at the the following [`contacts`](./account.md#contacts) keys:
Expand Down
Loading
Loading