Sha256: 2d9620e5b707e6f6e6013f2256ca356b14cfd05ef8db533ee3f36cc183383e39
Contents?: true
Size: 1000 Bytes
Versions: 4
Compression:
Stored size: 1000 Bytes
Contents
#!/usr/bin/env ruby # This script will send a jabber message to the specified JID. The subject can be # specified using the '-s' option, and the message will be taken from stdin. $:.unshift '../../../../../lib' require 'optparse' require 'xmpp4r' include Jabber # settings myJID = JID.new('bot@localhost/Bot') myPassword = 'bot' to = nil subject = '' OptionParser.new do |opts| opts.banner = 'Usage: jabbersend.rb -s \'subject\' -t dest@domain' opts.separator '' opts.on('-s', '--subject SUBJECT', 'sets the message\'s subject') { |s| subject = s } opts.on('-t', '--to DESTJID', 'sets the receiver') { |t| to = JID.new(t) } opts.on_tail('-h', '--help', 'Show this message') { puts opts exit } opts.parse!(ARGV) end if to.nil? puts "No receiver specified. See jabbersend -h" end cl = Client.new(myJID) cl.connect cl.auth(myPassword) body = STDIN.readlines.join m = Message.new(to, body).set_type(:normal).set_id('1').set_subject(subject) puts m.to_s cl.send(m) cl.close
Version data entries
4 entries across 4 versions & 1 rubygems