Resources and the module form
{{name}} resources in the Multogram Modules Constructor — the fields of a module's settings form: field types, required fields, groups in the layout manager, visibility conditions, translations, test values and the account picker field.
A resource is a setting the module's user sets before running: a chat, a text, a delay, a file
with a list of targets. The module form is built from resources automatically — the user sees it in the new
task window — and the scenario reads the values as {{name}}.
Resource or variable?
A resource is what the user chooses before running. A variable is what the scenario computes by itself. Don't make a resource out of a value the user doesn't need to change.
Resources panel
The panel on the right shows the module's resources: name, type, current value and description.
| Element | What it does |
|---|---|
| Search | Find a resource by name |
| Add Resource | Create a form field |
| Layout Manager | Arrange the fields into groups and columns |
| Set Values | Values for tests |
Each resource has edit and delete buttons. The Preview button in the top bar shows the form the way the user will see it.
Account picker field
The accounts resource is created in every new module by itself: it is the choice of accounts from the Multogram database. It is protected — it can't be changed or deleted — and in the module form it is labeled Accounts.
The scenario gets the selected accounts as a list. Each item is an account with these fields:
| Field | What's in it |
|---|---|
phone | The account's phone number |
session_path | The path to the .session session file |
data_path | The path to the .json data file |
proxy | The account's proxy: type, host, port, username, password and url — a string like socks5://user:pass@host:port. If there is no proxy — null |
The proxy fields are inserted into actions where a proxy is set in parts: [[account]].proxy.host,
[[account]].proxy.port. This is how Start Session in the AuthSession function and
Set Proxy of the TLS Client module do it. How to hand accounts out to threads is in
Threads and accounts.
Creating a resource
| Field | What to enter |
|---|---|
| Name | The name for the scenario: Latin letters and digits, {{chat}} |
| Title | The field's label in the form and its translations |
| Description | An explanation under the field |
| Type | The kind of field — see the table below |
The other sections of the window depend on the type: Appearance, Options, Constraints (minimum, maximum, length), Value & Behavior (default value, required field), Placeholder, Visibility and Value Parsing.
Field types
| Type | What for | View options |
|---|---|---|
| String | Text, a link, @username | Single-line and multi-line field, tags (a list of values), a random string generator from a pattern |
| Number | A delay, a limit, a quantity | Field, slider, a "from — to" range |
| Path Picker | A file or folder on disk | File path, folder path, file content (the file's text goes into the value) |
| Checkbox List | Several options — or an on/off switch | Checkboxes, switch, cards |
| Radio List | One option, all visible at once | Buttons, cards |
| Select List | One option from a drop-down list | List, cards |
| Date/Time | A date, a time, a period | Date, time, date and time, date range |
| Color | A color | HEX or RGB, with transparency |
| Emoji | A reaction, emoji for text | Limits on number and set |
Choose the type by meaning
"Delete the message after sending" is a Checkbox List shown as a switch, not a "yes/no" string. A "from and to" delay is a Number shown as a range. Then the form is clear, and the value unambiguous.
Values in the scenario
{{name}} inserts a resource's value into any field of an action, just as [[name]] inserts a variable.
| Value | How to read it |
|---|---|
| Simple: text, a number | {{message}}, {{delay}} |
| A range | {{delay}}.min and {{delay}}.max |
| A list: checkboxes, tags, file lines | As a whole — into a FOREACH loop ({{targets}}), one at a time — with the Get Resource Value action and its Take Item parameter |
To take apart a complex value, save it to a variable or use the JSON module.
Groups and layout
The Layout Manager arranges the fields into groups: a column, a row or a grid, with or without a title, a collapsible group for rarely used settings. On the right is a live preview of the form.
Groups are worth creating when there are more than five or six fields and they fall into topics: "Targets", "Texts", "Delays".
Conditional visibility
In the Visibility section a field gets a condition: show it only when another field has the right value. For example, the "Reply text" field is visible only if the "Reply to messages" switch is on. There can be several conditions: Match all (AND) or Match any (OR).
Translations
Title is the field's label in the form. The Manage Translations button next to it sets the text for Multogram's languages: English, Russian, Ukrainian, Chinese and Hindi. Descriptions, placeholders and choice options are translated the same way. If there is no translation, English is shown.
Values for tests
Set Values opens all resources with their current values — set the data for tests here. For accounts, give test rows: the paths to a test account's files.
Values aren't saved in the project
The project stores the resource's description and its default value, but not the current value. After reopening the project, set the test values again.
Resources at runtime
The Resources module reads and changes resources right while the module runs: Get Resource Value (as a whole or one list item at a time), Set Resource Value (replace or add an item to a list), Create Resource, Delete Resource, Get All Resources.
Updated
Functions
Functions in the Multogram Modules Constructor: the Main function, your own functions with parameters and a return value, calling them with Call Function, folders and the function manager.
Threads and accounts
How a Multogram module runs in several threads: what a thread is, how to hand accounts out to threads without repeats, when a module's task ends, shared and local data, the task's log and statistics, running functions in parallel.