set timeoutSeconds to 8 * 3600 -- 设置超时时间为 8 小时 with timeout of timeoutSeconds seconds set filePath to (path to me as text) & "phongNumber.txt" set phongData to read file filePath as «class utf8» -- 以 UTF-8 编码方式读取文件内容 end timeout tell application "Messages" set targetMessage to "Hello, World!" -- 替换为你要发送的消息内容 repeat with targetBuddy in targetBuddies set targetAccount to 1st account whose service = (1st service whose service type = iMessage and name = targetBuddy) send_message(targetMessage, targetBuddy, targetAccount) delay 0.2 -- 设置发送间隔为 0.2 秒 end repeat end tell on send_message(message, buddy, account) tell application "Messages" send message to buddy buddy of service id of account end tell delay 0.2 -- 每0.2秒发送一条消息 end repeat
时间: 2024-01-25 21:05:13 浏览: 22
尊敬的用户,这个脚本的语法有一些问题,这可能会导致脚本无法正常运行。建议您使用以下代码:
```
set timeoutSeconds to 8 * 3600 -- 设置超时时间为 8 小时
with timeout of timeoutSeconds seconds
set filePath to (path to me as text) & "phongNumber.txt"
set phongData to read file filePath as «class utf8» -- 以 UTF-8 编码方式读取文件内容
end timeout
tell application "Messages"
set targetMessage to "Hello, World!" -- 替换为你要发送的消息内容
repeat with targetBuddy in targetBuddies
set targetAccount to 1st account whose service = (1st service whose service type = iMessage and name = targetBuddy)
send_message(targetMessage, targetBuddy, targetAccount)
delay 0.2 -- 设置发送间隔为 0.2 秒
end repeat
end tell
on send_message(message, buddy, account)
tell application "Messages"
send message to buddy buddy of service id of account
end tell
end send_message
```
请注意,`delay 0.2` 命令应该是在 `repeat` 循环内部,而不是在 `send_message` 声明后面。另外,`end repeat` 命令也缺失了。更正后的代码已经修复了这些问题。