我一直在研究腳本一段時間,並且提出了很多問題。根據一些人的建議我也重寫了很多代碼。然而,我仍然有這個問題沒有答案。以下是iMessage PA的「Siri」代碼。基本上,當我通過iMessage向它發送命令時,它會響應。Applescript:未知的錯誤
我一直在拼命地讓它有更多的智慧,讓它在句子中回覆。你可以在代碼中看到,當它問我「......你還好嗎?」它應該尋找「是」或「否」,但只有當第一個問題被問到。但目前它只是響應最初的「我很好,先生,你還好嗎?」然後當我說出是或否時,什麼都不做。
只是爲了確保它不是主代碼,我添加了一個簡單的「hello world」來查看它是否會正常響應。以下是代碼:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
if theMessage is "hello" then
helloresponse()
end if
if theMessage contains "Are you ok" then
areyouok()
if theMessage is "yes" then
happyResponse()
else
if theMessage is "no" then
unhappyResponse()
end if
end if
end if
if theMessage contains "hello world" then
helloworldresponse()
end if
end message received
end using terms from
on helloresponse()
tell application "Messages"
send "Hey sir!" to buddy "[email protected]" of service "E:[email protected]"
end tell
end helloresponse
on happyResponse()
tell application "Messages"
send "you said yes, yey!" to buddy "[email protected]" of service "E:[email protected]"
end tell
end happyResponse
on unhappyResponce()
tell application "Messages"
send "You said no, thats a shame!" to buddy "[email protected]" of service "E:[email protected]"
end tell
end unhappyResponce
on areyouok()
tell application "Messages"
send "I am fine sir, are you ok?" to buddy "[email protected]" of service "E:[email protected]"
end tell
end areyouok
on helloworldresponse()
tell application "Messages"
send "World replies: Hello." to buddy "[email protected]" of service "E:[email protected]"
end tell
end helloworldresponse
感謝任何幫助的人可以給我!
我已經更新我的答案給你如何Ÿ一個想法響應你可以測試你的邏輯,也可以看到獲得你想要的答案的方法 – markhunte 2013-05-07 23:39:46