Table of Contents

Namespace BotManager.Runtime.Expressions

Classes

And

Logical and operator. It returns true if all expression in this list are true or if the list is empty. Execution is stopped, once the first entry returns false.

Return type is bool.

This json example returns true:
{ "$And": [ true, true ] }
This json example returns false:
{ "$And": [ true, false ] }
Async

Runs the Expression in a new thread.

Return type is null.

This json example waits 5 seconds in a async thread, but doesn't block the main thread and returns null:
{ "$Async": { "$Delay": 5000 } }
Boolean

A static bool value.

Returns type is bool.

This json example returns true:
{ "$Boolean": true }
Or even shorter:
true
Call

Calls a registered function and returns it's value. Use Function to register a function beforehand.

Returns the value of the executed function.

This json example executes the user-defined function "MyFunction" and returns its value:
{ "$Call": "MyFunction" }
Choose

Executes and returns a random item from this list.

Return type is the type of the chosen item.

This json example returns either 1, 2 or 3 chosen randomly:
{ "$Choose": [ 1, 2, 3 ] }
Cooldown

Executes the Action expression with a cooldown of Milliseconds. If this expression is called multiple times while the cooldown timer is still ticking down, then the Fallback branch is executed instead.

The cooldown timer is started before Action is executed. The time Action takes to run is ignored in the cooldown timer.

Returns the value of the executed branch.

This json example will return 10, but when called again withing 5 minutes will return 0:
{ "$Cooldown": { "Action": 10, "Fallback": 0, "Milliseconds": 300000 } }
Delay

Holds execution and waits the defined number of milliseconds.

Return type is null.

This json example waits three seconds and returns null:
{ "$Delay": 3000 }
Env

Returns the value of a variable from the system environment variables.

Return type is string.

This json example returns the value of the environment variable "MY_VAR":
{ "$Env": "MY_VAR" }
Equals

Returns a boolean value if A and B are equal.

Returns type os bool.

This json example returns true:
{ "$Equals": { "A": 10, "B": 10 } }
This json example returns false:
{ "$Equals": { "A": 10, "B": 100 } }
Error

Writes a log message to the error output.

Return type is null.

This json example writes an error to the output and returns null:
{ "$Error": "This is an error!" }
Format

Formats a string by using Format(string, params object[]).

Return type is string.

This json example returns "Hello World! 1 + 2 = 3":
{ "$Format": { "Text": "Hello {0}! {1} + {2} = {3}", "Parameters": [ "World", 1, 2, 3 ] } }
Function

Registers a new function in the runtime context. Use Call to execute it later.

Return type is null.

This json example executes registers a user-defined function "MyFunction":
{ "$Function": { "Name": "MyFunction", "Action": 10 } }
Get

Returns the value of a variable from the current RuntimeContext.

Return type is the type of the variable.

This json example returns the value of the "MyVar" variable:
{ "$Get": "MyVar" }
If

Executes the Then expression if Condition returns true. Otherwise Else is executed.

Returns the value of the executed branch.

This json example returns 10:
{ "$If": { "Condition": true, "Then": 10, "Else": 20 } }
This json example returns 20:
{ "$If": { "Condition": false, "Then": 10, "Else": 20 } }
In

Returns a boolean value if Value is equal to at least one item in List.

Return type is bool.

This json example returns true:
{ "$In": { "Value": 10, "List": [ 1, 2, 10 ] } }
This json example returns false:
{ "$In": { "Value": 10, "List": [ 1, 2, 3 ] } }
Include

Includes and executes an external json config. The included file is only read and parsed once on the first execution.

Returns the value that is returned by the executed file.

This json example executes the expression in the "inc.json" file and returns its value:
{ "$Include": "inc.json" }
Info

Writes a log message to the standard output.

Return type is null.

This json example writes an info message to the output and returns null:
{ "$Info": "This is an info!" }
Int32

A static int value.

Return type is int.

This json example returns 10:
{ "$Int32": 10 }
Or even shorter:
10
Int64

A static long value.

Return type is long.

This json example returns 10:
{ "$Int64": 10 }
List

A list of IExpression that will be executed sequentially. The returned values of the expressions is returns as an array if returnType is not set to null.

Return type is Array or null.

This json example returns a list with the values 1, 2, 3:
[ 1, 2, 3 ]
Not

Inverts the given boolean expression.

Return type is bool.

This json example returns false:
{ "$Not": true }
This json example returns true:
{ "$Not": false }
Or

Logical or operator. It returns true if any expression in this list is true or if the list is empty. Execution is stopped, once the first entry returns true.

Return type is bool.

This json example returns true:
{ "$Or": [ true, false ] }
This json example returns false:
{ "$Or": [ false, false ] }
Set

Sets a variable in the current RuntimeContext.

Returns type is the type of the variable.

This json example set the variable "MyVar" to 10 and returns this value:
{ "$Set": { "Name": "MyVar", "Value": 10 } }
String

A static string value.

Returns type is string.

This json example returns "Hello":
{ "$String": "Hello" }
Or even shorter:
"Hello"
Try

Trys to execute the Expression and handles any exceptions. If an exception is throw while executing Expression, it will write the Exception to 'exception' in the current RuntimeContext and then run the Catch expression.

Returns the value of the executed branch.

This json example returns 10:
{ "$Try": { "Expression": 10, "Catch": -10 } }
UInt32

A static uint value.

Return type is uint.

This json example returns 10:
{ "$UInt32": 10 }
UInt64

A static ulong value.

Return type is ulong.

This json example returns 10:
{ "$UInt64": 10 }