chatterbot 2.0.0.pre → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.markdown +20 -14
- data/bin/chatterbot-register +6 -2
- data/chatterbot.gemspec +3 -3
- data/lib/chatterbot/bot.rb +7 -3
- data/lib/chatterbot/client.rb +4 -3
- data/lib/chatterbot/config.rb +1 -0
- data/lib/chatterbot/config_manager.rb +7 -1
- data/lib/chatterbot/home_timeline.rb +0 -1
- data/lib/chatterbot/skeleton.rb +1 -1
- data/lib/chatterbot/streaming.rb +2 -0
- data/lib/chatterbot/tweet.rb +2 -1
- data/lib/chatterbot/ui.rb +88 -19
- data/lib/chatterbot/version.rb +1 -1
- data/spec/bot_spec.rb +4 -4
- data/spec/client_spec.rb +2 -3
- data/spec/streaming_spec.rb +2 -0
- data/spec/tweet_spec.rb +3 -6
- data/templates/skeleton.txt +28 -11
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd3b277547610b8d5e0ec0993a5952d015cab80b
|
4
|
+
data.tar.gz: 114e6d11f506a6bbb331081b66395613346e3a12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92c72bf9e9ab384e2a5a00756d78af0128998efd1dd7d1eba9ac069b8fe427042e5ea73aeed03e2ae9dd30a140833382f9e239090b6c835794fe9207073e6d98
|
7
|
+
data.tar.gz: 3d6c202746806977bd602b9ad2f196cec49ef4dd091582ce38711906b1e7ddb9fd93be34b517b6aadeb7492e024e07784c12c4002d74e0220247bd623616fea6
|
data/.travis.yml
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Chatterbot
|
2
2
|
===========
|
3
3
|
|
4
|
+
Hey! This is Chatterbot 2.0. There have been some breaking changes
|
5
|
+
from older versions of the library, and it doesn't support MySQL
|
6
|
+
anymore. If you are looking for the old version,
|
7
|
+
you can try the [1.0 branch](https://github.com/muffinista/chatterbot/tree/1.0.2)
|
8
|
+
|
4
9
|
Chatterbot is a Ruby library for making bots on Twitter. It's
|
5
10
|
great for rapid development of bot ideas. It handles all of the basic
|
6
11
|
Twitter API features -- searches, replies, tweets, retweets, etc. and has
|
@@ -51,7 +56,7 @@ A bot using chatterbot can be as simple as this:
|
|
51
56
|
|
52
57
|
```
|
53
58
|
exclude "http://"
|
54
|
-
|
59
|
+
blocklist "mean_user, private_user"
|
55
60
|
|
56
61
|
puts "checking my timeline"
|
57
62
|
home_timeline do |tweet|
|
@@ -71,14 +76,15 @@ end
|
|
71
76
|
```
|
72
77
|
|
73
78
|
Or you can write a bot using more traditional ruby classes, extend it if needed, and use it like so:
|
74
|
-
|
75
|
-
|
79
|
+
```
|
80
|
+
class MyBot < Chatterbot::Bot
|
76
81
|
def do_stuff
|
77
82
|
search("'surely you must be joking'") do |tweet|
|
78
83
|
reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet
|
79
84
|
end
|
80
85
|
end
|
81
86
|
end
|
87
|
+
```
|
82
88
|
|
83
89
|
Chatterbot can actually generate a template bot file for you, and will
|
84
90
|
walk you through process of getting a bot authorized with Twitter.
|
@@ -101,7 +107,7 @@ to do something complicated, you should probably consider using the
|
|
101
107
|
|
102
108
|
Basic usage is very straightforward:
|
103
109
|
|
104
|
-
|
110
|
+
use_streaming true
|
105
111
|
home_timeline do |tweet|
|
106
112
|
puts "someone i follow tweeted! #{tweet.text}"
|
107
113
|
end
|
@@ -109,7 +115,7 @@ Basic usage is very straightforward:
|
|
109
115
|
|
110
116
|
You can also run a search:
|
111
117
|
|
112
|
-
|
118
|
+
use_streaming true
|
113
119
|
search("pizza") do |tweet|
|
114
120
|
puts "someone is talking about pizza! #{tweet.text}"
|
115
121
|
end
|
@@ -167,7 +173,7 @@ person who sent the original tweet.
|
|
167
173
|
|
168
174
|
```rb
|
169
175
|
search "xyzzy" do |tweet|
|
170
|
-
retweet(tweet
|
176
|
+
retweet(tweet.id)
|
171
177
|
end
|
172
178
|
```
|
173
179
|
|
@@ -177,11 +183,11 @@ person who sent the original tweet.
|
|
177
183
|
|
178
184
|
(NOTE: you'll need to make sure your bot has permission to send DMs)
|
179
185
|
|
180
|
-
**
|
186
|
+
**blocklist** -- you can use this to specify a list of users you don't
|
181
187
|
want to interact with. If you put the following line at the top of
|
182
188
|
your bot:
|
183
189
|
|
184
|
-
|
190
|
+
blocklist "user1, user2, user3"
|
185
191
|
|
186
192
|
None of those users will trigger your bot if they come up in a
|
187
193
|
search. However, if a user replies to one of your tweets or mentions
|
@@ -307,7 +313,7 @@ loop do
|
|
307
313
|
search "twitter" do |tweet|
|
308
314
|
# here you could do something with a tweet
|
309
315
|
# if you want to retweet
|
310
|
-
retweet(tweet
|
316
|
+
retweet(tweet.id)
|
311
317
|
end
|
312
318
|
|
313
319
|
replies do |tweet|
|
@@ -319,16 +325,16 @@ end
|
|
319
325
|
```
|
320
326
|
|
321
327
|
|
322
|
-
|
328
|
+
Blocklists
|
323
329
|
----------
|
324
330
|
|
325
331
|
Not everyone wants to hear from your bot. To keep annoyances to a
|
326
|
-
minimum, Chatterbot has a simple
|
332
|
+
minimum, Chatterbot has a simple blocklist tool. Using it is as simple as:
|
327
333
|
|
328
|
-
|
334
|
+
blocklist "mean_user, private_user"
|
329
335
|
|
330
336
|
You should really respect the wishes of users who don't want to hear
|
331
|
-
from your bot, and add them to your
|
337
|
+
from your bot, and add them to your blocklist whenever requested.
|
332
338
|
|
333
339
|
There's also an 'exclude' method which can be used to add
|
334
340
|
words/phrases you might want to ignore -- for example, if you wanted
|
@@ -348,7 +354,7 @@ I can work with you on that.
|
|
348
354
|
Copyright/License
|
349
355
|
-----------------
|
350
356
|
|
351
|
-
Copyright (c)
|
357
|
+
Copyright (c) 2016 Colin Mitchell. Chatterbot is distributed under the
|
352
358
|
MIT licence -- Please see LICENSE.txt for further details.
|
353
359
|
|
354
360
|
http://muffinlabs.com
|
data/bin/chatterbot-register
CHANGED
@@ -58,6 +58,7 @@ end
|
|
58
58
|
@bot.config.delete(:token)
|
59
59
|
@bot.require_login(false)
|
60
60
|
|
61
|
+
|
61
62
|
unless @bot.screen_name.nil?
|
62
63
|
if @botname == "tmp_bot_name"
|
63
64
|
puts "change botname to #{@bot.screen_name}"
|
@@ -66,8 +67,11 @@ unless @bot.screen_name.nil?
|
|
66
67
|
|
67
68
|
puts "Storing config info"
|
68
69
|
puts @bot.config.inspect
|
69
|
-
|
70
|
-
|
70
|
+
|
71
|
+
config_src = File.join(Dir.getwd, "tmp_bot_name.yml")
|
72
|
+
config_dest = File.join(Dir.getwd, "#{@bot.botname}.yml")
|
73
|
+
File.rename(config_src, config_dest)
|
74
|
+
|
71
75
|
|
72
76
|
if @skeleton
|
73
77
|
skel_dest = File.join(Dir.getwd, "#{@bot.botname}.rb")
|
data/chatterbot.gemspec
CHANGED
@@ -21,13 +21,13 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.licenses = ["MIT"]
|
22
22
|
|
23
23
|
s.add_development_dependency(%q<redcarpet>, [">= 0"])
|
24
|
-
s.add_runtime_dependency(%q<oauth>, ["
|
25
|
-
s.add_runtime_dependency(%q<twitter>, ["5.
|
24
|
+
s.add_runtime_dependency(%q<oauth>, ["~> 0.4.7"])
|
25
|
+
s.add_runtime_dependency(%q<twitter>, ["~> 5.16.0"])
|
26
26
|
s.add_runtime_dependency(%q<launchy>, [">= 2.4.2"])
|
27
27
|
s.add_runtime_dependency(%q<colorize>, [">= 0.7.3"])
|
28
28
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
29
29
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
30
|
-
s.add_development_dependency(%q<rake>, ["
|
30
|
+
s.add_development_dependency(%q<rake>, ["< 11"])
|
31
31
|
s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
|
32
32
|
s.add_development_dependency(%q<rspec-mocks>, ["~> 3.0.2"])
|
33
33
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
data/lib/chatterbot/bot.rb
CHANGED
@@ -80,8 +80,11 @@ module Chatterbot
|
|
80
80
|
args = streamify_search_options(@handlers[:search].opts)
|
81
81
|
else
|
82
82
|
method = :user
|
83
|
-
args =
|
83
|
+
args = {
|
84
|
+
stall_warnings: "true"
|
85
|
+
}
|
84
86
|
end
|
87
|
+
|
85
88
|
|
86
89
|
streaming_client.send(method, args) do |object|
|
87
90
|
handle_streaming_object(object)
|
@@ -131,7 +134,7 @@ module Chatterbot
|
|
131
134
|
end
|
132
135
|
|
133
136
|
def call_api_immediately?
|
134
|
-
streaming?
|
137
|
+
!streaming?
|
135
138
|
end
|
136
139
|
|
137
140
|
def register_handler(method, opts = nil, &block)
|
@@ -142,8 +145,9 @@ module Chatterbot
|
|
142
145
|
puts "Forcing usage of Streaming API to support #{method} calls"
|
143
146
|
self.streaming = true
|
144
147
|
elsif call_api_immediately?
|
148
|
+
@run_count += 1
|
145
149
|
h = @handlers[method]
|
146
|
-
send(method, *(h.opts)) do |obj|
|
150
|
+
self.send(method, *(h.opts)) do |obj|
|
147
151
|
h.call(obj)
|
148
152
|
end
|
149
153
|
end
|
data/lib/chatterbot/client.rb
CHANGED
@@ -171,6 +171,7 @@ module Chatterbot
|
|
171
171
|
#
|
172
172
|
def get_screen_name(t = @access_token)
|
173
173
|
return unless @screen_name.nil?
|
174
|
+
return if t.nil?
|
174
175
|
|
175
176
|
oauth_response = t.get('/1.1/account/verify_credentials.json')
|
176
177
|
@screen_name = JSON.parse(oauth_response.body)["screen_name"]
|
@@ -198,10 +199,10 @@ module Chatterbot
|
|
198
199
|
@access_token = request_token.get_access_token(:oauth_verifier => pin.chomp)
|
199
200
|
get_screen_name
|
200
201
|
|
201
|
-
self.config[:
|
202
|
-
self.config[:
|
202
|
+
self.config[:access_token] = @access_token.token
|
203
|
+
self.config[:access_token_secret] = @access_token.secret
|
203
204
|
|
204
|
-
update_config unless ! do_update_config
|
205
|
+
#update_config unless ! do_update_config
|
205
206
|
reset_client
|
206
207
|
|
207
208
|
rescue OAuth::Unauthorized => e
|
data/lib/chatterbot/config.rb
CHANGED
@@ -27,6 +27,12 @@ module Chatterbot
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def to_h
|
31
|
+
@store.transaction do
|
32
|
+
Hash[@store.roots.map { |k| [k, @store[k]] }]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
# set/update a key
|
31
37
|
def []=(key, value)
|
32
38
|
return if @no_update == true
|
@@ -37,7 +43,7 @@ module Chatterbot
|
|
37
43
|
|
38
44
|
# retrieve a key
|
39
45
|
def [](key)
|
40
|
-
if READ_ONLY_VARIABLES.include?(key)
|
46
|
+
if READ_ONLY_VARIABLES.include?(key) && @read_only[key]
|
41
47
|
return @read_only[key]
|
42
48
|
end
|
43
49
|
@store.transaction do
|
data/lib/chatterbot/skeleton.rb
CHANGED
data/lib/chatterbot/streaming.rb
CHANGED
data/lib/chatterbot/tweet.rb
CHANGED
data/lib/chatterbot/ui.rb
CHANGED
@@ -5,7 +5,7 @@ module Chatterbot
|
|
5
5
|
#
|
6
6
|
module UI
|
7
7
|
# Where to send users who need to get API keys
|
8
|
-
API_SIGNUP_URL = "https://twitter.com/
|
8
|
+
API_SIGNUP_URL = "https://apps.twitter.com/app/new"
|
9
9
|
|
10
10
|
|
11
11
|
#:nocov:
|
@@ -52,27 +52,35 @@ module Chatterbot
|
|
52
52
|
# sleep here so that if launchy has any output (which it does
|
53
53
|
# sometimes), it doesn't interfere with our input prompt
|
54
54
|
|
55
|
-
sleep(
|
55
|
+
sleep(2)
|
56
56
|
|
57
57
|
puts "Paste your PIN and hit enter when you have completed authorization.\n\n"
|
58
58
|
print "> "
|
59
59
|
|
60
|
-
STDIN.readline.chomp
|
60
|
+
STDIN.readline.chomp.strip
|
61
61
|
rescue Interrupt => e
|
62
62
|
exit
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
green "****************************************"
|
69
|
-
green "****************************************"
|
70
|
-
green "**** API SETUP TIME! ****"
|
71
|
-
green "****************************************"
|
72
|
-
green "****************************************"
|
65
|
+
def ask_yes_no(q)
|
66
|
+
prompt = "> "
|
67
|
+
response = ""
|
73
68
|
|
69
|
+
|
70
|
+
while ! ["y", "n"].include?(response)
|
71
|
+
puts "#{q} [Y/N]"
|
72
|
+
print prompt
|
73
|
+
response = $stdin.gets.chomp.downcase[0]
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
+
if response == "y"
|
77
|
+
true
|
78
|
+
else
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def send_to_app_creation
|
76
84
|
puts "Please hit enter, and I will send you to #{API_SIGNUP_URL} to start the process."
|
77
85
|
puts "(If it doesn't work, you can open a browser and paste the URL in manually)"
|
78
86
|
|
@@ -81,21 +89,82 @@ module Chatterbot
|
|
81
89
|
STDIN.readline
|
82
90
|
|
83
91
|
Launchy.open(API_SIGNUP_URL)
|
92
|
+
|
84
93
|
# pause to allow any launchy output
|
85
|
-
sleep(
|
94
|
+
sleep(2)
|
86
95
|
|
87
96
|
puts "\n\n"
|
97
|
+
|
98
|
+
|
99
|
+
puts "Once you've filled out the app form, click on the 'Keys and Access Tokens' link"
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Ask the user to get an API key from Twitter.
|
104
|
+
def get_api_key
|
88
105
|
|
89
|
-
|
106
|
+
green "****************************************"
|
107
|
+
green "****************************************"
|
108
|
+
green "**** API SETUP TIME! ****"
|
109
|
+
green "****************************************"
|
110
|
+
green "****************************************"
|
111
|
+
|
112
|
+
|
113
|
+
puts "\n\nWelcome to Chatterbot. Let's walk through the steps to get a bot running.\n\n"
|
114
|
+
|
115
|
+
|
116
|
+
#
|
117
|
+
# At this point, we don't have any API credentials at all for
|
118
|
+
# this bot, but it's possible the user has already setup an app.
|
119
|
+
# Let's ask!
|
120
|
+
#
|
121
|
+
|
122
|
+
puts "Hey, looks like you need to get an API key from Twitter before you can get started.\n\n"
|
123
|
+
|
124
|
+
app_already_exists = ask_yes_no("Have you already set up an app with Twitter?")
|
125
|
+
|
126
|
+
if app_already_exists
|
127
|
+
puts "Terrific! Let's get your bot running!\n\n"
|
128
|
+
else
|
129
|
+
puts "OK, I can help with that!\n\n"
|
130
|
+
send_to_app_creation
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
print "\n\nPaste the 'Consumer Key' here: "
|
90
135
|
STDOUT.flush
|
91
|
-
config[:consumer_key] = STDIN.readline.chomp
|
136
|
+
config[:consumer_key] = STDIN.readline.chomp.strip
|
92
137
|
|
93
|
-
print "Paste the '
|
138
|
+
print "Paste the 'Consumer Secret' here: "
|
94
139
|
STDOUT.flush
|
95
|
-
config[:consumer_secret] = STDIN.readline.chomp
|
140
|
+
config[:consumer_secret] = STDIN.readline.chomp.strip
|
141
|
+
|
142
|
+
|
143
|
+
puts "\n\nNow it's time to authorize your bot!\n\n"
|
144
|
+
|
145
|
+
if ! app_already_exists && ask_yes_no("Do you want to authorize a bot using the account that created the app?")
|
146
|
+
puts "OK, on the app page, you can click the 'Create my access token' button to proceed.\n\n"
|
147
|
+
|
148
|
+
print "Paste the 'Access Token' here: "
|
149
|
+
STDOUT.flush
|
150
|
+
config[:access_token] = STDIN.readline.chomp.strip
|
151
|
+
|
96
152
|
|
97
|
-
|
98
|
-
|
153
|
+
print "\n\nPaste the 'Access Token Secret' here: "
|
154
|
+
STDOUT.flush
|
155
|
+
config[:access_token_secret] = STDIN.readline.chomp.strip
|
156
|
+
|
157
|
+
|
158
|
+
# reset the client so we can re-init with new OAuth credentials
|
159
|
+
reset_client
|
160
|
+
|
161
|
+
# at this point we should have a fully validated client, so grab
|
162
|
+
# the screen name
|
163
|
+
@screen_name = client.user.screen_name rescue nil
|
164
|
+
else
|
165
|
+
reset_client
|
166
|
+
end
|
167
|
+
|
99
168
|
|
100
169
|
#
|
101
170
|
# capture ctrl-c and exit without a stack trace
|
data/lib/chatterbot/version.rb
CHANGED
data/spec/bot_spec.rb
CHANGED
@@ -14,10 +14,10 @@ describe "Chatterbot::Bot" do
|
|
14
14
|
|
15
15
|
describe "REST API" do
|
16
16
|
it "should work" do
|
17
|
-
|
18
|
-
|
17
|
+
allow(@bot).to receive(:require_login).and_return(false)
|
18
|
+
allow(@bot).to receive(:client).and_return(fake_home_timeline(3))
|
19
19
|
@bot.register_handler(:home_timeline) {}
|
20
|
-
|
20
|
+
#@bot.run!
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -44,6 +44,7 @@ describe "Chatterbot::Bot" do
|
|
44
44
|
|
45
45
|
describe "stream!" do
|
46
46
|
before(:each) do
|
47
|
+
@bot.streaming = true
|
47
48
|
@sc = double(Twitter::Client)
|
48
49
|
expect(@bot).to receive(:streaming_client).and_return(@sc)
|
49
50
|
end
|
@@ -51,7 +52,6 @@ describe "Chatterbot::Bot" do
|
|
51
52
|
it "tweaks settings for searches" do
|
52
53
|
@bot.register_handler(:search, "hello") {}
|
53
54
|
expect(@sc).to receive(:filter)
|
54
|
-
|
55
55
|
@bot.stream!
|
56
56
|
end
|
57
57
|
|
data/spec/client_spec.rb
CHANGED
@@ -139,12 +139,11 @@ describe "Chatterbot::Client" do
|
|
139
139
|
and_return(double(:token => "access_token", :secret => "access_secret"))
|
140
140
|
|
141
141
|
expect(@bot).to receive(:get_screen_name)
|
142
|
-
expect(@bot).to receive(:update_config)
|
143
142
|
|
144
143
|
@bot.login
|
145
144
|
|
146
|
-
expect(@bot.config[:
|
147
|
-
expect(@bot.config[:
|
145
|
+
expect(@bot.config[:access_token]).to eq("access_token")
|
146
|
+
expect(@bot.config[:access_token_secret]).to eq("access_secret")
|
148
147
|
end
|
149
148
|
|
150
149
|
it "handles errors" do
|
data/spec/streaming_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe "Chatterbot::Streaming" do
|
|
9
9
|
describe "streaming_tweet_handler" do
|
10
10
|
before(:each) do
|
11
11
|
bot.skip_run = true
|
12
|
+
bot.streaming = true
|
12
13
|
allow(bot.client).to receive(:user).and_return(user)
|
13
14
|
end
|
14
15
|
|
@@ -31,6 +32,7 @@ describe "Chatterbot::Streaming" do
|
|
31
32
|
describe "handle_streaming_object" do
|
32
33
|
before(:each) {
|
33
34
|
bot.skip_run = true
|
35
|
+
bot.streaming = true
|
34
36
|
allow(bot.client).to receive(:user).and_return(user)
|
35
37
|
}
|
36
38
|
|
data/spec/tweet_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe "Chatterbot::Tweet" do
|
|
41
41
|
it "calls require_login when replying" do
|
42
42
|
bot = test_bot
|
43
43
|
expect(bot).to receive(:require_login).and_return(false)
|
44
|
-
bot.reply "reply test!",
|
44
|
+
bot.reply "reply test!", fake_tweet(100)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "calls client.update with the right values" do
|
@@ -53,11 +53,8 @@ describe "Chatterbot::Tweet" do
|
|
53
53
|
|
54
54
|
test_str = "test!"
|
55
55
|
|
56
|
-
s = {
|
57
|
-
:id => 100
|
58
|
-
}
|
59
56
|
expect(bot.client).to receive(:update).with(test_str, {:in_reply_to_status_id => 100})
|
60
|
-
bot.reply test_str,
|
57
|
+
bot.reply test_str, fake_tweet(100, 100)
|
61
58
|
end
|
62
59
|
|
63
60
|
|
@@ -69,7 +66,7 @@ describe "Chatterbot::Tweet" do
|
|
69
66
|
allow(bot).to receive(:debug_mode?).and_return(true)
|
70
67
|
|
71
68
|
expect(bot.client).not_to receive(:update)
|
72
|
-
bot.reply "no reply test!",
|
69
|
+
bot.reply "no reply test!", fake_tweet(100)
|
73
70
|
end
|
74
71
|
end
|
75
72
|
|
data/templates/skeleton.txt
CHANGED
@@ -21,6 +21,23 @@ require 'chatterbot/dsl'
|
|
21
21
|
#
|
22
22
|
|
23
23
|
|
24
|
+
#
|
25
|
+
# These lines here are just to make sure you edit this file before
|
26
|
+
# trying to run your bot. You can safely remove them once you've
|
27
|
+
# looked through this file.
|
28
|
+
#
|
29
|
+
puts "========================"
|
30
|
+
puts "========================"
|
31
|
+
puts "========================"
|
32
|
+
puts "\n\n\n"
|
33
|
+
|
34
|
+
puts "Hey there! You should open %{name}.rb and take a look before running this script."
|
35
|
+
|
36
|
+
puts "\n\n\n"
|
37
|
+
exit
|
38
|
+
|
39
|
+
|
40
|
+
|
24
41
|
#
|
25
42
|
# Placing your security credentials right in a script like this is
|
26
43
|
# handy, but potentially dangerous, especially if your code is
|
@@ -78,13 +95,13 @@ exclude bad_words
|
|
78
95
|
only_interact_with_followers
|
79
96
|
|
80
97
|
#
|
81
|
-
# Specifying '
|
98
|
+
# Specifying 'use_streaming' will cause Chatterbot to use Twitter's
|
82
99
|
# Streaming API. Your bot will run constantly, listening for tweets.
|
83
100
|
# Alternatively, you can run your bot as a cron/scheduled job. In that
|
84
101
|
# case, do not use this line. Every time you run your bot, it will
|
85
102
|
# execute once, and then exit.
|
86
103
|
#
|
87
|
-
|
104
|
+
use_streaming
|
88
105
|
|
89
106
|
#
|
90
107
|
# Here's the fun stuff!
|
@@ -100,19 +117,19 @@ streaming true
|
|
100
117
|
# Still here? Hopefully it's because you're going to do something cool
|
101
118
|
# with the data that doesn't bother other people. Hooray!
|
102
119
|
#
|
103
|
-
search "chatterbot" do |tweet|
|
104
|
-
# here's the content of a tweet
|
105
|
-
puts tweets.text
|
106
|
-
end
|
120
|
+
#search "chatterbot" do |tweet|
|
121
|
+
# # here's the content of a tweet
|
122
|
+
# puts tweets.text
|
123
|
+
#end
|
107
124
|
|
108
125
|
#
|
109
126
|
# this block responds to mentions of your bot
|
110
127
|
#
|
111
|
-
replies do |tweet|
|
112
|
-
# Any time you put the #USER# token in a tweet, Chatterbot will
|
113
|
-
# replace it with the handle of the user you are interacting with
|
114
|
-
reply "Yes #USER#, you are very kind to say that!", tweet
|
115
|
-
end
|
128
|
+
#replies do |tweet|
|
129
|
+
# # Any time you put the #USER# token in a tweet, Chatterbot will
|
130
|
+
# # replace it with the handle of the user you are interacting with
|
131
|
+
# reply "Yes #USER#, you are very kind to say that!", tweet
|
132
|
+
#end
|
116
133
|
|
117
134
|
#
|
118
135
|
# this block handles incoming Direct Messages. if you want to do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatterbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Mitchell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: oauth
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.4.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: twitter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 5.
|
47
|
+
version: 5.16.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 5.
|
54
|
+
version: 5.16.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: launchy
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "<"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '11'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "<"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '11'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -281,9 +281,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
281
281
|
version: '0'
|
282
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
283
|
requirements:
|
284
|
-
- - "
|
284
|
+
- - ">="
|
285
285
|
- !ruby/object:Gem::Version
|
286
|
-
version:
|
286
|
+
version: '0'
|
287
287
|
requirements: []
|
288
288
|
rubyforge_project: chatterbot
|
289
289
|
rubygems_version: 2.2.2
|