Skip to content

Instantly share code, notes, and snippets.

@bmnick
Created May 2, 2011 02:17
Show Gist options
  • Save bmnick/951103 to your computer and use it in GitHub Desktop.
Save bmnick/951103 to your computer and use it in GitHub Desktop.
That's what she said autoresponder for iChat
#!/usr/bin/env ruby
require 'rubygems'
require 'twss'
# Read in from command line arguments
input_value = ARGV.shift
# make it more common
TWSS.threshold = 3.0
# Provide output that should be easy for applescript to parse
if TWSS(input_value)
puts "yes"
else
puts "no"
end
using terms from application "iChat"
# Register event handler
on message received theMessage from theBuddy for theChat
# Hand the input to the shell script
set x to do shell script "/Users/ben/.rvm/bin/ruby-1.9.2-p180 /Users/ben/Applications/twss.rb \"" & theMessage & "\""
if x is equal to "yes" then
# send the message back
tell application "iChat"
send "That's what she said!" to theBuddy
end tell
end if
end message received
end using terms from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment