Sha256: 3ad4c4fb270a6402ae818d2b4d7efb9d825c511a79ae0fea4298eb6966fbd670

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

#!/usr/bin/env ruby

require 'xmpp4r'
require 'xmpp4r/muc/helper/mucbrowser'

if ARGV.size != 3
  puts "Usage: #{$0} <jid> <password> <muc-jid>"
  exit
end

jid, password, muc_jid = Jabber::JID.new(ARGV.shift), ARGV.shift, Jabber::JID.new(ARGV.shift)

cl = Jabber::Client.new(jid)
cl.connect
cl.auth(password)

browser = Jabber::MUC::MUCBrowser.new(cl)

print "Querying #{muc_jid} for identity..."; $stdout.flush
name = browser.muc_name(muc_jid)

if name.nil?
  puts " Sorry, but the queried MUC component doesn't seem to support MUC or Groupchat."
else
  puts " #{name}"

  print "Querying #{muc_jid} for its rooms..."; $stdout.flush
  rooms = browser.muc_rooms(muc_jid)
  puts " #{rooms.size} rooms found"

  max_room_length = 0
  rooms.each_key { |jid| max_room_length = jid.to_s.size if jid.to_s.size > max_room_length }

  rooms.each { |jid,name|
    puts "#{jid.to_s.ljust(max_room_length)} #{name}"
  }
end

cl.close

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bryanl-xmpp4r-0.3.2 data/doc/xmpp4r/examples/basic/mucinfo.rb
heipei-xmpp4r-0.3.2 data/doc/xmpp4r/examples/basic/mucinfo.rb