# Робота зі змінними

## Як отримати значення змінних клієнта

get\_client\_var() | get\_client\_vars()

<details>

<summary>Опис</summary>

<mark style="color:за замовчуванням;background-color:blue;">**Щоб отримати значення однієї змінної**</mark>

**get\_client\_var(client\_id, variable)**

Параметри:\ <mark style="color:red;">**!**</mark>**&#x20;client\_id -** ID клієнта\ <mark style="color:red;">**!**</mark>**&#x20;variable -** назва змінної

<mark style="color:за замовчуванням;background-color:blue;">**Щоб отримати значення кількох змінних**</mark>

**get\_client\_vars(client\_id, names)**

Параметри:\ <mark style="color:red;">**!**</mark>**&#x20;client\_id -** ID клієнта\ <mark style="color:red;">**!**</mark>**&#x20;names-** масив змінних

</details>

<details>

<summary>Приклад</summary>

Давайте надішлемо менеджеру повідомлення з номером уроку, який проходить один із учасників нашого проєкту:

<div data-with-frame="true"><figure><img src="/files/b3923318054b9e564351f83bc3abf4363282513c" alt="" width="563"><figcaption><p>Приклад використання функції для отримання значення змінної</p></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/b404b1b1d01779a768fd096f9f2e83b7817e5a43" alt="" width="375"><figcaption><p>Результат функції</p></figcaption></figure></div>

Той самий варіант, але з виведенням, наприклад, рівня та уроку в ньому:

<div data-with-frame="true"><figure><img src="/files/1238c4b4cbd0f104970a1858057e22af4c25d6b3" alt=""><figcaption><p>Приклад використання функції для отримання кількох значень</p></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/91e69c4a8dfcc2cd23fed6c70e56aff32e3c1778" alt="" width="350"><figcaption><p>Результат функції</p></figcaption></figure></div>

</details>

<details>

<summary>Приклад коду для копіювання</summary>

```
/*Отримання однієї змінної*/
trial=get_client_var(64732310, 'lesson')

/*Отримання кількох змінних*/
names=["level","lesson"]
trial=get_client_vars(64732310, names)
```

</details>

## Як призначити змінну клієнта

set\_client\_var() | set\_client\_vars()

<details>

<summary>Опис</summary>

<mark style="color:за замовчуванням;background-color:blue;">**Щоб призначити значення однієї змінної**</mark>

**set\_client\_var(client\_id, variable, value)**

Параметри:

**client\_id** — ID клієнта MaviBot\
**variable** — назва змінної, яку потрібно призначити\
**value** — значення змінної

<mark style="color:за замовчуванням;background-color:blue;">**Щоб призначити кілька змінних**</mark>

**set\_client\_vars(client\_id, variables\_dict)**

Параметри:

**client\_id** — ID клієнта MaviBot\
**variables\_dict** — словник; містить усі назви змінних та їхні значення, які потрібно додати. \
Формат:\
'{"var\_name1": "var\_value1", "var\_name2": "var\_value2", "var\_name3": "var\_value3"}'

</details>

<details>

<summary>Приклад</summary>

Приклад 1:

set\_client\_var(client\_id, "new", "yes")

<div data-with-frame="true"><figure><img src="/files/e0221a4eb1fc2f5f528b22cf427f9387f0c75fa6" alt="" width="563"><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/c05bacf8906d7a59084269d09e65beba68f371f3" alt=""><figcaption></figcaption></figure></div>

Приклад 2:

set\_client\_vars(1136, '{"var\_name1": "var\_value1", "var\_name2": "var\_value2", "var\_name3": "var\_value3"}')

<div data-with-frame="true"><figure><img src="/files/e5f38306d2d18351f9b69c2fdadde095b84423ce" alt=""><figcaption></figcaption></figure></div>

Розділ змінних у картці клієнта

<div data-with-frame="true"><figure><img src="/files/195b227701faa6a64f4158c7569ee467a4fa22cf" alt=""><figcaption></figcaption></figure></div>

&#x20;

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/doc/uk/chatbot/functions/kalkulyator/variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
