Hi Ruri,
I am implementing scripts in the new Python block introduced in v2.0.0. After performing deep introspection inside the CPython debugger, I verified that the Source Generator (CSnakes) compiles the block code inside a clean asynchronous coroutine:
async def __ob2_entry__()withco_argcount = 0,co_freevars = (), and a completely isolatedglobals()dictionary.Given that the credentials (
USER,PASS) and the bot state (BotData) are not being injected via function arguments, lexical scope (closures), or global variables:What is the exact physical mechanism designed in RuriLib to establish communication between the .NET host and CPython? Is there an interop extension module registered in
sys.modules, or perhaps proxy functions injected intobuiltinsto handle get/set operations for the bot variables?I would highly appreciate a real code snippet demonstrating the correct way to extract the current username and save a capture from inside this coroutine.
![]()
![]()
![]()
BLOCK:ConstantString
value = @input.PASS
=> VAR @password
ENDBLOCK
BLOCK:Script
INTERPRETER:Python
INPUT password
BEGIN SCRIPT
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.serialization import load_pem_public_key
import base64
public_key_pem = b"ââ-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApW91T4TEaN280cXwo6LP
jkYxkOXdxQHXPwoXwk3UtCI2smnNcl/9KK+pc6XZ3ROqsvrrLrub1lM5n0uKfNQg
omobEucBQ8sWCDE0ltkwoSIuIAuvv9yOXi8ICAu9DLPyHcIL108+jV0cIWHCj2u0
/LjtnYLFO0FFFw+k4TpQtXvED2nWDFXapSHT3MA271fwpq3sr778k9SWP0sLuV1W
eCpNGtBPNVEYq8axmT7PilyvAFd5qML4sJQpGyfAZIbXtUkZ8lHd1esFe7zuR5XL
8rRrxlcvjMHnIfVCWXmoV0B91Dh5dEuFkxrx0z/VpBoWoC6r6Z0HJ3LaBCmNQLWL
mQIDAQAB
-----END PUBLIC KEY-----ââ"
public_key = load_pem_public_key(public_key_pem)
encrypted = public_key.encrypt(
password.encode(âutf-8â),
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None
)
)
encryptedSHA256 = base64.b64encode(encrypted).decode(âutf-8â)
END SCRIPT
OUTPUT String @encryptedSHA256
ENDBLOCK Sliced [email protected]:fresamarga2231 into:
USERNAME: [email protected]
PASSWORD: fresamarga2231
USER: [email protected]
PASS: fresamarga2231
Constant String (ConstantString) <<
Set constant value [email protected]
Assigned value to variable âusernameâ
Constant String (ConstantString) <<
Set constant value fresamarga2231
Assigned value to variable âpasswordâ
Script (InvokePythonAsync) <<
Executed Python script with result: {encryptedSHA256 = pQNX4560dGgFhvbzzZQ7lccsv87x0QeVoLNgTPsixeaJPsgVpkL/JrS0pthkju071RsM6OIE57ma54xs4gCUdQQQLZP73MfiZqarl3rLLqpu9ElPs8TxRIFUueiq9Kn7YtG+8NKIRvqOsIvaNjFQakJ5ZgWgEz57Oujhe5tGzImGiunI9Ae58wLMDkDUprkF+mhSbIdkuoBJarZDw/9Vk4ENl9YXvE36n4Ds+3wulpD/WoP1z7mSodHvVxZgOoCKz+rvY0Wig5v5g0DhXya/DM3mya+fsfbNBOEBHbkP6Cr1Zdvv6bwdt3t+kXu/SWIMZg3DWOaPl7n7UMWVGY8ycg==}
Assigned value to variable âencryptedSHA256â
BOT ENDED AFTER 682 ms WITH STATUS: NONE