chatterbot 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +5 -9
- data/README.markdown +46 -35
- data/chatterbot.gemspec +3 -2
- data/lib/chatterbot.rb +2 -0
- data/lib/chatterbot/bot.rb +1 -0
- data/lib/chatterbot/config.rb +5 -5
- data/lib/chatterbot/dsl.rb +28 -0
- data/lib/chatterbot/home_timeline.rb +33 -0
- data/lib/chatterbot/reply.rb +1 -1
- data/lib/chatterbot/search.rb +6 -5
- data/lib/chatterbot/ui.rb +25 -15
- data/lib/chatterbot/version.rb +1 -1
- data/spec/dsl_spec.rb +5 -0
- data/spec/home_timeline_spec.rb +53 -0
- data/spec/search_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -0
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fbc2531f820dba19fb0a7a8a42d167608e0c6ed
|
4
|
+
data.tar.gz: 940c107b1d1a3e625dd6a95dcb0a289b7833bd49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8c77f2a0d9a9353e9bc7823b0bdcf7d61c6b7c3a8b7000b33314712c8aa9fbd78cee2f97ba17cb9c7a5ec4528c863c50d6e021a8b97bc87c73a6ab5cfffa30
|
7
|
+
data.tar.gz: 1abb9ed9e3500ff31b784f42028c8213be682d01292847928bf3e73fa51c85dc2f6fa921dac608bd803f9bfdee4ac0625c23e258c74286260387a81f0185e71b
|
data/LICENSE.txt
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
DO WHAT THE FUCK YOU WANT TO
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
Copyright (C) 2011 Colin Mitchell <colin@muffinlabs.com>
|
6
|
-
Derived from WTFPL, Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
4
|
+
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
7
5
|
|
8
6
|
Everyone is permitted to copy and distribute verbatim or modified
|
9
7
|
copies of this license document, and changing it is allowed as long
|
10
8
|
as the name is changed.
|
11
9
|
|
12
|
-
|
13
|
-
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
14
12
|
|
15
13
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
16
|
-
1. Don't be an asshole. Really.
|
17
|
-
|
data/README.markdown
CHANGED
@@ -1,38 +1,32 @@
|
|
1
1
|
Chatterbot
|
2
2
|
===========
|
3
3
|
|
4
|
-
Chatterbot is a Ruby library for making bots on Twitter. It
|
5
|
-
|
6
|
-
|
7
|
-
a simple blacklist system to help
|
8
|
-
|
4
|
+
Chatterbot is a Ruby library for making bots on Twitter. It's
|
5
|
+
great for rapid development of bot ideas. It handles all of the basic
|
6
|
+
Twitter API features -- searches, replies, tweets, retweets, etc. and has
|
7
|
+
a simple blacklist/whitelist system to help minimize spam and unwanted
|
8
|
+
data.
|
9
9
|
|
10
10
|
[![Build Status](https://secure.travis-ci.org/muffinista/chatterbot.png?branch=master)](http://travis-ci.org/muffinista/chatterbot)
|
11
11
|
|
12
|
-
|
13
12
|
Features
|
14
13
|
--------
|
15
|
-
* Works via Twitter's OAuth system.
|
16
14
|
* Handles search queries and replies to your bot
|
17
|
-
* Use a simple
|
15
|
+
* Use a simple scripting language, or extend a Bot class if you need it
|
16
|
+
* Wraps the Twitter gem so you have access to the entire Twitter API
|
18
17
|
* Simple blacklistling system to limit your annoyance of users
|
18
|
+
* Avoid your bot making a fool of itself by ignoring tweets with
|
19
|
+
certain bad words
|
20
|
+
* Basic Streaming API support
|
19
21
|
* Optionally log tweets to the database for metrics and tracking purposes
|
20
22
|
|
21
|
-
Is Writing Bots a Good Use of My Time?
|
22
|
-
======================================
|
23
|
-
|
24
|
-
Quick answer: if you're planning on being spammish on Twitter, you
|
25
|
-
should probably find something else to do. If you're planning on
|
26
|
-
writing a bot that isn't too rude or annoying, or that expects a
|
27
|
-
certain amount of opt-in from users, then you're probably good. I've
|
28
|
-
written a blog post about bots on Twitter here:
|
29
|
-
http://muffinlabs.com/2012/06/04/the-current-state-of-bots-on-twitter/
|
30
|
-
|
31
|
-
|
32
23
|
|
33
24
|
Using Chatterbot
|
34
25
|
================
|
35
26
|
|
27
|
+
**NEW!!** Chatterbot has a [documentation website](http://muffinista.github.io/chatterbot/). It's a work-in-progress.
|
28
|
+
|
29
|
+
|
36
30
|
Make a Twitter account
|
37
31
|
----------------------
|
38
32
|
|
@@ -50,23 +44,39 @@ actual bot.
|
|
50
44
|
Write your bot
|
51
45
|
--------------
|
52
46
|
|
53
|
-
|
54
|
-
earlier Twitter bot framework. Here's an example, based on
|
55
|
-
[@dr_rumack](http://twitter.com/#!/Dr_Rumack), an actual bot running
|
56
|
-
on Twitter:
|
47
|
+
A bot using chatterbot can be as simple as this:
|
57
48
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
49
|
+
```
|
50
|
+
exclude "http://"
|
51
|
+
blacklist "mean_user, private_user"
|
62
52
|
|
63
|
-
|
53
|
+
puts "checking my timeline"
|
54
|
+
home_timeline do |tweet|
|
55
|
+
# i like to favorite things
|
56
|
+
favorite tweet
|
57
|
+
end
|
58
|
+
|
59
|
+
puts "checking for replies to my tweets and mentions of me"
|
60
|
+
replies do |tweet|
|
61
|
+
text = tweet.text
|
62
|
+
puts "message received: #{text}"
|
63
|
+
src = text.gsub(/@echoes_bot/, "#USER#")
|
64
|
+
|
65
|
+
# send it back!
|
66
|
+
reply src, tweet
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
Or you can write a bot using more traditional ruby classes, extend it if needed, and use it like so:
|
64
71
|
|
65
72
|
bot = Chatterbot::Bot.new
|
66
73
|
bot.search("'surely you must be joking'") do |tweet|
|
67
74
|
bot.reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet
|
68
75
|
end
|
69
76
|
|
77
|
+
Chatterbot can actually generate a template bot file for you, and will
|
78
|
+
walk you through process of getting a bot authorized with Twitter.
|
79
|
+
|
70
80
|
That's it!
|
71
81
|
|
72
82
|
Chatterbot uses the the Twitter gem
|
@@ -93,6 +103,12 @@ Here's a list of the important methods in the Chatterbot DSL:
|
|
93
103
|
|
94
104
|
Note that the string #USER# will be replaced with the username of the person who sent the original tweet.
|
95
105
|
|
106
|
+
**home_timeline** -- This call will return tweets from the bot's home timeline -- this will include tweets from accounts the bot follows, as well as the bot's own tweets:
|
107
|
+
home_timeline do |tweet|
|
108
|
+
puts tweet.text # this is the actual tweeted text
|
109
|
+
favorite tweet # i like to fave tweets
|
110
|
+
end
|
111
|
+
|
96
112
|
**tweet** -- send a Tweet out for this bot:
|
97
113
|
|
98
114
|
tweet "I AM A BOT!!!"
|
@@ -314,13 +330,8 @@ sense if requested.
|
|
314
330
|
Copyright/License
|
315
331
|
-----------------
|
316
332
|
|
317
|
-
Copyright (c)
|
318
|
-
|
319
|
-
but don't be an asshole' public license. Please see LICENSE.txt for
|
320
|
-
further details. Basically, do whatever you want with this code, but
|
321
|
-
don't be an asshole about it. If you spam users inappropriately,
|
322
|
-
expect your karma to suffer.
|
323
|
-
|
333
|
+
Copyright (c) 2014 Colin Mitchell. Chatterbot is distributed under the
|
334
|
+
WTFPL licence -- Please see LICENSE.txt for further details.
|
324
335
|
|
325
336
|
http://muffinlabs.com
|
326
337
|
|
data/chatterbot.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
-
s.licenses = ["
|
21
|
+
s.licenses = ["WTFPL"]
|
22
22
|
|
23
23
|
if RUBY_VERSION < "1.9" || RUBY_VERSION == "1.9.2"
|
24
24
|
s.add_dependency "activesupport", "~> 3.0.11"
|
@@ -30,7 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
|
31
31
|
s.add_runtime_dependency(%q<oauth>, [">= 0.4.7"])
|
32
32
|
s.add_runtime_dependency(%q<twitter>, ["5.8.0"])
|
33
|
-
s.add_runtime_dependency(%q<launchy>, [">= 2.
|
33
|
+
s.add_runtime_dependency(%q<launchy>, [">= 2.4.2"])
|
34
|
+
s.add_runtime_dependency(%q<colorize>, [">= 0.7.3"])
|
34
35
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
35
36
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
36
37
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
data/lib/chatterbot.rb
CHANGED
@@ -2,6 +2,7 @@ require 'yaml'
|
|
2
2
|
require 'oauth'
|
3
3
|
require 'twitter'
|
4
4
|
require 'launchy'
|
5
|
+
require 'colorize'
|
5
6
|
|
6
7
|
#
|
7
8
|
# Try and load Sequel, but don't freak out if it's not there
|
@@ -46,6 +47,7 @@ module Chatterbot
|
|
46
47
|
require "chatterbot/favorite"
|
47
48
|
require "chatterbot/profile"
|
48
49
|
require "chatterbot/reply"
|
50
|
+
require "chatterbot/home_timeline"
|
49
51
|
require "chatterbot/streaming"
|
50
52
|
require "chatterbot/streaming_handler"
|
51
53
|
require "chatterbot/followers"
|
data/lib/chatterbot/bot.rb
CHANGED
data/lib/chatterbot/config.rb
CHANGED
@@ -6,6 +6,7 @@ module Chatterbot
|
|
6
6
|
attr_accessor :config
|
7
7
|
|
8
8
|
MAX_TWEET_ID = 9223372036854775807
|
9
|
+
COMMAND_LINE_VARIABLES = [:debug_mode, :no_update, :verbose, :reset_since_id]
|
9
10
|
|
10
11
|
#
|
11
12
|
# the entire config for the bot, loaded from YAML files and the DB if applicable
|
@@ -273,7 +274,7 @@ module Chatterbot
|
|
273
274
|
return {} if db.nil?
|
274
275
|
db[:config][:id => botname]
|
275
276
|
end
|
276
|
-
|
277
|
+
|
277
278
|
#
|
278
279
|
# figure out what we should save to the local config file. we don't
|
279
280
|
# save anything that exists in the global config, unless it's been modified
|
@@ -283,10 +284,9 @@ module Chatterbot
|
|
283
284
|
tmp = config.delete_if { |k, v| global_config.has_key?(k) && global_config[k] == config[k] }
|
284
285
|
|
285
286
|
# let's not store these, they're just command-line options
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
287
|
+
COMMAND_LINE_VARIABLES.each { |k|
|
288
|
+
tmp.delete(k)
|
289
|
+
}
|
290
290
|
|
291
291
|
# update the since_id now
|
292
292
|
tmp[:since_id] = tmp.delete(:tmp_since_id) unless ! tmp.has_key?(:tmp_since_id)
|
data/lib/chatterbot/dsl.rb
CHANGED
@@ -14,6 +14,13 @@ module Chatterbot
|
|
14
14
|
#
|
15
15
|
# search twitter for the specified terms, then pass any matches to
|
16
16
|
# the block.
|
17
|
+
# @param opts [Hash] options. these will be passed directly to
|
18
|
+
# Twitter via the twitter gem. You can see the possible arguments
|
19
|
+
# at http://www.rubydoc.info/gems/twitter/Twitter/REST/Search#search-instance_method
|
20
|
+
# There is one extra argument:
|
21
|
+
# @option options [Integer] :limit limit the number of tweets to
|
22
|
+
# return per search
|
23
|
+
|
17
24
|
# @example
|
18
25
|
# search("chatterbot is cool!") do |tweet|
|
19
26
|
# puts tweet.text # this is the actual tweeted text
|
@@ -23,6 +30,19 @@ module Chatterbot
|
|
23
30
|
bot.search(query, opts, &block)
|
24
31
|
end
|
25
32
|
|
33
|
+
#
|
34
|
+
# handle tweets that are on the bot's home timeline. this includes
|
35
|
+
# tweets from accounts the bot is following, as well as its own tweets
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# home_timeline do |tweet|
|
39
|
+
# puts tweet.text # this is the actual tweeted text
|
40
|
+
# favorite tweet # i like to fave tweets
|
41
|
+
# end
|
42
|
+
def home_timeline(opts = {}, &block)
|
43
|
+
bot.home_timeline(opts, &block)
|
44
|
+
end
|
45
|
+
|
26
46
|
#
|
27
47
|
# handle replies to the bot. Each time this is called, chatterbot
|
28
48
|
# will pass any replies since the last call to the specified block
|
@@ -87,6 +107,10 @@ module Chatterbot
|
|
87
107
|
bot.reply(txt, source)
|
88
108
|
end
|
89
109
|
|
110
|
+
#
|
111
|
+
# handle getting/setting the profile text.
|
112
|
+
# @param [p] p The new value for the profile. If this isn't passed in, the method will simply return the current value
|
113
|
+
# @return profile text
|
90
114
|
def profile_text(p=nil)
|
91
115
|
if p.nil?
|
92
116
|
bot.profile_text
|
@@ -95,6 +119,10 @@ module Chatterbot
|
|
95
119
|
end
|
96
120
|
end
|
97
121
|
|
122
|
+
#
|
123
|
+
# handle getting/setting the profile website
|
124
|
+
# @param [p] p The new value for the website. If this isn't passed in, the method will simply return the current value
|
125
|
+
# @return profile website
|
98
126
|
def profile_website(w=nil)
|
99
127
|
if w.nil?
|
100
128
|
bot.profile_website
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Chatterbot
|
2
|
+
|
3
|
+
#
|
4
|
+
# methods for checking the bots timeline
|
5
|
+
module HomeTimeline
|
6
|
+
|
7
|
+
# handle the bots timeline
|
8
|
+
def home_timeline(opts={}, &block)
|
9
|
+
return unless require_login
|
10
|
+
|
11
|
+
debug "check for home_timeline tweets since #{since_id}"
|
12
|
+
|
13
|
+
opts = {
|
14
|
+
:since_id => since_id,
|
15
|
+
:count => 200
|
16
|
+
}.merge(opts)
|
17
|
+
|
18
|
+
results = client.home_timeline(opts)
|
19
|
+
|
20
|
+
@current_tweet = nil
|
21
|
+
results.each { |s|
|
22
|
+
update_since_id(s)
|
23
|
+
if has_whitelist? && !on_whitelist?(s)
|
24
|
+
debug "skipping because user not on whitelist"
|
25
|
+
elsif block_given? && !on_blacklist?(s) && !skip_me?(s)
|
26
|
+
@current_tweet = s
|
27
|
+
yield s
|
28
|
+
end
|
29
|
+
}
|
30
|
+
@current_tweet = nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/chatterbot/reply.rb
CHANGED
data/lib/chatterbot/search.rb
CHANGED
@@ -4,6 +4,8 @@ module Chatterbot
|
|
4
4
|
# handle Twitter searches
|
5
5
|
module Search
|
6
6
|
|
7
|
+
MAX_SEARCH_TWEETS = 1000
|
8
|
+
|
7
9
|
@skip_retweets = true
|
8
10
|
|
9
11
|
#
|
@@ -25,21 +27,20 @@ module Chatterbot
|
|
25
27
|
def search(queries, opts = {}, &block)
|
26
28
|
debug "check for tweets since #{since_id}"
|
27
29
|
|
30
|
+
max_tweets = opts.delete(:limit) || MAX_SEARCH_TWEETS
|
31
|
+
|
28
32
|
if queries.is_a?(String)
|
29
33
|
queries = [queries]
|
30
34
|
end
|
31
35
|
|
32
|
-
|
33
36
|
#
|
34
37
|
# search twitter
|
35
38
|
#
|
36
39
|
queries.each { |query|
|
37
40
|
debug "search: #{query} #{default_opts.merge(opts)}"
|
38
|
-
result = client.search( query, default_opts.merge(opts) )
|
39
|
-
update_since_id(result)
|
40
|
-
|
41
41
|
@current_tweet = nil
|
42
|
-
|
42
|
+
client.search( query, default_opts.merge(opts) ).take(max_tweets).each { |s|
|
43
|
+
update_since_id(s)
|
43
44
|
debug s.text
|
44
45
|
if has_whitelist? && !on_whitelist?(s)
|
45
46
|
debug "skipping because user not on whitelist"
|
data/lib/chatterbot/ui.rb
CHANGED
@@ -5,17 +5,28 @@ module Chatterbot
|
|
5
5
|
#
|
6
6
|
module UI
|
7
7
|
|
8
|
+
API_SIGNUP_URL = "https://twitter.com/apps/new"
|
9
|
+
|
10
|
+
|
11
|
+
def red(str)
|
12
|
+
puts str.colorize(:red)
|
13
|
+
end
|
14
|
+
|
15
|
+
def green(str)
|
16
|
+
puts str.colorize(:green)
|
17
|
+
end
|
18
|
+
|
8
19
|
#
|
9
20
|
# print out a message about getting a PIN from twitter, then output
|
10
21
|
# the URL the user needs to visit to authorize
|
11
22
|
#
|
12
23
|
#:nocov:
|
13
24
|
def get_oauth_verifier
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
25
|
+
green "****************************************"
|
26
|
+
green "****************************************"
|
27
|
+
green "**** BOT AUTH TIME! ****"
|
28
|
+
green "****************************************"
|
29
|
+
green "****************************************"
|
19
30
|
|
20
31
|
puts "You need to authorize your bot with Twitter.\n\nPlease login to Twitter under the bot's account. When you're ready, hit Enter.\n\nYour browser will open with the following URL, where you can authorize the bot.\n\n"
|
21
32
|
|
@@ -47,33 +58,32 @@ module Chatterbot
|
|
47
58
|
#
|
48
59
|
# Ask the user to get an API key from Twitter.
|
49
60
|
def get_api_key
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
green "****************************************"
|
62
|
+
green "****************************************"
|
63
|
+
green "**** API SETUP TIME! ****"
|
64
|
+
green "****************************************"
|
65
|
+
green "****************************************"
|
55
66
|
|
56
|
-
api_url = "https://dev.twitter.com/apps/new"
|
57
67
|
|
58
68
|
puts "Hey, looks like you need to get an API key from Twitter before you can get started."
|
59
|
-
puts "Please hit enter, and I will send you to #{
|
69
|
+
puts "Please hit enter, and I will send you to #{API_SIGNUP_URL} to start the process."
|
60
70
|
puts "(If it doesn't work, you can open a browser and paste the URL in manually)"
|
61
71
|
|
62
72
|
puts "\nHit Enter to continue."
|
63
73
|
|
64
74
|
STDIN.readline
|
65
75
|
|
66
|
-
Launchy.open(
|
76
|
+
Launchy.open(API_SIGNUP_URL)
|
67
77
|
# pause to allow any launchy output
|
68
78
|
sleep(1)
|
69
79
|
|
70
80
|
puts "\n\n"
|
71
81
|
|
72
|
-
print "\n\nPaste the '
|
82
|
+
print "\n\nPaste the 'API Key' here: "
|
73
83
|
STDOUT.flush
|
74
84
|
config[:consumer_key] = STDIN.readline.chomp
|
75
85
|
|
76
|
-
print "Paste the '
|
86
|
+
print "Paste the 'API Secret' here: "
|
77
87
|
STDOUT.flush
|
78
88
|
config[:consumer_secret] = STDIN.readline.chomp
|
79
89
|
|
data/lib/chatterbot/version.rb
CHANGED
data/spec/dsl_spec.rb
CHANGED
@@ -133,6 +133,11 @@ describe "Chatterbot::DSL" do
|
|
133
133
|
expect(@bot).to receive(:replies)
|
134
134
|
replies
|
135
135
|
end
|
136
|
+
|
137
|
+
it "#home_timeline passes along to bot object" do
|
138
|
+
expect(@bot).to receive(:home_timeline)
|
139
|
+
home_timeline
|
140
|
+
end
|
136
141
|
|
137
142
|
it "#streaming_tweets passes along to bot object" do
|
138
143
|
expect(@bot).to receive(:streaming_tweets)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Chatterbot::HomeTimeline" do
|
4
|
+
it "calls require_login" do
|
5
|
+
bot = test_bot
|
6
|
+
expect(bot).to receive(:require_login).and_return(false)
|
7
|
+
bot.home_timeline
|
8
|
+
end
|
9
|
+
|
10
|
+
it "updates since_id when complete" do
|
11
|
+
bot = test_bot
|
12
|
+
expect(bot).to receive(:require_login).and_return(true)
|
13
|
+
results = fake_home_timeline(1, 1000)
|
14
|
+
|
15
|
+
allow(bot).to receive(:client).and_return(results)
|
16
|
+
|
17
|
+
bot.home_timeline do
|
18
|
+
end
|
19
|
+
|
20
|
+
expect(bot.config[:tmp_since_id]).to eq(1000)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "iterates results" do
|
24
|
+
bot = test_bot
|
25
|
+
expect(bot).to receive(:require_login).and_return(true)
|
26
|
+
allow(bot).to receive(:client).and_return(fake_home_timeline(3))
|
27
|
+
|
28
|
+
expect(bot).to receive(:update_since_id).exactly(3).times
|
29
|
+
|
30
|
+
indexes = []
|
31
|
+
bot.home_timeline do |x|
|
32
|
+
indexes << x[:id]
|
33
|
+
end
|
34
|
+
|
35
|
+
expect(indexes).to eq([1,2,3])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "checks blacklist" do
|
39
|
+
bot = test_bot
|
40
|
+
expect(bot).to receive(:require_login).and_return(true)
|
41
|
+
allow(bot).to receive(:client).and_return(fake_home_timeline(3))
|
42
|
+
|
43
|
+
allow(bot).to receive(:on_blacklist?).and_return(true, false, false)
|
44
|
+
|
45
|
+
|
46
|
+
indexes = []
|
47
|
+
bot.home_timeline do |x|
|
48
|
+
indexes << x[:id]
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(indexes).to eq([2,3])
|
52
|
+
end
|
53
|
+
end
|
data/spec/search_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe "Chatterbot::Search" do
|
|
13
13
|
|
14
14
|
data = fake_search(100, 1)
|
15
15
|
allow(bot).to receive(:client).and_return(data)
|
16
|
-
expect(bot).to receive(:update_since_id).with(data.search)
|
16
|
+
expect(bot).to receive(:update_since_id).with(data.search[0])
|
17
17
|
|
18
18
|
bot.search("foo")
|
19
19
|
end
|
@@ -62,7 +62,7 @@ describe "Chatterbot::Search" do
|
|
62
62
|
results = fake_search(1000, 1)
|
63
63
|
allow(bot).to receive(:client).and_return(results)
|
64
64
|
|
65
|
-
expect(bot).to receive(:update_since_id).with(results.search)
|
65
|
+
expect(bot).to receive(:update_since_id).with(results.search[0])
|
66
66
|
bot.search("foo")
|
67
67
|
end
|
68
68
|
|
data/spec/spec_helper.rb
CHANGED
@@ -54,6 +54,12 @@ def fake_replies(result_count = 0, id_base = 0)
|
|
54
54
|
c
|
55
55
|
end
|
56
56
|
|
57
|
+
def fake_home_timeline(result_count = 0, id_base = 0)
|
58
|
+
c = stubbable_client
|
59
|
+
allow(c).to receive_messages(:home_timeline => 1.upto(result_count).collect { |i| fake_tweet(i, id_base)})
|
60
|
+
c
|
61
|
+
end
|
62
|
+
|
57
63
|
def fake_followers(count)
|
58
64
|
c = stubbable_client
|
59
65
|
allow(c).to receive_messages(:followers => 1.upto(count).collect { |i| fake_follower(i) })
|
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: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Mitchell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -58,14 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.4.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.4.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.3
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: yard
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +231,7 @@ files:
|
|
217
231
|
- lib/chatterbot/favorite.rb
|
218
232
|
- lib/chatterbot/followers.rb
|
219
233
|
- lib/chatterbot/helpers.rb
|
234
|
+
- lib/chatterbot/home_timeline.rb
|
220
235
|
- lib/chatterbot/logging.rb
|
221
236
|
- lib/chatterbot/profile.rb
|
222
237
|
- lib/chatterbot/reply.rb
|
@@ -239,6 +254,7 @@ files:
|
|
239
254
|
- spec/favorite_spec.rb
|
240
255
|
- spec/followers_spec.rb
|
241
256
|
- spec/helpers_spec.rb
|
257
|
+
- spec/home_timeline_spec.rb
|
242
258
|
- spec/logging_spec.rb
|
243
259
|
- spec/profile_spec.rb
|
244
260
|
- spec/reply_spec.rb
|
@@ -255,7 +271,7 @@ files:
|
|
255
271
|
- templates/skeleton.txt
|
256
272
|
homepage: http://github.com/muffinista/chatterbot
|
257
273
|
licenses:
|
258
|
-
-
|
274
|
+
- WTFPL
|
259
275
|
metadata: {}
|
260
276
|
post_install_message:
|
261
277
|
rdoc_options: []
|