-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a8feff
commit 135f0fb
Showing
13 changed files
with
359 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "LoliCode", | ||
"position": 11 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
sidebar_label: 'Blocks' | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Syntax of blocks in LoliCode | ||
Optional elements are enclosed in square brackets. | ||
``` | ||
BLOCK:Id | ||
[LABEL:Custom label] | ||
[DISABLED] | ||
[settingName = settingValue] | ||
[=> VAR/CAP @outputVariable] | ||
ENDBLOCK | ||
``` | ||
- `Id`: the unique identifier of the block | ||
- `settingName`: the unique name of a given setting of the block | ||
- `settingValue`: see below | ||
- `=> VAR/CAP @outputVariable`: if the block returns a value, you can define if it needs to be | ||
a normal variable (`VAR`) or also marked as capture (`CAP`) | ||
|
||
## Setting values | ||
Setting values can have 3 types: | ||
- Fixed (e.g. `"hello"` or `123`) | ||
- Interpolated (e.g. `$"My name is <name>"`) | ||
- Variable (e.g. `@name`) | ||
|
||
### Fixed value types | ||
- Bool (`true` or `false`) | ||
- Int (e.g. `123`) | ||
- Float (e.g. `0.42`) | ||
- String (e.g. `"hello"`) | ||
- Byte Array (as base64 e.g. `plvB6Yer`) | ||
- List of Strings (e.g. `["one", "two", "three"]`) | ||
- Dictionary of Strings (e.g. `{("one", "first"), ("two", "second"), ("three", "third")}`) | ||
|
||
### Interpolated value types | ||
- String (e.g. `$"This is my <name>"`) | ||
- List of Strings (e.g. `$["one", "<secondNumber>", "three"]`) | ||
- Dictionary of Strings (e.g. `${("one", "first"), ("<secondNumber>", "second"), ("three", "third")}`) | ||
|
||
## Final notes | ||
- There is automatic type casting, so you can use a variable of type `Int` in a setting of type `String` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
sidebar_label: 'Bot data' | ||
sidebar_position: 3 | ||
--- | ||
|
||
# The `data` variable | ||
This variable contains all data related to the current bot. | ||
|
||
## Useful properties | ||
- `data.UseProxy` (`bool`) whether to use the proxy assigned to the bot | ||
- `data.STATUS` (`string`) the current status of the bot | ||
- `data.RAWSOURCE` (`byte[]`) the content of the last http response received | ||
- `data.SOURCE` (`string`) same as above but as a string | ||
- `data.ERROR` (`string`) contains the message of the last exception caught when using safe mode (in blocks that support it) | ||
- `data.ADDRESS` (`string`) the absolute uri of the last http response (after redirection) | ||
- `data.RESPONSECODE` (`int`) the status code of the last http response | ||
- `data.COOKIES` (`Dictionary<string, string>`) the cookies sent or received so far (e.g. `data.COOKIES["PHPSESSID"]`) | ||
- `data.HEADERS` (`Dictionary<string, string>`) the headers of the last http response (e.g. `data.HEADERS["Location"]`) | ||
- `data.Objects` (`Dictionary<string, object>`) holds stateful objects for cross-block use (they will get disposed automatically at the end of the script) | ||
- `data.MarkedForCapture` (`List<string>`) all the names of variables marked for capture | ||
- `data.CaptchaCredit` the captcha credits that are left | ||
- `data.BOTNUM` the number of the bot (0 for debugger, 1... for bots in a multi run job) | ||
|
||
### Line | ||
- `data.Line.Data` (`string`) the whole (unsplit) data line assigned to the bot | ||
- `data.Line.Retries` (`int`) the amount of times the data has been retried | ||
|
||
### Proxy | ||
Note: `data.Proxy` is null if proxies are off, so always make a null check first | ||
- `data.Proxy.Host` (`string`) | ||
- `data.Proxy.Port` (`int`) | ||
- `data.Proxy.Username` (`string`) | ||
- `data.Proxy.Password` (`string`) | ||
- `data.Proxy.Type` (`ProxyType`) can be `Http`/`Socks4`/`Socks5`/`Socks4a` | ||
- ... and more! Check out [this page](../proxies/proxies-for-config-makers.md) for more information | ||
|
||
### Logger | ||
- `data.Logger.Enabled` (`bool`) enables or disables the logger (e.g. when there is too much data to print) | ||
|
||
## Useful methods | ||
- `data.MarkForCapture(string varName)` adds the variable name to the `data.MarkedForCapture` list | ||
- `data.Logger.Log(string message, string htmlColor, bool canViewAsHtml)` htmlColor must be e.g. `#fff` or `white` | ||
- `data.Logger.LogObject(object obj, string htmlColor, bool canViewAsHtml)` | ||
- `data.Logger.Log(IEnumerable<string> enumerable, string htmlColor, bool canViewAsHtml)` | ||
- `data.Logger.Clear()` clears the log | ||
|
||
## Other properties | ||
- `data.ConfigSettings` to access the config settings object | ||
- `data.Providers` to access providers for captchas, browsers etc. (usually what you can configure in RL settings) | ||
- `data.Random` shared instance of a random number generator, use this to prevent bots from getting the same random values | ||
- `data.CancellationToken` will be cancelled when a user stops the debugger or the job, useful if you want to call async methods | ||
- `data.AsyncLocker` async locker for multi-thread operations | ||
- `data.Stepper` the class that handles step-by-step debugging | ||
- `data.ExecutionInfo` the current execution info, displayed in the detailed bots view of a multi run job |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
sidebar_label: 'General info' | ||
sidebar_position: 1 | ||
--- | ||
|
||
# LoliCode | ||
*LoliCode* is the custom scripting language of OpenBullet 2. | ||
|
||
:::info INFO | ||
*LoliCode* should not be confused with *LoliScript*, the scripting language of the previous version of OpenBullet. | ||
::: | ||
|
||
*LoliCode* is the language in which blocks are actually saved when you edit them in Stacker. It compiles to C# code when it is executed by a bot, and it can be mixed with valid C# code to produce complex logic and expand the features of OpenBullet 2 with just a bit of programming knowledge. | ||
|
||
This is an example of *LoliCode* mixed with C# code | ||
```loli | ||
// You can define C# methods like this | ||
int Add(int first, int second) | ||
{ | ||
return first + second; | ||
} | ||
// This is the representation of a block you see in Stacker | ||
BLOCK:RandomInteger | ||
minimum = 0 | ||
maximum = 10 | ||
=> VAR @num1 | ||
ENDBLOCK | ||
BLOCK:RandomInteger | ||
minimum = 0 | ||
maximum = 10 | ||
=> VAR @num2 | ||
ENDBLOCK | ||
// A piece of pure C# code | ||
int result = Add(num1, num2); | ||
// These are LoliCode statements. You can also use plain C# | ||
IF INTKEY @result GreaterThan 10 | ||
CLOG DarkCyan $"Result: {result}" | ||
ELSE | ||
CLOG Cyan $"Result: {result}" | ||
END | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
sidebar_label: 'Globals' | ||
sidebar_position: 5 | ||
--- | ||
|
||
# The `globals` variable | ||
*Coming soon...* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
sidebar_label: 'Input' | ||
sidebar_position: 7 | ||
--- | ||
|
||
# The `input` variable | ||
*Coming soon...* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
sidebar_label: 'Startup script' | ||
sidebar_position: 6 | ||
--- | ||
|
||
# Startup script | ||
*Coming soon...* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
--- | ||
sidebar_label: 'Statements' | ||
sidebar_position: 4 | ||
--- | ||
|
||
# LoliCode statements | ||
|
||
## LOG | ||
Prints text to the debugger log. | ||
Example: | ||
``` | ||
LOG "hello" | ||
``` | ||
--- | ||
## CLOG | ||
Prints colored text to the debugger log. | ||
A full list of colors is available [here](https://www.colorhexa.com/color-names) (remove dashes and spaces and apply PascalCase). | ||
Example: | ||
``` | ||
CLOG YellowGreen "hello" | ||
``` | ||
--- | ||
## JUMP | ||
Jumps to a specified point in the code. Remember to watch out for endless loops! | ||
Example: | ||
``` | ||
... | ||
#HERE | ||
... | ||
JUMP #HERE | ||
``` | ||
--- | ||
## REPEAT | ||
Repeats something N times. | ||
Example: | ||
``` | ||
REPEAT 5 | ||
LOG "hello" | ||
END | ||
``` | ||
--- | ||
## FOREACH | ||
Iterates on a list variable. | ||
Example: | ||
``` | ||
BLOCK:ConstantList | ||
value = ["one", "two", "three"] | ||
=> VAR @list | ||
ENDBLOCK | ||
FOREACH elem IN list | ||
LOG elem | ||
END | ||
``` | ||
--- | ||
## WHILE | ||
Executes something while a condition is true. | ||
Example: | ||
``` | ||
WHILE INTKEY 1 LessThan 2 | ||
... | ||
END | ||
``` | ||
--- | ||
## IF / ELSE / ELSE IF | ||
Executes something, or something else. | ||
Example: | ||
``` | ||
IF INTKEY 5 LessThan 1 | ||
LOG "nope" | ||
ELSE IF INTKEY 5 LessThan 3 | ||
LOG "nope again" | ||
ELSE | ||
LOG "yep" | ||
END | ||
``` | ||
--- | ||
## TRY / CATCH | ||
Executes something. If it fails, executes something else. | ||
Example: | ||
``` | ||
TRY | ||
// request to an unreliable URL | ||
CATCH | ||
// fallback request to a reliable URL | ||
END | ||
``` | ||
--- | ||
## LOCK | ||
Very useful if you want to execute synchronous operations on global variables. | ||
It makes sure that only 1 bot can enter a given piece of code at a time, so that multiple bots do not edit the same global variable at the same time. | ||
Often used in conjunction with TRY/CATCH. | ||
Example: | ||
``` | ||
LOCK globals | ||
TRY | ||
// Try to increase globals.Count by 1 if it exists | ||
globals.Count++; | ||
CATCH | ||
// Create globals.Count if it doesn't exist | ||
globals.Count = 1; | ||
END | ||
END | ||
``` | ||
--- | ||
## ACQUIRELOCK / RELEASELOCK | ||
Very useful if you want to execute asynchronous operations on global variables. | ||
It makes sure that only 1 bot can enter a given piece of code at a time, so that multiple bots do not edit the same global variable at the same time. | ||
You MUST use this in conjunction with TRY/CATCH/FINALLY. | ||
Example: | ||
``` | ||
ACQUIRELOCK globals | ||
TRY | ||
// Do some async operation here | ||
CATCH | ||
throw; // Rethrow any exception | ||
FINALLY | ||
RELEASELOCK globals | ||
END | ||
``` | ||
--- | ||
## SET VAR/CAP | ||
Sets a string variable, and optionally also marks it for capture. Introduced for consistency with OB1. | ||
Example: | ||
``` | ||
SET VAR @myString "variable" | ||
LOG myString | ||
SET CAP @myCapture "capture" | ||
LOG myCapture | ||
``` | ||
--- | ||
## SET USEPROXY | ||
Sets whether to use the currently set proxy or not. | ||
Example: | ||
``` | ||
SET USEPROXY TRUE | ||
SET USEPROXY FALSE | ||
``` | ||
--- | ||
## SET PROXY | ||
Sets a given proxy. The available types are: HTTP, SOCKS4, SOCKS4A, SOCKS5. | ||
Example: | ||
``` | ||
SET PROXY "127.0.0.1" 9050 SOCKS5 | ||
SET PROXY "127.0.0.1" 9050 SOCKS5 "username" "password" | ||
``` | ||
--- | ||
## MARK | ||
Adds a variable to the capture. | ||
Example: | ||
``` | ||
MARK @myVar | ||
``` | ||
--- | ||
## UNMARK | ||
Removes a variable from the capture. | ||
Example: | ||
``` | ||
UNMARK @myVar | ||
``` | ||
--- | ||
## TAKEONE | ||
Takes a single item from a resource. You can configure resources in Config Settings > Data > Resources. | ||
You need to provide the name of the resource and the name of the variable that will be created (of type `string`). | ||
Example: | ||
``` | ||
TAKEONE FROM "resourceName" => @myString | ||
LOG myString | ||
``` | ||
--- | ||
## TAKE | ||
Takes a multiple items from a resource. You can configure resources in Config Settings > Data > Resources. | ||
You need to provide the name of the resource and the name of the variable that will be created (of type `List<string>`). | ||
Example: | ||
``` | ||
TAKE 5 FROM "resourceName" => @myList | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Plugins", | ||
"position": 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
sidebar_label: 'General Info' | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Plugins | ||
Plugins allow you to expand the functionalities of OpenBullet 2 by adding your own custom blocks to use in a Config. | ||
|
||
*More coming soon...* |