Search code examples
applescriptadium

Receive Adium messages in Applescript


I'm trying to write a simple chat bot for Adium, that will post "lol" and "haha" and answer basic questions in annoying group chats that some people keep adding me to.

I've covered the "lol" part with a few simple send and delay commands in a repeat, but I need to do some interaction as well.
Answer "yes" to anything with a question mark for example...

Believe me or not, such a simple bot would pass a Turing Test for those conversations.

Opening the Adium dictionary does not reveal any obvious way of getting messages, nor does the Growl dictionary.

I did found out that I can run a script every time a message is received, Is there a way to get access to the sent message?

Adium pref http://media.ruk.ca/images/adiumpreferences.png

My code:

tell application "Adium"
    activate
    set theChat to the active chat
    send theChat message "Hi"
    delay 5
    send theChat message "How's life?"
    delay 10
    repeat 10 times
        send theChat message "Realy?"
        delay 5
        send theChat message "Lol :P"
        delay 15
        send theChat message "Haha XD"
        delay 15
        send theChat message "Yes1!!1"
        delay 20
        send theChat message "I like it! :D"
        delay 10
    end repeat
    send theChat message "Bye!"
    tell theChat to close
end tell

Solution

  • You can pipe to a script using Pipe Event as well now.