我一直在编写脚本一段时间,并且有很多问题被问到。我还根据一些人的建议重写了很多代码。然而,我仍然有一个没有答案的问题。以下是 iMessage PA 等“Siri”的代码。基本上,当我通过 iMessage 向它发出命令时,它会响应。
我一直在拼命地尝试让它有更多的智能,让它用句子来回答。你可以在代码中看到,当它问我“......你还好吗?” 它应该寻找“是”或“否”,但仅在提出第一个问题时。然而,目前它只是以最初的“我很好,先生,你还好吗?”作为回应。然后当我告诉它是或否时什么也不做。
为了确保它不是主要代码,我添加了一个简单的“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@1.com" of service "E:email@2.com"
end tell
end helloresponse
on happyResponse()
tell application "Messages"
send "you said yes, yey!" to buddy "email@1.com" of service "E:email@2.com"
end tell
end happyResponse
on unhappyResponce()
tell application "Messages"
send "You said no, thats a shame!" to buddy "email@1.com" of service "E:email@2.com"
end tell
end unhappyResponce
on areyouok()
tell application "Messages"
send "I am fine sir, are you ok?" to buddy "email@1.com" of service "E:email@2.com"
end tell
end areyouok
on helloworldresponse()
tell application "Messages"
send "World replies: Hello." to buddy "email@1.com" of service "E:email@2.com"
end tell
end helloworldresponse
感谢人们可以给我的任何帮助!