From Mexico.purplecow.org

(Difference between revisions)
Jump to: navigation, search

Current revision

This jabber send script is pure cargo-cult mess, but it works most of the time. The sleep is there because sometimes ruby will "run off the end" and die before delivering the messages without it. Ruby, huh?

#!/opt/coolstack/bin/ruby
require 'rubygems'
require 'xmpp4r-simple'
require 'optparse'
require 'ostruct'


taddr = nil
tmsg = nil

opts = OptionParser.new do |opts|
        opts.on("-a [ADDR]") do 
                |a|
                taddr = a
        end
        opts.on("-m [MSG]") do
                |m|
                tmsg = m
        end
end

opts.parse!(ARGV)

silly = Jabber::Simple.new('jid@domain', 'password')

silly.status(nil, 'On the job')

silly.deliver(taddr,tmsg)



sleep 2
silly.disconnect