lita-tipbot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06920063e35501d1189c69663b4b2ed45e086599
4
- data.tar.gz: e9e8bb68f06ad1582992b97f7919ea0902f0c0da
3
+ metadata.gz: 859a431c9a77933c570e155163949d68dc414008
4
+ data.tar.gz: e1809b39eb9360a88515c3efab0e84f511bda247
5
5
  SHA512:
6
- metadata.gz: 56a490fb443fd223a6e1a0094d363d3b95366b62ac775842c3ae12b104419839fbea619200aaac71665ffa96432377b7bfc840ac871d2f6ce934f5f431cb9849
7
- data.tar.gz: d182d21450cfb3cff9a4b36428c58de433e6d86b63cba7ec70f2bde5cd04b1f692e7091e3d865ac52dfaa3caf5d9cd8268813739d4575e5e18feb907b3c7707b
6
+ metadata.gz: 9617ea735081584d93662a9242e10befd1d8d44a37019aefbbe976b25647088ce9c927edb75084ff00e179c20cf5c84bffd3566802ceff522ddfced509358e03
7
+ data.tar.gz: be2237048c0ded054733f7cd0644fde59cd40fb033cf84892d85f8f19d2b753201e7f9b310c57d15a246985723d73f58db16d927c04fbbfce1e3cfe8c2c6a8f0
@@ -180,6 +180,9 @@ module Lita
180
180
  users = active_room_members room_jid
181
181
 
182
182
  users.shuffle.each do |user|
183
+ # skip tipper
184
+ next if user['mention_name'] == response.user.mention_name
185
+
183
186
  log.info "tipping #{user['email']}"
184
187
 
185
188
  dest_hash = hash_email user['email']
@@ -232,10 +235,12 @@ module Lita
232
235
  # instead: make one call for all users, then check
233
236
  # to see if each is an active participant
234
237
  def active_room_members(room_jid)
238
+ log.debug "looking up room jid: #{room_jid}"
235
239
  data = room_data(room_jid)
240
+ log.debug "room_data: #{data.inspect}"
236
241
  results = []
237
242
  data['participants'].each do |p|
238
- user = hipchat_api.users_show(p['id'])
243
+ user = hipchat_api.users_show(p['user_id'])
239
244
  next if user['user']['status'] != 'available'
240
245
  next if exclude_user? user['user']
241
246
  results << user['user']
@@ -250,13 +255,15 @@ module Lita
250
255
  def room_data(room_jid)
251
256
  room_id = room_id_from_jid room_jid
252
257
  data = hipchat_api.rooms_show room_id
258
+ log.debug "room #{room_id} data: #{data.inspect}"
253
259
  data['room']
254
260
  end
255
261
 
256
262
  def room_id_from_jid(room_jid)
257
263
  data = hipchat_api.rooms_list
264
+ log.debug "all room data: #{data.inspect}"
258
265
  room = data['rooms'].select {|r| r['xmpp_jid'] == room_jid}.first
259
- room.nil? ? nil : room['id']
266
+ room.nil? ? nil : room['room_id']
260
267
  end
261
268
 
262
269
  end
data/lita-tipbot.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-tipbot"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.2"
4
4
  spec.authors = ["Chris Chalfant"]
5
5
  spec.email = ["chalfants@gmail.com"]
6
6
  spec.description = "Tip people with dogecoins!"
@@ -62,6 +62,37 @@ describe Lita::Handlers::Tipbot, lita_handler: true do
62
62
  expect(replies.first).to eq('foo')
63
63
  end
64
64
 
65
+ describe '#make_it_rain' do
66
+ let(:active_users) {
67
+ [
68
+ {
69
+ 'name' => user.name,
70
+ 'mention_name' => user.mention_name,
71
+ 'email' => 'test@foo.com'
72
+ },
73
+ {
74
+ 'name' => 'someguy',
75
+ 'mention_name' => '@someguy',
76
+ 'email' => 'someguy@foo.com'
77
+ }
78
+ ]
79
+ }
80
+
81
+ before(:each) do
82
+ allow(subject).to receive(:active_room_members).and_return(active_users)
83
+ subject.tipbot_api = double(tip: 'foo')
84
+ send_message("tipbot make it rain")
85
+ end
86
+
87
+ it 'tips a user' do
88
+ expect(replies).to include("A coin for someguy!")
89
+ end
90
+
91
+ it 'does not tip the tipper' do
92
+ expect(replies).to_not include("A coin for #{user.name}")
93
+ end
94
+ end
95
+
65
96
  describe '#hash_email' do
66
97
  it 'hashes properly' do
67
98
  email = 'cchalfant@leafsoftwaresolutions.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-tipbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Chalfant