Class: Switchboard::Commands::Roster::Add

Inherits:
Switchboard::Command show all
Defined in:
lib/switchboard/commands/roster/add.rb

Class Method Summary collapse

Methods inherited from Switchboard::Command

description, help, options, to_command, to_command_name

Class Method Details

.run!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/switchboard/commands/roster/add.rb', line 7

def self.run!
  switchboard = Switchboard::Client.new(Switchboard::Settings.new, false)

  switchboard.on_roster_loaded do
    # add the server as a contact if it wasn't already added
    ARGV.each do |jid|
      if roster.find(jid).empty?
        puts "Adding #{jid} to my roster..."
        roster.add(jid, nil, true)
      end
    end
  end

  switchboard.plug!(AutoAcceptJack)

  switchboard.run!
end