twitter_ebooks 2.2.8 → 2.2.9
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 +1 -1
- data/lib/twitter_ebooks/archive.rb +5 -3
- data/lib/twitter_ebooks/bot.rb +16 -14
- data/lib/twitter_ebooks/version.rb +1 -1
- data/twitter_ebooks.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a5dca9c31287964724b38cb022c6273a242a59
|
4
|
+
data.tar.gz: 7c2f8e441bc119f1bc29b8e7ece6650812785fa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdd9dee8a8f53bb421761a0a485b0c5bcb2677355e6c4186c69c8e60d9f15dbd13a4c1cd77c09243e609bc53b02cecc3d2c6a2f81e2fadc4da0cc8b527558df3
|
7
|
+
data.tar.gz: 6a0beb91162f03bfd3ddc1edb386940919b066c13ef323d370b3314b9e4cdd3cca4463f22719ce0cecfd5f5f33fe5b5352268d71d99fa2f15f2b8f41749845a7
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# twitter\_ebooks 2.2.
|
1
|
+
# twitter\_ebooks 2.2.9
|
2
2
|
|
3
3
|
Rewrite of my twitter\_ebooks code. While the original was solely a tweeting Markov generator, this framework helps you build any kind of interactive twitterbot which responds to mentions/DMs. See [ebooks\_example](https://github.com/mispy/ebooks_example) for an example of a full bot.
|
4
4
|
|
@@ -31,12 +31,14 @@ module Ebooks
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
Twitter
|
34
|
+
Twitter.configure do |config|
|
35
35
|
config.consumer_key = @config[:consumer_key]
|
36
36
|
config.consumer_secret = @config[:consumer_secret]
|
37
|
-
config.
|
38
|
-
config.
|
37
|
+
config.oauth_token = @config[:oauth_token]
|
38
|
+
config.oauth_token_secret = @config[:oauth_token_secret]
|
39
39
|
end
|
40
|
+
|
41
|
+
Twitter::Client.new
|
40
42
|
end
|
41
43
|
|
42
44
|
def initialize(username, path, client=nil)
|
data/lib/twitter_ebooks/bot.rb
CHANGED
@@ -43,13 +43,15 @@ module Ebooks
|
|
43
43
|
config.oauth_token_secret = @oauth_token_secret
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
Twitter.configure do |config|
|
47
47
|
config.consumer_key = @consumer_key
|
48
48
|
config.consumer_secret = @consumer_secret
|
49
|
-
config.
|
50
|
-
config.
|
49
|
+
config.oauth_token = @oauth_token
|
50
|
+
config.oauth_token_secret = @oauth_token_secret
|
51
51
|
end
|
52
52
|
|
53
|
+
@twitter = Twitter::Client.new
|
54
|
+
|
53
55
|
needs_stream = [@on_follow, @on_message, @on_mention, @on_timeline].any? {|e| !e.nil?}
|
54
56
|
|
55
57
|
@stream = TweetStream::Client.new if needs_stream
|
@@ -88,19 +90,19 @@ module Ebooks
|
|
88
90
|
end
|
89
91
|
|
90
92
|
@stream.userstream do |ev|
|
91
|
-
next unless ev
|
92
|
-
next if ev
|
93
|
+
next unless ev[:text] # If it's not a text-containing tweet, ignore it
|
94
|
+
next if ev[:user][:screen_name] == @username # Ignore our own tweets
|
93
95
|
|
94
96
|
meta = {}
|
95
97
|
mentions = ev.attrs[:entities][:user_mentions].map { |x| x[:screen_name] }
|
96
98
|
|
97
99
|
reply_mentions = mentions.reject { |m| m.downcase == @username.downcase }
|
98
|
-
reply_mentions = [ev
|
100
|
+
reply_mentions = [ev[:user][:screen_name]] + reply_mentions
|
99
101
|
|
100
102
|
meta[:reply_prefix] = reply_mentions.uniq.map { |m| '@'+m }.join(' ') + ' '
|
101
103
|
meta[:limit] = 140 - meta[:reply_prefix].length
|
102
104
|
|
103
|
-
mless = ev
|
105
|
+
mless = ev[:text]
|
104
106
|
begin
|
105
107
|
ev.attrs[:entities][:user_mentions].reverse.each do |entity|
|
106
108
|
last = mless[entity[:indices][1]..-1]||''
|
@@ -108,7 +110,7 @@ module Ebooks
|
|
108
110
|
end
|
109
111
|
rescue Exception
|
110
112
|
p ev.attrs[:entities][:user_mentions]
|
111
|
-
p ev
|
113
|
+
p ev[:text]
|
112
114
|
raise
|
113
115
|
end
|
114
116
|
meta[:mentionless] = mless
|
@@ -117,8 +119,8 @@ module Ebooks
|
|
117
119
|
# - The tweet mentions list contains our username
|
118
120
|
# - The tweet is not being retweeted by somebody else
|
119
121
|
# - Or soft-retweeted by somebody else
|
120
|
-
if mentions.map(&:downcase).include?(@username.downcase) && !ev
|
121
|
-
log "Mention from @#{ev
|
122
|
+
if mentions.map(&:downcase).include?(@username.downcase) && !ev[:retweeted_status] && !ev[:text].start_with?('RT ')
|
123
|
+
log "Mention from @#{ev[:user][:screen_name]}: #{ev[:text]}"
|
122
124
|
@on_mention.call(ev, meta) if @on_mention
|
123
125
|
else
|
124
126
|
@on_timeline.call(ev, meta) if @on_timeline
|
@@ -139,11 +141,11 @@ module Ebooks
|
|
139
141
|
opts = opts.clone
|
140
142
|
|
141
143
|
if ev.is_a? Twitter::DirectMessage
|
142
|
-
log "Sending DM to @#{ev
|
143
|
-
@twitter.direct_message_create(ev
|
144
|
+
log "Sending DM to @#{ev[:sender][:screen_name]}: #{text}"
|
145
|
+
@twitter.direct_message_create(ev[:sender][:screen_name], text, opts)
|
144
146
|
elsif ev.is_a? Twitter::Tweet
|
145
|
-
log "Replying to @#{ev
|
146
|
-
@twitter.update(text, in_reply_to_status_id: ev
|
147
|
+
log "Replying to @#{ev[:user][:screen_name]} with: #{text}"
|
148
|
+
@twitter.update(text, in_reply_to_status_id: ev[:id])
|
147
149
|
else
|
148
150
|
raise Exception("Don't know how to reply to a #{ev.class}")
|
149
151
|
end
|
data/twitter_ebooks.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'memory_profiler'
|
20
20
|
gem.add_development_dependency 'pry-byebug'
|
21
21
|
|
22
|
-
gem.add_runtime_dependency 'twitter', '~>
|
22
|
+
gem.add_runtime_dependency 'twitter', '~> 4.0'
|
23
|
+
gem.add_runtime_dependency 'simple_oauth', '~> 0.2.0'
|
23
24
|
gem.add_runtime_dependency 'tweetstream'
|
24
25
|
gem.add_runtime_dependency 'rufus-scheduler'
|
25
26
|
gem.add_runtime_dependency 'gingerice'
|
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: 2.2.
|
4
|
+
version: 2.2.9
|
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-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -58,14 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.0'
|
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: '
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simple_oauth
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: tweetstream
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|