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