Sha256: 24494145242c9b51a637d1c6641d18d02aa29de6f0ea2c4c1f4c565b8eb260c2

Contents?: true

Size: 807 Bytes

Versions: 4

Compression:

Stored size: 807 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift '../../../../../lib'
require 'xmpp4r'


# Argument checking
if ARGV.size < 2
  puts("Usage: #{$0} <desired jid> <password> [field1=value1] [fieldN=valueN]")
  exit
end


# The usual procedure
cl = Jabber::Client.new(Jabber::JID.new(ARGV[0]))
puts "Connecting"
cl.connect

# Registration of the new user account
puts "Registering..."
begin
  fields = {}
  ARGV[2..-1].each { |a|
    k, v = a.split('=', 2)
    fields[k] = v
  }
  cl.register(ARGV[1], fields)
  puts "Successful"
rescue Jabber::ServerError => e
  puts "Error: #{e.error.text}"
  if e.error.type == :modify
    puts "Accepted registration information:"
    instructions, fields = cl.register_info
    fields.each { |info|
      puts "* #{info}"
    }
    puts "(#{instructions})"
  end
end

# Shutdown
cl.close

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gmcmillan-xmpp4r-0.6.2 data/doc/xmpp4r/examples/basic/register.rb
gmcmillan-xmpp4r-0.6.1 data/doc/xmpp4r/examples/basic/register.rb
gmcmillan-xmpp4r-0.6 data/doc/xmpp4r/examples/basic/register.rb
gmcmillan-xmpp4r-0.5 data/doc/xmpp4r/examples/basic/register.rb