Class: Botfly::Bot
- Inherits:
-
CommonBlockAcceptor
- Object
- CommonBlockAcceptor
- Botfly::Bot
- Defined in:
- lib/botfly/bot.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#roster ⇒ Object
readonly
Returns the value of attribute roster.
Attributes inherited from CommonBlockAcceptor
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(jid, pass, opts = {}) ⇒ Bot
constructor
A new instance of Bot.
- #join(room_name, &block) ⇒ Object
- #quit ⇒ Object
- #to_debug_s ⇒ Object
Methods inherited from CommonBlockAcceptor
#[], #[]=, #class_prefix, #on, #remove_responder
Constructor Details
#initialize(jid, pass, opts = {}) ⇒ Bot
Returns a new instance of Bot.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/botfly/bot.rb', line 6 def initialize(jid,pass, opts = {}) super Botfly.logger.info(" BOT: Bot#new") @password = pass @jid = Jabber::JID.new(jid) @client = Jabber::Client.new(@jid) @main_thread = Thread.current if opts[:gtalk] @host = "talk.google.com" end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/botfly/bot.rb', line 5 def client @client end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/botfly/bot.rb', line 5 def host @host end |
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
5 6 7 |
# File 'lib/botfly/bot.rb', line 5 def jid @jid end |
#roster ⇒ Object (readonly)
Returns the value of attribute roster.
5 6 7 |
# File 'lib/botfly/bot.rb', line 5 def roster @roster end |
Instance Method Details
#connect ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/botfly/bot.rb', line 18 def connect Botfly.logger.info(" BOT: Connecting to #{@host || @jid}...") @client.connect(@host) @client.auth(@password) @roster = Jabber::Roster::Helper.new(@client) Botfly.logger.info(" BOT: Connected") register_for_callbacks self end |
#join(room_name, &block) ⇒ Object
28 29 30 |
# File 'lib/botfly/bot.rb', line 28 def join(room_name,&block) return Botfly::MUCClient.new(room_name,self,&block) end |
#quit ⇒ Object
32 33 34 35 |
# File 'lib/botfly/bot.rb', line 32 def quit @client.close @main_thread.wakeup end |
#to_debug_s ⇒ Object
37 |
# File 'lib/botfly/bot.rb', line 37 def to_debug_s; "BOT"; end |