Namespace BotManager.Runtime.Expressions
Classes
- And
Logical and operator. It returns
trueif all expression in this list aretrueor if the list is empty. Execution is stopped, once the first entry returnsfalse.Return type is bool.
This json example returns true:
This json example returns{ "$And": [ true, true ] }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:
Or even shorter:{ "$Boolean": true }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,2or3chosen 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 return0:{ "$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:
This json example returns{ "$Equals": { "A": 10, "B": 10 } }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:
This json example returns{ "$If": { "Condition": true, "Then": 10, "Else": 20 } }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:
This json example returns{ "$In": { "Value": 10, "List": [ 1, 2, 10 ] } }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:
Or even shorter:{ "$Int32": 10 }10
- List
A list of IExpression that will be executed sequentially. The returned values of the expressions is returns as an array if
returnTypeis 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:
This json example returns{ "$Not": true }true:{ "$Not": false }
- Or
Logical or operator. It returns
trueif any expression in this list istrueor if the list is empty. Execution is stopped, once the first entry returnstrue.Return type is bool.
This json example returns true:
This json example returns{ "$Or": [ true, false ] }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 10and returns this value:{ "$Set": { "Name": "MyVar", "Value": 10 } }
- String
A static string value.
Returns type is string.
This json example returns "Hello":
Or even shorter:{ "$String": "Hello" }"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 } }