0

本质上,我需要使用 AppleScript 解析 CHAT CREATE 命令的响应字符串以获取聊天 ID。响应如下所示:

聊天#my.username/$123abc456blah STATUS MULTICHAT

我试过了

set chatid to item 2 of response

但这会返回“H”——我也试过了

set chatid to word 2 of response

但这会返回“我的”。我想这对于了解 AppleScript 的人来说是一个简单的问题。这是一个示例脚本...

tell application "Skype"
    set response to (send command "CHAT CREATE username1, username2" script name "MyScript")
    set chatid to ***WHAT GOES HERE?***
    send command "ALTER CHAT " & chatid & " SETTOPIC Hello" script name "MyScript"
end tell
4

2 回答 2

3

你很亲密。尝试这个:

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set chatid to text item 2 of response
set AppleScript's text item delimiters to oldDelims
于 2009-11-09T11:54:02.150 回答
0

这个给你 ID 部分(我假设是#my.username/$123abc456blah部分)

set c to "CHAT #my.username/$123abc456blah STATUS MULTICHAT"
set hm to do shell script "perl -e '\"" & c & "\"=~/\\w (.*?) \\w/;print$1' "

然而,这不是纯粹的 AppleScript,我调用 perl 来使用正则表达式来完成繁重的工作。

于 2009-11-09T12:07:06.010 回答