Difference between revisions of "Bot Playground/Built-in Functions"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} The basic built-in functions do not relate to bot functionality. Instead, they allow writing flexible scripts. <syntaxhighlight lang="javascr...") |
m (Add the _assert function) |
||
| (14 intermediate revisions by 3 users not shown) | |||
| Line 9: | Line 9: | ||
{{API_Table_start|Command|Description}} | {{API_Table_start|Command|Description}} | ||
| + | {{API_Group|Script details}} | ||
| + | {{API_Entry|HTTP Bot Command|process.name}} | ||
| + | {{API_Entry|HTTP Bot Command|process.release}} | ||
{{API_Group|Program flow}} | {{API_Group|Program flow}} | ||
| + | {{API_Entry|HTTP Bot Command|process.exit}} | ||
| + | {{API_Entry|HTTP Bot Command|process.sleep}} | ||
| + | {{API_Entry|HTTP Bot Command|Timer control}} | ||
| + | |||
| + | {{API_Group|Persistent bot storage}} | ||
| + | {{API_Entry|HTTP Bot Command|localStorage.get}} | ||
| + | {{API_Entry|HTTP Bot Command|localStorage.set}} | ||
| + | {{API_Entry|HTTP Bot Command|localStorage.keys}} | ||
| + | {{API_Entry|HTTP Bot Command|localStorage.on}} | ||
| + | |||
| + | {{API_Group|User settings}} | ||
| + | {{API_Entry|HTTP Bot Command|userSettings.*}} | ||
| + | |||
| + | {{API_Group|HTTP}} | ||
| + | {{API_Entry|HTTP Bot Command|http.get}} | ||
| + | {{API_Entry|HTTP Bot Command|http.post}} | ||
| + | {{API_Entry|HTTP Bot Command|http.requestWebhookUrl}} | ||
| + | |||
| + | {{API_Group|Debug}} | ||
{{API_Entry|HTTP Bot Command|console.log}} | {{API_Entry|HTTP Bot Command|console.log}} | ||
| + | {{API_Entry|HTTP Bot Command|console.warn}} | ||
{{API_Entry|HTTP Bot Command|console.error}} | {{API_Entry|HTTP Bot Command|console.error}} | ||
| − | {{API_Entry|HTTP Bot Command| | + | {{API_Entry|HTTP Bot Command|_assert}} |
| − | + | ||
{{API_Table_end}} | {{API_Table_end}} | ||
Latest revision as of 12:59, 18 September 2025
The basic built-in functions do not relate to bot functionality. Instead, they allow writing flexible scripts.
setTimeout(function() { console.log("Timer has fired!"); }, 3000);
Commands reference
| Command | Description | |
|---|---|---|
Script details | ||
| process.name | Read-only property reflecting running script name. | |
| process.release | Read-only property reflecting the script release version (for Store-purchased scripts). | |
Program flow | ||
| process.exit | Ends the execution of the program. | |
| process.sleep | Pauses a program execution. | |
| Timer control | Standard timer control routines of JavaScript: setTimeout, setInterval etc. | |
Persistent bot storage | ||
| localStorage.get | Restores a string value from a persistent storage. | |
| localStorage.set | Puts a string value into a persistent storage. | |
| localStorage.keys | Returns the list of the available keys in a persistent storage. | |
| localStorage.on | Adds the event callback on localStorage. | |
User settings | ||
| userSettings.* | Allows accessing the settings specified by the script user. | |
HTTP | ||
| http.get | Retrieves data from a HTTP source. | |
| http.post | Retrieves data from a HTTP source using the POST method. | |
| http.requestWebhookUrl | Allocates a new, per-run webhook URL and authorization token for the current script instance. | |
Debug | ||
| console.log | Logs data to the runtime log. | |
| console.warn | Logs data to the error log. | |
| console.error | Logs data to the error log. | |
| _assert | Logs data to the error log if the assertion is false. | |