Can anyone tell me why using an emoji in a message recipient name fails?
I do have an existing Message recipient, a group of three people; its original name was changed to match an iOS group.
Meta
Messages 11.0
macOS 10.13.6
Script
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--
set moneybag_cp_dec to 128176
set moneybag_char to character id moneybag_cp_dec
set recipient_name to "Weekly NFL Picks"
set recipient to moneybag_char & recipient_name & moneybag_char
set message to "
NFL 2025 Week 8 Games
-----------------------------------
Commanders @ Chiefs
Vikings @ Chargers
Dolphins @ Falcons
Jets @ Bengals
Browns @ Patriots
Giants @ Eagles
Bills @ Panthers
Bears @ Ravens
49ers @ Texans
Buccaneers @ Saints
Cowboys @ Broncos
Titans @ Colts
Packers @ Steelers
"
tell application "Messages"
activate
display dialog "Recipient: " & recipient giving up after 5
try
send message to buddy recipient -- 'text chat' didn't work
on error errMessage number errNum
display dialog errMessage & return & errNum
end try
end tell
Dialog Output
Messages got an error: Canât get buddy âWeekly NFL Picksâ:moneybag:â.
-1728
First, to format your code for posting, please put three backticks (the key above the tab) on a line immediately above and below your code. Donât include any other characters. This will make it easier to read as well as copy your text. Thanks.
```
[your code here]
```
Second, this is just a stab at the problem as I donât use this app.
The -1728 error means that the item in question doesnât exist where it is being requested from. So there is probably a missing piece to this line:
`send message to buddy recipient`
The dictionary for my version âwhich is oldâ suggests that you need to also specify either the service or text chat. The service youâre using needs to be figured out and specified. Perhaps something like this:
set bestBuddy to participant littleBuddy of account id targetedService
Whatever would be appropriate in your case, there should be an âofâ followed by whatever. And if itâs a text chat, then likely it would have a number as well, eg text chat 1.
Third: Regarding the emoji⌠it seems strange that it gets the first one correct but not the last one. Are you able to send to someone whose recipient name does not include any emoji?
I canât explain it well in English, but maybe itâs like this?
use AppleScript version "2.4"
use scripting additions
set moneybag_cp_dec to 128176 as integer
set moneybag_char to (character id moneybag_cp_dec) as text
set recipient_name to "Weekly NFL Picks" as text
log class of moneybag_char & recipient_name & moneybag_char
-->{text, "Weekly NFL Picks", "đ°"}
--> {class of đ° , "Weekly NFL Picks" , đ°}
-->NOTE: Text is undefined here, resulting in a value class of 'list'."
log class of (moneybag_char & recipient_name & moneybag_char) as text
-->(*text*)
check name of every participant
use AppleScript version "2.4"
use scripting additions
tell application "Messages"
set listAddName to (name of every participant) as list
end tell
log listAddName
-->I think the name is not listed here?
set valueResponse to (choose from list listAddName)
set strRecipient to (first item of valueResponse) as text
log strRecipient
set recipient to moneybag_char & recipient_name & moneybag_char
-->check recipient
Sorry about the code formatting â I noticed it was fubar when I posted it, but forgot the GitHub code block aspect. Figured Iâd figure out how to fix it when it wasnât 4am.
Using your âtext chat 1â approach posted to a random account from years ago.
Yes, if I change recipient to just my name, the code works like a champ.
I did notice one thing examining that particular field in SD7 â it looks as expected for the âBestâ and âSourceâ views. But the âAEPrintâ view shows 'utxt'("?Weekly NFL Picks?") which would explain the failure. But surely AS 2.7 is using Unicode, no?
Saw somewhere else the font cache data might be botched.
Could attempt fixing this using $ sudo atsutil database -remove and rebooting, but that seems rather drastic.
â1â is just an example. The issue is that you must specify an account and a service/chat in some manner. It could be an index number or a name or maybe an ID. So you need to try and find out how to specify the desired text chat.
Iâll use the Finder for an example because I donât use Messages. Each of these statements refers to the exact same window.
tell application "Finder"
position of Finder window 1
--> {0, 204}
position of Finder window "Desktop"
--> {0, 204}
position of window id 40509
--> {0, 204}
end tell
You can get a list of all Finder windows this way:
Finder windows
--> {Finder window id 40509 of application "Finder", Finder window id 40985 of application "Finder", Finder window id 40103 of application "Finder"}
So maybe try something similar by itself inside a Messages tell block:
text chats
This might return all of the text chats. Or maybe even this:
text chat -1
or
last text chat
Yes. Unicode has been supported since OS X began. Applescript became âentirely unicode-basedâ in AS 2.0 (OS X 10.5 Leopard).
That said, I think it might be a unicode issue, but not one thatâs specific to applescript.
The unicode for the character is:
Unicode: U+1F4B0, UTF-8: F0 9F 92 B0
So it needs 4 bytes. Not sure whether there are any font-related issues.
FWIW I get some odd behaviour. I canât paste the character anywhere. I have to go into the âshow emoji and symbolsâ tool to enter it. And textedit pops up an alert warning that it cannot auto-save the document.
Dunno whether my system will act differently after a reboot but right now itâs choking on the character.
Itâs a mystery. And yes, that does seem drastic.