# BOT_STATUS_QUERY

# BOT_STATUS_QUERY

**TotalControl for LSL‎ Commands**

Queries the selected bot status (useful to determine the subscription length).  
The result is returned using the `BOT_EVENT_STATUS_REPLY` event.

```csharp

llMessageLinked(LINK_SET, BOT_STATUS_QUERY, "", "");
```

## Variables

The following table shows input values (you send them with the API call) and returned output values.

| **Variable** | **Description** |
|----------|-------------|
| `str`    | —           |
| `id`     | —           |


---

## Return Value

The result of this command will be returned to your script using the `BOT_EVENT_STATUS_REPLY` event:

```csharp

link_message(integer sender, integer num, string str, key id)
```

| **Parameter** | **Description** |
|-----------|-------------|
| `sender`  | Link number of the sender prim |
| `num`     | `BOT_EVENT_STATUS_REPLY` |
| `str`     | String representing the bot's status:<br>• First line — bot status code (see all codes here)<br>• Second line — bot expiration date<br>• Third line — bot online status<br><br>**Online statuses*** `"ONLINE"` — Bot is online <br> * `"LOGGED OUT"` — Bot was logged out gracefully <br> * `"CONNECTING"` — The bot is logging in <br> * `"OFFLINE"` — Bot is expired or has an error<br>**Example output**```<br>OK<br>2019-03-10 00:00<br>LOGGED OUT<br>``` |
| `id`      | Bot UUID    |

## Example

```csharp
integer BOT_SETUP_SETBOT = 280101;
integer BOT_STATUS_QUERY = 280106;

integer READY = FALSE;

string name = "SmartBots Resident";
string accesscode = "f7dheb7fba9";

default
{
	state_entry()
	{
		llMessageLinked(LINK_SET, BOT_SETUP_SETBOT, name, accesscode);
	}

	touch_start(integer total_number)
	{
		if (READY) {
			llMessageLinked(LINK_SET, BOT_STATUS_QUERY, "", "");
		} else {
			llOwnerSay("The bot is not ready. If you received a Setup Failed message then please check your access code is correct, otherwise please try again in a moment.");
		}
	}

	link_message(integer sender, integer cmd, string data, key idk) {
		string id = (string)idk;
		if(cmd == BOT_SETUP_SUCCESS) {
			READY = TRUE;
			llOwnerSay("Setup Success: data=" + data + "\nkey= " + id);
		} else if(cmd == BOT_SETUP_FAILED) {
			READY = FALSE;
			llOwnerSay("Setup Failed: data=" + data + "\nkey= " + id);
		} else if(cmd == BOT_EVENT_STATUS_REPLY) {
			llOwnerSay("Status: data = " + data + "\nkey= " + id);
		}
	}
}
```