Class: Botfly::MUCClient
- Inherits:
-
CommonBlockAcceptor
- Object
- CommonBlockAcceptor
- Botfly::MUCClient
- Defined in:
- lib/botfly/muc_client.rb
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#muc ⇒ Object
readonly
Returns the value of attribute muc.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Attributes inherited from CommonBlockAcceptor
Instance Method Summary collapse
- #as(resource, &block) ⇒ Object
- #class_prefix ⇒ Object
-
#initialize(room, bot, &block) ⇒ MUCClient
constructor
A new instance of MUCClient.
- #leave ⇒ Object
- #respond_to(callback_type, params = {}) ⇒ Object
- #room ⇒ Object
- #to_debug_s ⇒ Object
Methods inherited from CommonBlockAcceptor
#[], #[]=, #on, #remove_responder
Constructor Details
#initialize(room, bot, &block) ⇒ MUCClient
Returns a new instance of MUCClient.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/botfly/muc_client.rb', line 9 def initialize(room, bot, &block) super Botfly.logger.info("MUC: New client created") @bot = bot @client = @bot.client @room = room @domain = "conference.#{@bot.jid.domain}" # A sensible default for now @resource = @bot.jid.node execute(&block) if block_given? # i.e. join(room) do ... end return self end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
5 6 7 |
# File 'lib/botfly/muc_client.rb', line 5 def bot @bot end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
5 6 7 |
# File 'lib/botfly/muc_client.rb', line 5 def domain @domain end |
#muc ⇒ Object (readonly)
Returns the value of attribute muc.
5 6 7 |
# File 'lib/botfly/muc_client.rb', line 5 def muc @muc end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
5 6 7 |
# File 'lib/botfly/muc_client.rb', line 5 def resource @resource end |
Instance Method Details
#as(resource, &block) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/botfly/muc_client.rb', line 22 def as(resource, &block) Botfly.logger.info("MUC: as #{resource}") @resource = resource execute(&block) if block_given? return self end |
#class_prefix ⇒ Object
40 |
# File 'lib/botfly/muc_client.rb', line 40 def class_prefix; "MUC"; end |
#leave ⇒ Object
29 |
# File 'lib/botfly/muc_client.rb', line 29 def leave; @muc.exit; end |
#respond_to(callback_type, params = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/botfly/muc_client.rb', line 32 def respond_to(callback_type, params={}) if (params[:nick] != @resource ) # don't respond to self Botfly.logger.info("MUC: Responding to callback of type: #{callback_type} with time of #{params[:time]}") @responders[callback_type].each {|r| r.callback_with params} if @responders[callback_type] end end |
#room ⇒ Object
7 |
# File 'lib/botfly/muc_client.rb', line 7 def room; @block_state; end |
#to_debug_s ⇒ Object
39 |
# File 'lib/botfly/muc_client.rb', line 39 def to_debug_s; "MUC"; end |