ruboty-twitter 0.0.6 → 0.0.7
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/CHANGELOG.md +3 -0
- data/README.md +3 -2
- data/lib/ruboty/adapters/twitter.rb +21 -8
- data/lib/ruboty/twitter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd89760887aa4fc864d13f851470a28bba23433
|
4
|
+
data.tar.gz: 5ecb4bad1de70cdcb57d2d1ace44088a014cbf76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438c41b94822053d118a28a4a9fa4315ec5cc3b50ca119f686f42d31434c6d35f1e2481e784d8b3d7f5a5db2fff3510042b9a83862c9360d93ae2ec36d692764
|
7
|
+
data.tar.gz: ce1e666456c9f3a9a73c56fb8ff0c70ada9782222c67d259e88d3e317c73c5f5320e1ce5c2ab6de6db345975a3ef3b9d9d9f52087d0c8156f97efd0f5afd8d03
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -9,8 +9,9 @@ gem "ruboty-twitter"
|
|
9
9
|
|
10
10
|
## ENV
|
11
11
|
```
|
12
|
-
TWITTER_CONSUMER_KEY - Twitter consumer key (a.k.a. API key)
|
13
|
-
TWITTER_CONSUMER_SECRET - Twitter consumer secret (a.k.a. API secret)
|
14
12
|
TWITTER_ACCESS_TOKEN - Twitter access token
|
15
13
|
TWITTER_ACCESS_TOKEN_SECRET - Twitter access token secret
|
14
|
+
TWITTER_CONSUMER_KEY - Twitter consumer key (a.k.a. API key)
|
15
|
+
TWITTER_CONSUMER_SECRET - Twitter consumer secret (a.k.a. API secret)
|
16
|
+
TWITTER_AUTO_FOLLOW_BACK - Pass 1 to follow back followers (optional)
|
16
17
|
```
|
@@ -7,10 +7,11 @@ module Ruboty
|
|
7
7
|
class Twitter < Base
|
8
8
|
include Mem
|
9
9
|
|
10
|
-
env :TWITTER_CONSUMER_KEY, "Twitter consumer key (a.k.a. API key)"
|
11
|
-
env :TWITTER_CONSUMER_SECRET, "Twitter consumer secret (a.k.a. API secret)"
|
12
10
|
env :TWITTER_ACCESS_TOKEN, "Twitter access token"
|
13
11
|
env :TWITTER_ACCESS_TOKEN_SECRET, "Twitter access token secret"
|
12
|
+
env :TWITTER_AUTO_FOLLOW_BACK, "Pass 1 to follow back followers (optional)", optional: true
|
13
|
+
env :TWITTER_CONSUMER_KEY, "Twitter consumer key (a.k.a. API key)"
|
14
|
+
env :TWITTER_CONSUMER_SECRET, "Twitter consumer secret (a.k.a. API secret)"
|
14
15
|
|
15
16
|
def run
|
16
17
|
Ruboty.logger.debug("#{self.class}##{__method__} started")
|
@@ -25,16 +26,28 @@ module Ruboty
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
29
|
+
def enabled_to_auto_follow_back?
|
30
|
+
ENV["TWITTER_AUTO_FOLLOW_BACK"] == "1"
|
31
|
+
end
|
32
|
+
|
28
33
|
def listen
|
29
|
-
stream.user do |
|
30
|
-
case
|
34
|
+
stream.user do |message|
|
35
|
+
case message
|
31
36
|
when ::Twitter::Tweet
|
32
|
-
Ruboty.logger.debug("
|
37
|
+
Ruboty.logger.debug("#{message.user.screen_name} tweeted #{message.text.inspect}")
|
33
38
|
robot.receive(
|
34
|
-
body:
|
35
|
-
from:
|
36
|
-
tweet:
|
39
|
+
body: message.text,
|
40
|
+
from: message.user.screen_name,
|
41
|
+
tweet: message
|
37
42
|
)
|
43
|
+
when ::Twitter::Streaming::Event
|
44
|
+
if message.name == :follow
|
45
|
+
Ruboty.logger.debug("#{message.source.screen_name} followed #{message.target.screen_name}")
|
46
|
+
if enabled_to_auto_follow_back? && message.target.screen_name == robot.name
|
47
|
+
Ruboty.logger.debug("Trying to follow back #{message.source.screen_name}")
|
48
|
+
client.follow(message.source.screen_name)
|
49
|
+
end
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-twitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|