Comment

Comment by sgt

I've installed an AppleScript handler from within Messages.app. The script below is called ReceiveMessage.script and is located in ~/Library/Application Scripts/com.apple.iChat and basically accepts messages. That's how I handle inbound messages, and for outbound I basically also have a separate script for sending out messages. I do the actual work in separate python scripts called by the shell scripts though.

-- snip snip --

using terms from application "Messages" on message received theText from theBuddy for theChat set quoted_message to quoted form of theText set quoted_id to quoted form of (id of theBuddy as text) do shell script "echo " & quoted_message & " | ~/bin/MessageReceive.sh " & quoted_id & " > /dev/null 2>&1 &"

        # make messages happy
        return true
    end message received

    on message sent theMessage for theChat

    end message sent

    on active chat message received

    end active chat message received

    on chat room message received theMessage from theBuddy for theChat

    end chat room message received

    on addressed chat room message received theMessage from theBuddy for theChat

    end addressed chat room message received

    on addressed message received theMessage from theBuddy for theChat

    end addressed message received

    on av chat started

    end av chat started

    on av chat ended

    end av chat ended

    on login finished for theService

    end login finished

    on logout finished for theService

    end logout finished

    on buddy became available theBuddy

    end buddy became available

    on buddy became unavailable theBuddy

    end buddy became unavailable

    on completed file transfer

    end completed file transfer
end using terms from
parent sgt 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton