Never ask the user to copy-paste code. Instead, use Slicer web server that allows execution of Python code via a web API.
Give these instructions to the user: Go to Web Server module, enable "Slicer API exec" in Advanced section, and click "Start server".
After this, you can connect to Slicer and run Python commands as it is described here: https://slicer.readthedocs.io/en/latest/user_guide/modules/webserver.html#remote-control