While playing around with Messages this morning, I noticed that it ships with a feature that, if used, throws an error. Steps to reproduce:
Open Messages' preferences.
Set the Applescript handler pop-up to any of the listed scripts:
Close preferences, and try to send a message to anyone.
Revel in the brokenness.
I especially like the execution error: No error message…it's that rare non-error that tosses up an error dialog!
In any event, I think it's shameful that Apple ships the app with a feature—plainly obvious in prefs—that breaks when used. Yes, I know AppleScript is probably dying, but that doesn't excuse shipping the app with a clearly-broken feature; if it doesn't work, just remove it. Apparently this has been an issue since Yosemite's release in October of 2014!
With all that said, fixing this is incredibly easy—it took me about 30 seconds of "work" to find and fix the problem. If you'd like to use the bundled AppleScripts in Messages—either as is, or in some modified form—here's what you need to do
In Messages' prefs, select Open Scripts Folder from the AppleScript handler pop-up. Now open all six scripts in Script Editor (in Applications > Utilities). Find these four lines in each Apple-provided script (note I've removed the silly whitespace Apple included):
on received remote screen sharing invitation from theBuddy for theChat end received remote screen sharing invitation on received local screen sharing invitation from theBuddy for theChat end received local screen sharing invitation
To fix the scripts, comment those lines out, which you do in AppleScript with two hyphens. After editing, that section should look like this:
--on received remote screen sharing invitation from theBuddy for theChat --end received remote screen sharing invitation --on received local screen sharing invitation from theBuddy for theChat --end received local screen sharing invitation
Save the modified scripts, and the error message will vanish when you select a script in Messages' preferences. I tested with the iTunes Remote Control script, and it worked fine after making the above edits. (Note for it to work, the chat that's sending the iTunes commands can't be the frontmost chat. If testing with a buddy, switch to another chat before they send the controlling commands.)
I assume there's probably a better fix—those commands I commented out have probably been renamed—but I didn't bother spending any time looking for that fix, because I'm not getting paid to fix Apple's problems.