delDeletes a local or module variable.
Signature: del(varName string)
Arguments: varName — the name of the variable as a string. The variable name can include a scope prefix, such as $ (for local variables) or # (for module variables). If the prefix is omitted, the variable is considered local.
Return value: None.
Example of use:
$localVar = 123
#moduleVar = true
del(“$localVar”) // Deletes the local variable $localVar
del(“localVar”) // Same as del(“$localVar”)
del(“#moduleVar”) // Deletes a variable with a scope within a module
setClientTimezoneOffsetChanges the current time zone offset of the user (the bot's interlocutor).
Signature: setClientTimezoneOffset(offset int)
Arguments: offset — time zone offset in minutes. Positive values mean eastward offset, negative values mean westward offset.
Return value: None.
Note: Calling this function will also change the values of the system variables now, today, and time according to the new time zone.
Example of use:
setClientTimezoneOffset(-1800) // Sets the time zone offset to -30 minutes (for example, for the UTC-30 time zone)
asBoolConverts the value to a Boolean type.
Signature: asBool(obj any) bool
Arguments: obj — any value that needs to be converted.
Return value: Boolean value.
Note: In BPL (Basic Programming Language), all values can be converted to Boolean type. For example, nil, empty strings, or zero are converted to false, and all other values are converted to true.
Example of use:
$bool = asBool(nil) // $bool contains false
$bool = asBool(“”) // $bool contains false
$bool = asBool(0) // $bool contains false
$bool = asBool([]) // $bool contains true
$bool = asBool(123) // $bool contains true
asStringConverts a value to a string.
Signature: asString(obj any) string
Arguments: *obj — any value that needs to be converted.
Return value: String representation of the value.
Note: In BPL, all values can be converted to string type.
Example of use:
$str = asString(123) // $str equals “123”
$str = asString(1.23) // $str equals “1.23”
$str = asString(true) // $str is equal to “true”
$str = asString({1: “a b c”, 2: 0.5}) // $str is equal to “{1: ”a b c“, 2: 0.5}”
asIntConverts a value to an integer.
Signature: asInt(obj any) int
Arguments: obj — any value that needs to be converted.
Return value: An integer value. If conversion is not possible, 0 is returned.
Example of use:
$int = asInt(5.67) // $int is equal to 5
$int = asInt(“123”) // $int is equal to 123
$int = asInt(true) // $int is equal to 1
$int = asInt(nil) // $int is equal to 0
$int = asInt(“abc”) // $int is equal to 0
asFloatConverts a value to a real number.
Signature: asFloat(obj any) float
Arguments: obj — any value to be converted.
Return value: A real number. If conversion is not possible, 0 is returned.
Example of use:
$float = asFloat(“5.67”) // $float is equal to 5.67
$float = asFloat(123) // $float equals 123.0
$float = asfloat(true) // $float equals 1.0
$float = asfloat(nil) // $float equals 0.0
$float = asFloat(“abc”) // $float equals 0.0