2017-11-21 12 views
0

AppleScriptを作成して、特定の正規表現のパターンに一致するメッセージの会話を削除しようとしています。私が見つけた例に従おうとしましたが、もはや動作しないコード(おそらくHigh Sierraの制限)を使用しているようです。正規表現と一致するメッセージの会話を削除するAppleScript

次のコードは動作していないようです。

set chatsToKill to {} 
tell application "Messages" 
    set allChats to every chat 
    repeat with eachChat in allChats 
    -- 
    -- The example fails because ScriptEditor would error saying it could get participants of the value returned for the first (or any of eachChat). 
    -- 
    set thePeeps to participants of eachChat 
    repeat with oneParticipant in thePeeps 
     set theHandle to handle of oneParticipant 
     try 
      do shell script "echo " & quoted form of theHandle & " | egrep '^SMS;-;141'" 
      if chatsToKill does not contain eachChat's id then set end of chatsToKill to eachChat's id 
     end try 
    end repeat 
end repeat 
repeat with deathChat in chatsToKill 
    -- This should be a delete of the deathChat 
end repeat 
end tell 

答えて

0

は、おそらく、物事はそのスクリプトが書かれた以降に変更されたが、それは欠陥があると動作しません、と私はMacOSの10.11.6+のように動作させることができるかわかりません。

Appleは、メッセージアプリケーションへのスクリプトアクセスを大幅に制限しています。
set thePeeps to participants of eachChat

エラーは次のとおりです:

Messages got an error: Can’t get participants of text chat id "iMessage;-;+1123121234".

私はtry/catchブロック内のコードを入れたとしても、私はあなたのスクリプトをステップ実行すると

は、私は、この行にエラーが出ますすべてのメッセージに対して失敗しました。

でも、それでもスクリプトの残りの部分がどのように機能するのか分かりません。結果に何も割り当てないでdo shell scriptを実行します。

set scriptResults to do shell script "echo " & quoted form of theHandle & " | egrep '^SMS;-;141'" 
    -- do something with scriptResults 

    if chatsToKill does not contain eachChat's id then set end of chatsToKill to eachChat's id 

申し訳ありませんが、私はもっと良いものを提供することはできません。

あなたはこのようなものが必要。

+0

スクリプトは私のものではありません。私は別のスタック交換メッセージからコピーしましたが、明らかに2年前に働いていました。だから、シエラやシエラの時代から何かが起こっています。 –

関連する問題