代码之家  ›  专栏  ›  技术社区  ›  g .

如何用AppleScript分析Skype响应?

  •  0
  • g .  · 技术社区  · 15 年前

    本质上,我需要用applescript解析chat create命令的响应字符串来获取chatid。回答如下:

    chat my.username/$123abc456blah status multichat

    我试过

    set chatid to item 2 of response
    

    但返回“h”—我也尝试过

    set chatid to word 2 of response
    

    但它返回“我的”。我想这对于熟悉applesccript的人来说是一个简单的问题。这是一个脚本示例…

    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
    
    2 回复  |  直到 15 年前
        1
  •  3
  •   Gene Goykhman    15 年前

    你离得很近。试试这个:

    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
    
        2
  •  0
  •   ase    15 年前

    这个给你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使用正则表达式来完成繁重的工作。