twittbot 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b29c8971b76f6db4f0a8e608691d47e48197be4e
4
- data.tar.gz: 48b6811b0919d1cb825f98f1aa7455b6bc302b89
2
+ SHA256:
3
+ metadata.gz: 9505942aefa10497e29a2efd8521310244ba2ceb3d9b3daa58f1ae6d7edf8bdf
4
+ data.tar.gz: 0e25fd635496d4b7116edb25e6d69aa890a8588e65927f617ffdba104b09ea4e
5
5
  SHA512:
6
- metadata.gz: 551cbe999c1dae4fe347daa60c8f24309a94aab01f94bb42dc9c5936fa9e89f28b2a8970530a18036ddef6f6f801b9dfb3242de98154ff69e0adaddd35424051
7
- data.tar.gz: f8a898e947011620bac124ef5a3cf7b645097a1d8e9a8e83db7750bfe22223b0442f0f04dabc6bb09097c1232950fc3e77820d7f5ae0738efa85974b8e39333b
6
+ metadata.gz: 6cafa5c989946bc1d404b6db89c4a907b05813c995f1fb43cf43ab5a59e32ced8a2ae326a512f672d6368c27efc1378dcd9d6d6fdd735725860fd75c92a94fb8
7
+ data.tar.gz: c0657c6c65a5e4c6ec13bcb6d050005d931991f0cfd68ef0606c32ed7894f17402b40dc229b799674f6f77a391506d8a3b31cd08210fdc676b92a0527fe13ef1
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ * Add `--no-stream` flag to the `start` command to disable connections to the
6
+ Streaming API
7
+
3
8
  ## 0.5.0
4
9
 
5
10
  * Add `expanded_text` method to Tweet objects which returns the full >140 character tweet text.
@@ -26,8 +26,9 @@ module Twittbot
26
26
  ),
27
27
  periodic: [],
28
28
  save_config: true,
29
- tasks: {}
30
- }.merge!(options)
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
- @userstream_thread ||= Thread.new do
76
- loop do
77
- begin
78
- puts "connected to user stream"
79
- @streamer.user do |obj|
80
- handle_stream_object obj, :user
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
- rescue => e
83
- puts "lost user stream connection: " + e.message
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
- @tweetstream_thread ||= Thread.new do
91
- loop do
92
- begin
93
- puts "connected to tweet stream"
94
- @streamer.filter track: $bot[:config][:track].join(",") do |obj|
95
- handle_stream_object obj, :filter
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
- rescue
98
- puts "lost tweet stream connection: " + e.message
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
- @userstream_thread.join
118
- @tweetstream_thread.join
122
+ if $bot[:stream]
123
+ @userstream_thread.join
124
+ @tweetstream_thread.join
125
+ end
119
126
  @periodic_thread.join
120
127
  end
121
128
 
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  module Twittbot
2
2
  # The version of Twittbot.
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
 
5
5
  CONSUMER_KEY = 'FYRuQcDbPAXAyVjuPZMuw' # :nodoc:
6
6
  CONSUMER_SECRET = 'KiLCYTftPdxNebl5DNcj7Ey2Y8YVZu7hfqiFRYkcg' # :nodoc:
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.5.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: 2017-11-07 00:00:00.000000000 Z
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.13
178
+ rubygems_version: 2.7.6
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: An advanced Twitter bot.