botfly 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{botfly}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Neufeld"]
@@ -1,5 +1,8 @@
1
1
  require 'rubygems'
2
2
 
3
+ require 'logger'
4
+ require 'forwardable'
5
+
3
6
  require 'xmpp4r'
4
7
  require 'xmpp4r/muc'
5
8
  require 'xmpp4r/roster'
@@ -10,8 +13,7 @@ require 'botfly/bot'
10
13
  require 'botfly/matcher'
11
14
  require 'botfly/muc_client'
12
15
 
13
- require 'logger'
14
- require 'forwardable'
16
+
15
17
 
16
18
  Thread.abort_on_exception = true
17
19
 
@@ -20,10 +22,10 @@ module Botfly
20
22
  @logger = Logger.new(@logfile)
21
23
  return @logger
22
24
  end
23
- def Botfly.login(jid,pass,logfile=STDOUT,&block)
25
+ def Botfly.login(jid,pass,opts={},logfile=STDOUT,&block)
24
26
  @logfile = logfile
25
27
  Botfly.logger.info("BOTFLY: #login")
26
- bot = Botfly::Bot.new(jid,pass)
28
+ bot = Botfly::Bot.new(jid,pass,opts)
27
29
  bot.connect # Must connect first, since MUC requires an active connection to initiate
28
30
  bot.instance_exec(&block)
29
31
  return bot # At this point doesn't get returned, as the thread is stopped
@@ -20,10 +20,11 @@ module Botfly
20
20
  Botfly.logger.info(" BOT: Connecting to #{@host || @jid}...")
21
21
  @client.connect(@host)
22
22
  @client.auth(@password)
23
+ @roster = Jabber::Roster::Helper.new(@client)
23
24
  Botfly.logger.info(" BOT: Connected")
24
25
  register_for_callbacks
25
26
  @client.send(Jabber::Presence.new.set_status("Carrier has arrived"))
26
- @roster = Jabber::Roster::Helper.new(@client)
27
+
27
28
  #Thread.stop
28
29
  end
29
30
 
@@ -43,7 +44,7 @@ module Botfly
43
44
  def register_for_callbacks
44
45
  Botfly.logger.info(" BOT: Registering for callbacks with client")
45
46
  # @client.add_update_callback {|presence| respond_to(:update, :presence => presence) }
46
- @client.add_subscription_request_callback do |item, pres| # requires Roster helper
47
+ @roster.add_subscription_request_callback do |item, pres| # requires Roster helper
47
48
  Botfly.logger.debug(" CB: Got Message")
48
49
  respond_to(:subscription_request, :roster_item => item, :presence => pres)
49
50
  end
@@ -5,7 +5,7 @@ module Botfly
5
5
  attr_accessor :responders
6
6
  attr_reader :client
7
7
 
8
- def initialize(ignored,ignore)
8
+ def initialize(jid,pass,opts={})
9
9
  @block_state = {}
10
10
  @responders = {}
11
11
  end
@@ -37,7 +37,8 @@ module Botfly
37
37
 
38
38
  def method_missing(type,&block)
39
39
  Botfly.logger.info("#{@obj.to_debug_s}: Bot#on")
40
- klass = Botfly.const_get(@obj.class_prefix + type.to_s.capitalize + "Responder")
40
+ type_name = type.to_s.split('_').map(&:capitalize).join('')
41
+ klass = Botfly.const_get(@obj.class_prefix + type_name + "Responder")
41
42
  (@obj.responders[type] ||= []) << responder = klass.new(@obj, &block)
42
43
  Botfly.logger.info("#{@obj.to_debug_s}: #{@obj.class_prefix}#{type.to_s.capitalize}Responder added to responder chain")
43
44
  return responder
@@ -1,6 +1,8 @@
1
+ # TODO: Dry this up
1
2
  require 'botfly/responder/common_responder_methods'
2
3
  require 'botfly/responder/responder'
3
4
  require 'botfly/responder/message_responder'
4
5
  require 'botfly/responder/presence_responder'
5
6
  require 'botfly/responder/muc_responder'
6
- require 'botfly/responder/muc_message_responder'
7
+ require 'botfly/responder/muc_message_responder'
8
+ require 'botfly/responder/subscription_request_responder'
@@ -13,5 +13,6 @@ module Botfly
13
13
  end
14
14
  def decline
15
15
  @bot.roster.decline_subscription(@from)
16
+ end
16
17
  end
17
18
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Neufeld