Class: JabberTee::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/jabber-tee/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jabber-tee/client.rb', line 9

def initialize(config)
  @config = config
  @client = Jabber::Client.new(Jabber::JID.new("#{config.username}/#{config.nick}"))
  client.connect
  client.auth(config.password)

  if config.in_room?
    @muc = Jabber::MUC::SimpleMUCClient.new(client)
    @muc.join(Jabber::JID.new("#{config.room}/#{config.nick}"))
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/jabber-tee/client.rb', line 7

def client
  @client
end

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/jabber-tee/client.rb', line 7

def config
  @config
end

Instance Method Details

#say(message) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/jabber-tee/client.rb', line 21

def say(message)
  message.chomp!
  if config.in_room?
    @muc.say(message)
  else
    msg = Jabber::Message.new(config.to, message)
    msg.type = :chat
    client.send(msg)
  end
end