twitter_ebooks 3.0.4 → 3.0.5
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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/bin/ebooks +1 -0
- data/lib/twitter_ebooks/archive.rb +1 -1
- data/lib/twitter_ebooks/bot.rb +7 -1
- data/lib/twitter_ebooks/version.rb +1 -1
- data/skeleton/bots.rb +2 -2
- data/skeleton/{.gitignore → gitignore} +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216097fd35b255ddec313b23165d2567ca7531c3
|
4
|
+
data.tar.gz: 2b54bf321d33cb4b9a72f86049283f1ac8eb4bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe62a7fa1c3ac656b8cd9f241a585cf0f12cbb8c3bd426cb2f0b41d62fc84e88ac0fed2a265280784ad79658b9afcfda5967fcfad2f3bbdd1ad02618a361453
|
7
|
+
data.tar.gz: 59dc22b0ba45436013e64a0047253eeeaf743e79a2a1f80fccd1533dc480a2365f94dd667962257b559802cd49c083ec1e84ad786da7c828a6808f7f0793ea05
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ A framework for building interactive twitterbots which respond to mentions/DMs.
|
|
17
17
|
- Non-participating users in a mention chain will be dropped after a few tweets
|
18
18
|
- [API documentation](http://rdoc.info/github/mispy/twitter_ebooks) and tests
|
19
19
|
|
20
|
-
Note that 3.0 is not backwards compatible with 2.x, so upgrade carefully!
|
20
|
+
Note that 3.0 is not backwards compatible with 2.x, so upgrade carefully! In particular, **make sure to regenerate your models** since the storage format changed.
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
@@ -40,8 +40,8 @@ class MyBot < Ebooks::Bot
|
|
40
40
|
def configure
|
41
41
|
# Consumer details come from registering an app at https://dev.twitter.com/
|
42
42
|
# Once you have consumer details, use "ebooks auth" for new access tokens
|
43
|
-
self.consumer_key =
|
44
|
-
self.consumer_secret =
|
43
|
+
self.consumer_key = "" # Your app consumer key
|
44
|
+
self.consumer_secret = "" # Your app consumer secret
|
45
45
|
|
46
46
|
# Users to block instead of interacting with
|
47
47
|
self.blacklist = ['tnietzschequote']
|
@@ -87,7 +87,7 @@ MyBot.new("abby_ebooks") do |bot|
|
|
87
87
|
end
|
88
88
|
```
|
89
89
|
|
90
|
-
|
90
|
+
`ebooks start` will run all defined bots in their own threads. The easiest way to run bots in a semi-permanent fashion is with [Heroku](https://www.heroku.com); just make an app, push the bot repository to it, enable a worker process in the web interface and it ought to chug along merrily forever.
|
91
91
|
|
92
92
|
The underlying streaming and REST clients from the [twitter gem](https://github.com/sferik/twitter) can be accessed at `bot.stream` and `bot.twitter` respectively.
|
93
93
|
|
data/bin/ebooks
CHANGED
@@ -58,6 +58,7 @@ STR
|
|
58
58
|
end
|
59
59
|
|
60
60
|
FileUtils.cp_r(Ebooks::SKELETON_PATH, path)
|
61
|
+
FileUtils.mv(File.join(path, 'gitignore'), File.join(path, '.gitignore'))
|
61
62
|
|
62
63
|
File.open(File.join(path, 'bots.rb'), 'w') do |f|
|
63
64
|
template = File.read(File.join(Ebooks::SKELETON_PATH, 'bots.rb'))
|
@@ -50,7 +50,7 @@ module Ebooks
|
|
50
50
|
@client = client || make_client
|
51
51
|
|
52
52
|
if File.exists?(@path)
|
53
|
-
@tweets = JSON.parse(File.read(@path), symbolize_names: true)
|
53
|
+
@tweets = JSON.parse(File.read(@path, :encoding => 'utf-8'), symbolize_names: true)
|
54
54
|
log "Currently #{@tweets.length} tweets for #{@username}"
|
55
55
|
else
|
56
56
|
@tweets.nil?
|
data/lib/twitter_ebooks/bot.rb
CHANGED
@@ -180,12 +180,17 @@ module Ebooks
|
|
180
180
|
@seen_tweets ||= {}
|
181
181
|
|
182
182
|
@username = username
|
183
|
+
@delay_range ||= 1..6
|
183
184
|
configure
|
184
185
|
|
185
186
|
b.call(self) unless b.nil?
|
186
187
|
Bot.all << self
|
187
188
|
end
|
188
189
|
|
190
|
+
def configure
|
191
|
+
raise ConfigurationError, "Please override the 'configure' method for subclasses of Ebooks::Bot."
|
192
|
+
end
|
193
|
+
|
189
194
|
# Find or create the conversation context for this tweet
|
190
195
|
# @param tweet [Twitter::Tweet]
|
191
196
|
# @return [Ebooks::Conversation]
|
@@ -379,7 +384,8 @@ module Ebooks
|
|
379
384
|
end
|
380
385
|
|
381
386
|
log "Replying to @#{ev.user.screen_name} with: #{meta.reply_prefix + text}"
|
382
|
-
|
387
|
+
text = meta.reply_prefix + text unless text.match /@#{Regexp.escape ev.user.screen_name}/i
|
388
|
+
tweet = twitter.update(text, opts.merge(in_reply_to_status_id: ev.id))
|
383
389
|
conversation(tweet).add(tweet)
|
384
390
|
tweet
|
385
391
|
else
|
data/skeleton/bots.rb
CHANGED
@@ -39,12 +39,12 @@ class MyBot < Ebooks::Bot
|
|
39
39
|
|
40
40
|
def on_mention(tweet)
|
41
41
|
# Reply to a mention
|
42
|
-
# reply(tweet,
|
42
|
+
# reply(tweet, "oh hullo")
|
43
43
|
end
|
44
44
|
|
45
45
|
def on_timeline(tweet)
|
46
46
|
# Reply to a tweet in the bot's timeline
|
47
|
-
# reply(tweet,
|
47
|
+
# reply(tweet, "nice tweet")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_ebooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaiden Mispy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -260,11 +260,11 @@ files:
|
|
260
260
|
- lib/twitter_ebooks/nlp.rb
|
261
261
|
- lib/twitter_ebooks/suffix.rb
|
262
262
|
- lib/twitter_ebooks/version.rb
|
263
|
-
- skeleton/.gitignore
|
264
263
|
- skeleton/Gemfile
|
265
264
|
- skeleton/Procfile
|
266
265
|
- skeleton/bots.rb
|
267
266
|
- skeleton/corpus/.gitignore
|
267
|
+
- skeleton/gitignore
|
268
268
|
- skeleton/model/.gitignore
|
269
269
|
- spec/bot_spec.rb
|
270
270
|
- spec/data/0xabad1dea.json
|