1

Craig Smith の次のコードを使用しています。

set chatsToKill to {}
tell application "Messages"
   set allChats to every chat
   repeat with eachChat in allChats
     set thePeeps to participants of eachChat
     repeat with oneParticipant in thePeeps
        if oneParticipant's handle contains "@" then
            if chatsToKill does not contain eachChat's id then set end of chatsToKill to eachChat's id
        end if
    end repeat
  end repeat
  repeat with deathChat in chatsToKill
        delete item 1 of (get every chat whose id = deathChat)
   end repeat
end tell

ユーザー ハンドルが 4 桁しかない送信者からの会話を消去する方法があるかどうか疑問に思っていました。

4 桁は常に異なり、同じではありません。さまざまなワイルドカード文字を試しましたが、Applescript がそれらをサポートしていないことがわかりました。

4

1 に答える 1

0

このソリューションでは、正規表現を使用します。一致するものがない場合、無視されるエラーがスローされます

set chatsToKill to {}
tell application "Messages"
    set allChats to every chat
    repeat with eachChat in allChats
        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 ^[0-9]{4}$"
                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
        delete item 1 of (get every chat whose id = deathChat)
    end repeat
end tell
于 2015-10-13T05:04:07.730 に答える