chatterbot 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -109,7 +109,6 @@ Note that the string #USER# will be replaced with the username of the person who
109
109
  end
110
110
  ```
111
111
 
112
-
113
112
  **blacklist** -- you can use this to specify a list of users you don't
114
113
  want to interact with. If you put the following line at the top of
115
114
  your bot:
@@ -134,6 +133,18 @@ precaution if you want to avoid spreading spam), you could call:
134
133
 
135
134
  For more details, check out dsl.rb in the source code.
136
135
 
136
+ Direct Client Access
137
+ --------------------
138
+
139
+ If you want to do something not provided by the DSL, you have access
140
+ to an instance of Twitter::Client provided by the **client** method.
141
+ In theory, you can do something like this in your bot to unfollow
142
+ users who DM you:
143
+
144
+ client.direct_messages_received(:since_id => since_id).each do |m|
145
+ client.unfollow(m.user.name)
146
+ end
147
+
137
148
 
138
149
  Authorization
139
150
  -------------
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Chatterbot
2
4
 
3
5
  #
@@ -130,10 +132,10 @@ module Chatterbot
130
132
  #
131
133
  # query twitter for the bots screen name. we do this during the bot registration process
132
134
  #
133
- def get_screen_name
135
+ def get_screen_name(t = @access_token)
134
136
  return unless @screen_name.nil?
135
137
 
136
- oauth_response = @access_token.get('/1/account/verify_credentials.json')
138
+ oauth_response = t.get('/1/account/verify_credentials.json')
137
139
  @screen_name = JSON.parse(oauth_response.body)["screen_name"]
138
140
  end
139
141
 
@@ -1,3 +1,3 @@
1
1
  module Chatterbot
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -87,4 +87,22 @@ describe "Chatterbot::Client" do
87
87
  @bot.login
88
88
  end
89
89
  end
90
+
91
+ describe "get_screen_name" do
92
+ before(:each) do
93
+ @json = '{"id":12345,"screen_name":"mockbot"}'
94
+
95
+ @token = mock(Object)
96
+ response = mock(Object, :body => @json)
97
+ @token.should_receive(:get).with("/1/account/verify_credentials.json").and_return(response)
98
+ end
99
+
100
+ it "should work" do
101
+ @bot.get_screen_name(@token)
102
+ @bot.screen_name.should == "mockbot"
103
+ end
104
+ end
105
+
106
+
107
+
90
108
  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.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
@@ -257,7 +257,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  segments:
259
259
  - 0
260
- hash: -440543130411025093
260
+ hash: 3131576310873480670
261
261
  required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  none: false
263
263
  requirements:
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  version: '0'
267
267
  segments:
268
268
  - 0
269
- hash: -440543130411025093
269
+ hash: 3131576310873480670
270
270
  requirements: []
271
271
  rubyforge_project: chatterbot
272
272
  rubygems_version: 1.8.24