if is_i response puts "Sending \'#{str}\' to chat number #{response}" `osascript -e 'tell application "Messages" to send \"#{str}\" to item #{response.to_i} of text chats'` else puts "Sending \'#{str}\' to buddy \'#{response}\'" `osascript -e 'tell application "Messages" to send \"#{str}\" to buddy \"#{response}\"'` end
Though I must say I kinda like the way they've done it in OS X 10.9, where I can respond inline even when I'm on another desktop.
The best thing about this is probably that you can send messages when you're logged in to your OSX box remotely. Though for that to be handy it misses a real "chat" feature, in which the app can also playback the messages you've received.