chatterbot 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,10 @@ module Chatterbot
53
53
  has_config? && config.has_key?(:log_dest)
54
54
  end
55
55
 
56
+ def verbose?
57
+ config[:verbose] || false
58
+ end
59
+
56
60
  #
57
61
  # destination for log entries
58
62
  def log_dest
@@ -197,6 +201,7 @@ module Chatterbot
197
201
  # let's not store these, they're just command-line options
198
202
  tmp.delete(:debug_mode)
199
203
  tmp.delete(:dry_run)
204
+ tmp.delete(:verbose)
200
205
 
201
206
 
202
207
  # update the since_id now
@@ -27,8 +27,9 @@ module Chatterbot
27
27
  opts.on('-d', '--db [ARG]', "Specify a DB connection URI") { |d| ENV["chatterbot_db"] = d }
28
28
  opts.on('-c', '--config [ARG]', "Specify a config file to use") { |c| ENV["chatterbot_config"] = c }
29
29
  opts.on('-t', '--test', "Run the bot without actually sending any tweets") { params[:debug_mode] = true }
30
+ opts.on('-v', '--verbose', "verbose output to stdout") { params[:verbose] = true }
30
31
  opts.on('--dry-run', "Run the bot in test mode, and also don't update the database") { params[:debug_mode] = true ; params[:no_update] = true }
31
- opts.on('-s', '--since_id [ARG]', "Check for tweets since tweet id #[ARG]") { |s| params[:since_id] = s }
32
+ opts.on('-s', '--since_id [ARG]', "Check for tweets since tweet id #[ARG]") { |s| params[:since_id] = s.to_i }
32
33
 
33
34
  opts.on_tail("-h", "--help", "Show this message") do
34
35
  puts opts
@@ -10,6 +10,7 @@ module Chatterbot
10
10
  #
11
11
  # log a message
12
12
  def debug(s)
13
+ puts s if verbose?
13
14
  logger.debug s unless ! logging?
14
15
  end
15
16
 
@@ -9,7 +9,8 @@ module Chatterbot
9
9
  return unless require_login
10
10
  debug "check for replies since #{since_id}"
11
11
 
12
- results = client.replies(:since_id => since_id)
12
+ opts = since_id > 0 ? {:since_id => since_id} : {}
13
+ results = client.replies(opts)
13
14
 
14
15
  if results.is_a?(Hash) && results.has_key?("error")
15
16
  critical results["error"]
@@ -1,3 +1,3 @@
1
1
  module Chatterbot
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/spec/reply_spec.rb CHANGED
@@ -18,7 +18,6 @@ describe "Chatterbot::Reply" do
18
18
  # end
19
19
 
20
20
  it "iterates results" do
21
- #bot = Chatterbot::Bot.new
22
21
  bot = test_bot
23
22
  bot.should_receive(:require_login).and_return(true)
24
23
  bot.stub!(:client).and_return(fake_replies(100, 3))
@@ -35,7 +34,6 @@ describe "Chatterbot::Reply" do
35
34
 
36
35
  it "checks blacklist" do
37
36
  bot = test_bot
38
- # bot = Chatterbot::Bot.new
39
37
  bot.should_receive(:require_login).and_return(true)
40
38
  bot.stub!(:client).and_return(fake_replies(100, 3))
41
39
 
@@ -51,4 +49,29 @@ describe "Chatterbot::Reply" do
51
49
  indexes.should == [2,3]
52
50
  end
53
51
 
52
+
53
+ it "passes along since_id" do
54
+ bot = test_bot
55
+ bot.should_receive(:require_login).and_return(true)
56
+ bot.stub!(:client).and_return(fake_replies(100, 3))
57
+ bot.stub!(:since_id).and_return(123)
58
+
59
+ bot.client.should_receive(:replies).with({:since_id => 123})
60
+
61
+ bot.replies
62
+ end
63
+
64
+
65
+ it "doesn't pass along invalid since_id" do
66
+ bot = test_bot
67
+ bot.should_receive(:require_login).and_return(true)
68
+ bot.stub!(:client).and_return(fake_replies(100, 3))
69
+ bot.stub!(:since_id).and_return(0)
70
+
71
+ bot.client.should_receive(:replies).with({ })
72
+
73
+ bot.replies
74
+ end
75
+
76
+
54
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatterbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-05-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter_oauth
16
- requirement: &21124680 !ruby/object:Gem::Requirement
16
+ requirement: &11616680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21124680
24
+ version_requirements: *11616680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &21124180 !ruby/object:Gem::Requirement
27
+ requirement: &11616180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21124180
35
+ version_requirements: *11616180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &21123700 !ruby/object:Gem::Requirement
38
+ requirement: &11615700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *21123700
46
+ version_requirements: *11615700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &21123220 !ruby/object:Gem::Requirement
49
+ requirement: &11657200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *21123220
57
+ version_requirements: *11657200
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &21122740 !ruby/object:Gem::Requirement
60
+ requirement: &11656720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *21122740
68
+ version_requirements: *11656720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rcov
71
- requirement: &21122260 !ruby/object:Gem::Requirement
71
+ requirement: &11656240 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *21122260
79
+ version_requirements: *11656240
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: watchr
82
- requirement: &21121780 !ruby/object:Gem::Requirement
82
+ requirement: &11655760 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *21121780
90
+ version_requirements: *11655760
91
91
  description: A framework for writing bots that run on Twitter. Comes with a simple
92
92
  DSL for easy coding.
93
93
  email: colin@muffinlabs.com