Class BlockFunction
A block that can execute a specific function on one or multiple inputs.
Implements
Inherited Members
Namespace: RuriLib
Assembly: RuriLib.dll
Syntax
public class BlockFunction : BlockBase, INotifyPropertyChanged
Constructors
| Improve this Doc View SourceBlockFunction()
Creates a Function block.
Declaration
public BlockFunction()
Properties
| Improve this Doc View SourceAesKey
The keys used for AES encryption and decryption.
Declaration
public string AesKey { get; set; }
Property Value
Type | Description |
---|---|
System.String |
CharIndex
The index of the wanted character.
Declaration
public string CharIndex { get; set; }
Property Value
Type | Description |
---|---|
System.String |
DateFormat
The format of the date (y = year, M = month, d = day, H = hour, m = minute, s = second).
Declaration
public string DateFormat { get; set; }
Property Value
Type | Description |
---|---|
System.String |
FunctionType
The function to execute.
Declaration
public BlockFunction.Function FunctionType { get; set; }
Property Value
Type | Description |
---|---|
BlockFunction.Function |
HashType
The hashing function to use.
Declaration
public BlockFunction.Hash HashType { get; set; }
Property Value
Type | Description |
---|---|
BlockFunction.Hash |
HmacBase64
Whether to output the message as a base64-encoded string instead of a hex-encoded string.
Declaration
public bool HmacBase64 { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
HmacKey
The key used to authenticate the message.
Declaration
public string HmacKey { get; set; }
Property Value
Type | Description |
---|---|
System.String |
InputString
The input string on which the function will be executed (not always needed).
Declaration
public string InputString { get; set; }
Property Value
Type | Description |
---|---|
System.String |
IsCapture
Whether the output variable should be marked for Capture.
Declaration
public bool IsCapture { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RandomMax
The maximum random number that can be generated.
Declaration
public int RandomMax { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
RandomMin
The minimum random number that can be generated.
Declaration
public int RandomMin { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
RegexMatch
The regex pattern to match.
Declaration
public string RegexMatch { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ReplaceWhat
The text to replace.
Declaration
public string ReplaceWhat { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ReplaceWith
The replacement text.
Declaration
public string ReplaceWith { get; set; }
Property Value
Type | Description |
---|---|
System.String |
RSAExp
The exponent of the RSA key.
Declaration
public string RSAExp { get; set; }
Property Value
Type | Description |
---|---|
System.String |
RSAMod
The modulus of the RSA key.
Declaration
public string RSAMod { get; set; }
Property Value
Type | Description |
---|---|
System.String |
StopAfterFirstMatch
Whether to stop translating after the first match.
Declaration
public bool StopAfterFirstMatch { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
StringToFind
The string to count the occurrences of.
Declaration
public string StringToFind { get; set; }
Property Value
Type | Description |
---|---|
System.String |
SubstringIndex
The starting index for the substring.
Declaration
public string SubstringIndex { get; set; }
Property Value
Type | Description |
---|---|
System.String |
SubstringLength
The length of the wanted substring.
Declaration
public string SubstringLength { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TranslationDictionary
The dictionary containing the words and their translation.
Declaration
public Dictionary<string, string> TranslationDictionary { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
UseRegex
Whether to use regex for replacing.
Declaration
public bool UseRegex { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
VariableName
The name of the output variable.
Declaration
public string VariableName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceAESDecrypt(String, String)
Decrypts an AES-encrypted string.
Declaration
public static string AESDecrypt(string key, string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The decryption key |
System.String | data | The AES-encrypted data |
Returns
Type | Description |
---|---|
System.String | The plaintext string |
AESEncrypt(String, String)
Encrypts a string with AES.
Declaration
public static string AESEncrypt(string key, string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The encryption key |
System.String | data | The data to encrypt |
Returns
Type | Description |
---|---|
System.String | The AES-encrypted string |
Base64Decode(String)
Decodes a base64-encoded string.
Declaration
public static string Base64Decode(string base64EncodedData)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64EncodedData | The base64-encoded string |
Returns
Type | Description |
---|---|
System.String | The decoded string |
Base64Encode(String)
Encodes a string to base64.
Declaration
public static string Base64Encode(string plainText)
Parameters
Type | Name | Description |
---|---|---|
System.String | plainText | The string to encode |
Returns
Type | Description |
---|---|
System.String | The base64-encoded string |
CountStringOccurrences(String, String)
Counts how many times a string occurs inside another string.
Declaration
public static int CountStringOccurrences(string input, string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The long string |
System.String | text | The text to search |
Returns
Type | Description |
---|---|
System.Int32 | How many times the text appears in the long string |
FromLS(String)
Builds a block from a line of LoliScript code.
Declaration
public override BlockBase FromLS(string line)
Parameters
Type | Name | Description |
---|---|---|
System.String | line | The line of LoliScript code |
Returns
Type | Description |
---|---|
BlockBase | The parsed block object |
Overrides
| Improve this Doc View SourceGetDictionary()
Builds a string containing translation keys.
Declaration
public string GetDictionary()
Returns
Type | Description |
---|---|
System.String | One translation key per line, with name and value separated by a colon |
GetHash(String, BlockFunction.Hash)
Hashes a string using the specified hashing function.
Declaration
public static string GetHash(string baseString, BlockFunction.Hash type)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseString | The string to hash |
BlockFunction.Hash | type | The hashing function |
Returns
Type | Description |
---|---|
System.String | The hash digest as a hex-encoded string |
Hmac(String, BlockFunction.Hash, String, Boolean)
Gets the HMAC signature of a message given a key and a hashing function.
Declaration
public static string Hmac(string baseString, BlockFunction.Hash type, string key, bool base64)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseString | The message to sign |
BlockFunction.Hash | type | The hashing function |
System.String | key | The HMAC key |
System.Boolean | base64 | Whether the output should be encrypted as a base64 string |
Returns
Type | Description |
---|---|
System.String | The HMAC signature |
Process(BotData)
Executes the actual block logic.
Declaration
public override void Process(BotData data)
Parameters
Type | Name | Description |
---|---|---|
BotData | data | The BotData needed for variable replacement |
Overrides
| Improve this Doc View SourceRandomUserAgent(Random)
Gets a random User-Agent header.
Declaration
public static string RandomUserAgent(Random rand)
Parameters
Type | Name | Description |
---|---|---|
System.Random | rand | A random number generator |
Returns
Type | Description |
---|---|
System.String | A randomly generated User-Agent header |
SetDictionary(String[])
Sets translation keys from an array of lines.
Declaration
public void SetDictionary(string[] lines)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | lines | The lines containing the colon-separated name and value of the translation keys |
ToLS(Boolean)
Converts the block to LoliScript code.
Declaration
public override string ToLS(bool indent = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | indent |
Returns
Type | Description |
---|---|
System.String |