我希望通过 imessage
以编程方式发送文件,但不知道如何通过 API 发送文件对象。
此脚本使用文件路径向指定用户发送消息:
imessage() {
file="$PWD/$2";
osascript -e 'tell application "Messages" to send '\"$file\"' to buddy '\"$1\"';
}
如何发送实际文件?指向文档的指针也会有所帮助。
最佳答案
看起来最简单的方法是创建一个 AppleScript 文件并通过 bash 调用它,如此处所示 https://gist.github.com/homam/0119797f5870d046a362 .
AppleScript - sendmessage.scpt
on run argv
set filename to item 1 of argv
set buddyName to item 2 of argv
set attach to POSIX file filename
tell application "Messages" to send attach to buddy buddyName
end run
bash 脚本
imessage() {
osascript sendmessage.scpt "$PWD/$2" "$1";
}
关于bash - 使用 AppleScript + bash 发送文件对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54874497/