twittbot 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/lib/twittbot/bot.rb +32 -25
- data/lib/twittbot/cli.rb +2 -1
- data/lib/twittbot/defaults.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9505942aefa10497e29a2efd8521310244ba2ceb3d9b3daa58f1ae6d7edf8bdf
|
4
|
+
data.tar.gz: 0e25fd635496d4b7116edb25e6d69aa890a8588e65927f617ffdba104b09ea4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cafa5c989946bc1d404b6db89c4a907b05813c995f1fb43cf43ab5a59e32ced8a2ae326a512f672d6368c27efc1378dcd9d6d6fdd735725860fd75c92a94fb8
|
7
|
+
data.tar.gz: c0657c6c65a5e4c6ec13bcb6d050005d931991f0cfd68ef0606c32ed7894f17402b40dc229b799674f6f77a391506d8a3b31cd08210fdc676b92a0527fe13ef1
|
data/CHANGELOG.md
CHANGED
data/lib/twittbot/bot.rb
CHANGED
@@ -26,8 +26,9 @@ module Twittbot
|
|
26
26
|
),
|
27
27
|
periodic: [],
|
28
28
|
save_config: true,
|
29
|
-
tasks: {}
|
30
|
-
|
29
|
+
tasks: {},
|
30
|
+
stream: options.fetch("stream", true)
|
31
|
+
}
|
31
32
|
|
32
33
|
load_bot_code
|
33
34
|
|
@@ -72,33 +73,37 @@ module Twittbot
|
|
72
73
|
check_config
|
73
74
|
init_clients
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
if $bot[:stream]
|
77
|
+
puts "connecting to streaming APIs"
|
78
|
+
|
79
|
+
@userstream_thread ||= Thread.new do
|
80
|
+
loop do
|
81
|
+
begin
|
82
|
+
puts "connected to user stream"
|
83
|
+
@streamer.user do |obj|
|
84
|
+
handle_stream_object obj, :user
|
85
|
+
end
|
86
|
+
rescue => e
|
87
|
+
puts "lost user stream connection: " + e.message
|
81
88
|
end
|
82
|
-
|
83
|
-
|
89
|
+
puts "reconnecting in #{Twittbot::RECONNECT_WAIT_TIME} seconds..."
|
90
|
+
sleep Twittbot::RECONNECT_WAIT_TIME
|
84
91
|
end
|
85
|
-
puts "reconnecting in #{Twittbot::RECONNECT_WAIT_TIME} seconds..."
|
86
|
-
sleep Twittbot::RECONNECT_WAIT_TIME
|
87
92
|
end
|
88
|
-
end
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
@tweetstream_thread ||= Thread.new do
|
95
|
+
loop do
|
96
|
+
begin
|
97
|
+
puts "connected to tweet stream"
|
98
|
+
@streamer.filter track: $bot[:config][:track].join(",") do |obj|
|
99
|
+
handle_stream_object obj, :filter
|
100
|
+
end
|
101
|
+
rescue
|
102
|
+
puts "lost tweet stream connection: " + e.message
|
96
103
|
end
|
97
|
-
|
98
|
-
|
104
|
+
puts "reconnecting in #{Twittbot::RECONNECT_WAIT_TIME} seconds..."
|
105
|
+
sleep Twittbot::RECONNECT_WAIT_TIME
|
99
106
|
end
|
100
|
-
puts "reconnecting in #{Twittbot::RECONNECT_WAIT_TIME} seconds..."
|
101
|
-
sleep Twittbot::RECONNECT_WAIT_TIME
|
102
107
|
end
|
103
108
|
end
|
104
109
|
|
@@ -114,8 +119,10 @@ module Twittbot
|
|
114
119
|
|
115
120
|
do_callbacks :load, nil
|
116
121
|
|
117
|
-
|
118
|
-
|
122
|
+
if $bot[:stream]
|
123
|
+
@userstream_thread.join
|
124
|
+
@tweetstream_thread.join
|
125
|
+
end
|
119
126
|
@periodic_thread.join
|
120
127
|
end
|
121
128
|
|
data/lib/twittbot/cli.rb
CHANGED
@@ -20,9 +20,10 @@ module Twittbot
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'start', 'Starts the bot'
|
23
|
+
method_option :stream, type: :boolean, desc: "Enable or disable the streaming API connection", default: true
|
23
24
|
def start
|
24
25
|
require 'twittbot/bot'
|
25
|
-
bot = Twittbot::Bot.new
|
26
|
+
bot = Twittbot::Bot.new(options)
|
26
27
|
bot.start
|
27
28
|
end
|
28
29
|
|
data/lib/twittbot/defaults.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twittbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nilsding
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.6
|
178
|
+
rubygems_version: 2.7.6
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: An advanced Twitter bot.
|