1
我已經在Applescript編寫了我自己的Jarvis版本幾天了,我一直使用iMessages作爲我的輸入和輸出,因爲我喜歡它的便攜性,但我現在想要更高級一些,並開始製作它覺得它有用處。如何以不同的方式讓applescript控制iMessage回覆?
目前我只使用簡單的代碼行來識別我什麼時候發送了一些內容,然後運行相應的腳本來發送回復。比如,如果我說「你好」,它說「你好,先生」回到我身邊。
一個例子是:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
if theMessage is "hello" then
run script ("/Users/Alex/Desktop/JarvisScripts/hello.scpt" as POSIX file)
end if
end message received
end using terms from
都好,但是我前面說過我想走得更遠,我需要一種方式,它可以問我一個問題,如「你好嗎」,然後取決於我說的「好」,它會運行正確的腳本來回應「好」。 我現在嘗試沿着線走:
if theMessage contains "Are you ok" then
run script ("/Users/Alex/Desktop/JarvisScripts/areyouok.scpt" as POSIX file)
if theMessage is "I'm fine" then
run script ("/Users/Alex/Desktop/JarvisScripts/happy.scpt" as POSIX file)
else
if theMessage is "No I'm not" then
run script ("/Users/Alex/Desktop/JarvisScripts/unhappy.scpt" as POSIX file)
end if
end if
end if
但我知道這是遠離正確的。那麼,有人可以幫我一些代碼嗎?謝謝
我完全理解,並且我已經嘗試了您的代碼,但我剛收到一條錯誤消息,說「事件:收到消息 文件:commands.scpt 錯誤:無法將某些數據轉換爲預期類型。你能想到爲什麼? – Aloogy 2013-05-06 21:18:11
沒有完整的上下文或看到完整的腳本,我不能告訴。如果可以,請編輯您的原始問題以包含完整的代碼,或者如果代碼太長,請提供代碼鏈接。 – 2013-05-07 15:21:28