bender-bot 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bender/main.rb +39 -23
- 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: d2171e9575b5e902190f80671fc54d50d3a29807
|
4
|
+
data.tar.gz: fe7a496b89279728545e4fe032f2c964c9e5b45c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 601fed44461ff0050a959c50d246a8acbcde081d3b2d0d8040df01d8a359785f13e5d15a337288280aa40614d87bcfd5a70d026575469aa8d988565e0e8957ea
|
7
|
+
data.tar.gz: 41985123cd22f41401a556c3ce56bcaabc21b6252c22ff9f624c1699668ef2499b7c0930d2860834f0066b6866da9eb7c382f65f7ee90072ebdb3e6b02be882e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/lib/bender/main.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'net/http'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
require 'tilt/erb'
|
5
6
|
require 'queryparams'
|
@@ -141,13 +142,20 @@ module Bender
|
|
141
142
|
aliases: %w[ -O ],
|
142
143
|
desc: 'Reverse order of HipChat API loading (hack)',
|
143
144
|
default: false
|
145
|
+
option :room_base_name, \
|
146
|
+
type: :string,
|
147
|
+
aliases: %w[ -N ],
|
148
|
+
desc: 'Base name for the primary room',
|
149
|
+
default: 'Production Indicent'
|
144
150
|
include_common_options
|
145
151
|
def start
|
146
152
|
bot = start_bot
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
153
|
+
ts = []
|
154
|
+
ts << periodically_refresh_group(bot)
|
155
|
+
ts << periodically_refresh_users(bot)
|
156
|
+
ts << periodically_refresh_incidents(bot)
|
157
|
+
# serve_web bot
|
158
|
+
ts.map(&:join)
|
151
159
|
end
|
152
160
|
|
153
161
|
|
@@ -200,13 +208,9 @@ module Bender
|
|
200
208
|
|
201
209
|
if open_incidents.empty?
|
202
210
|
if @open.nil? || @open > 0
|
203
|
-
new_room['name'] = '[NONE]
|
211
|
+
new_room['name'] = '[NONE] %s' % options.room_base_name
|
204
212
|
new_room['topic'] = 'Good news everyone! No high-severity incidents at the moment'
|
205
|
-
|
206
|
-
room.update_room(new_room)
|
207
|
-
rescue NoMethodError
|
208
|
-
log.warn 'NoMethodError in set_room_name_and_topic'
|
209
|
-
end
|
213
|
+
apply_room_name_and_topic new_room
|
210
214
|
end
|
211
215
|
|
212
216
|
@open = 0
|
@@ -218,14 +222,10 @@ module Bender
|
|
218
222
|
end
|
219
223
|
|
220
224
|
unless @open == open_incidents.size
|
221
|
-
new_room['name'] = '[IN PROGRESS]
|
225
|
+
new_room['name'] = '[IN PROGRESS] %s' % options.room_base_name
|
222
226
|
tha_news = open_incidents.size == 1 ? "There's a high-severity incident" : "There are #{open_incidents.size} high-severity incidents"
|
223
227
|
new_room['topic'] = "Terrible news everyone! #{tha_news}"
|
224
|
-
|
225
|
-
room.update_room(new_room)
|
226
|
-
rescue NoMethodError
|
227
|
-
log.warn 'NoMethodError in set_room_name_and_topic'
|
228
|
-
end
|
228
|
+
apply_room_name_and_topic new_room
|
229
229
|
end
|
230
230
|
|
231
231
|
@open = open_incidents.size
|
@@ -236,6 +236,27 @@ module Bender
|
|
236
236
|
end
|
237
237
|
|
238
238
|
|
239
|
+
def apply_room_name_and_topic room
|
240
|
+
uri = URI room['links']['self']
|
241
|
+
|
242
|
+
resp = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
243
|
+
req = Net::HTTP::Put.new uri
|
244
|
+
req['Content-Type'] = 'application/json'
|
245
|
+
req['Authorization'] = 'Bearer %s' % options.hipchat_v2_token
|
246
|
+
req.body = {
|
247
|
+
name: room['name'],
|
248
|
+
topic: room['topic'],
|
249
|
+
privacy: room['privacy'],
|
250
|
+
is_archived: room['is_archived'],
|
251
|
+
is_guest_accessible: room['is_guest_accessible'],
|
252
|
+
owner: { id: room['owner']['id'] }
|
253
|
+
}.to_json
|
254
|
+
|
255
|
+
http.request req
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
|
239
260
|
def periodically_refresh_incidents bot
|
240
261
|
Thread.new do
|
241
262
|
if options.order
|
@@ -254,13 +275,8 @@ module Bender
|
|
254
275
|
|
255
276
|
loop do
|
256
277
|
is = refresh_incidents bot
|
257
|
-
|
258
|
-
|
259
|
-
sleep options.issue_refresh
|
260
|
-
rescue HipChat::UnknownResponseCode
|
261
|
-
log.warn 'HipChat::UnknownResponseCode in set_room_name_and_topic'
|
262
|
-
sleep 2
|
263
|
-
end
|
278
|
+
set_room_name_and_topic room_id, is, hipchat_v2, bot
|
279
|
+
sleep options.issue_refresh
|
264
280
|
end
|
265
281
|
end
|
266
282
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bender-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|