I'm using the net-toc gem to connect to AIM with Ruby 1.8.7 since 1.9.2
doesn't seem to support net-toc. The code below works fine if I input it
line by line into IRB, but it won't create a connection and send an IM
if I run the code from a file($ ruby aim.rb). I've tried adding sleep(2)
after each connection to emulate the time it took me to write each line
in IRB, but that didn't work either. Any ideas?


#Loads net/toc, aim gem
require 'rubygems'
require 'net/toc'

#Get username, password, buddy's screenname, and message
print "username: "
username = gets
print "password: "
password = gets
print "buddy's screenname: "
screenname = gets
print "message: "
message = gets

#Define TOC Connection
client = Net::TOC.new(username, password)

#Connect
client.connect

#Grab object associated with buddy's screenname
friend = client.buddy_list.buddy_named(screenname)

#Sends the IM
friend.send_im(message)

-- 
Posted via http://www.ruby-forum.com/.