lita-github-pinger 0.3.6 → 0.3.7

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: edb3e251d49bce421fdbb52dac861ee107d11f1b
4
- data.tar.gz: f51cbd8c58841d51a56c82c95b5d2c96743de0fc
3
+ metadata.gz: 532eb6b451efd5fedee4eecbbbffe2b942701704
4
+ data.tar.gz: c0de7f549078d94d25e5f021b9d0131957d2e120
5
5
  SHA512:
6
- metadata.gz: ec3b49c4cc4340f7100230aa5b7d9ce5fb176cdd7f4d54d94e60be11f5010b6e1555b7a8613d9a7c70df67946fa6268f929a11c570aa7459577c5d7e4e8812de
7
- data.tar.gz: 8e40199e6bb6ea34c61019b22cae6cbb051c62137699d453d20f71544b0f7fcc871b2651ade1f870bd7b8d012c70423011d769508442348b36fd5e85baf2a6f9
6
+ metadata.gz: 9ad21d6f34d595e9f50a1a099cae63b248ac52316c1c8c977534ded78c1a301dff9b9fb54bb66cc8a8ed461202cdc0baa41abec7c703b4009370ed4d321a1875
7
+ data.tar.gz: ac6abe1e6963aea188aa9fadf88c735732d668dfe4175ba459816f73dbd704f0620b1f248b8c1bddc6816da3c294d623e4491b86ba7240f9a1236f8ac4878945
@@ -12,32 +12,34 @@ module Lita
12
12
  body = MultiJson.load(request.body)
13
13
 
14
14
  if body["comment"]
15
+ thing = body["pull_request"] || body["issue"]
16
+ pr_url = thing["html_url"]
17
+ comment = body["comment"]["body"]
18
+ commenter = body["comment"]["user"]["login"]
15
19
 
16
- thing = body["pull_request"] || body["issue"]
20
+ # automatically include the creator of the PR
21
+ usernames_to_ping = [thing["user"]["login"]]
17
22
 
18
- pr_url = thing["html_url"]
19
- pr_owner = thing["user"]["login"]
20
- commenter = body["comment"]["user"]["login"]
21
- comment = body["comment"]["body"].split("\n").join("\n >")
23
+ # Is anyone mentioned in this comment?
24
+ if comment.include?("@")
25
+ # get each @mentioned username in the comment
26
+ mentions = comment.split("@")[1..-1].map { |snip| snip.split(" ").first }
22
27
 
23
- pr_owner = config.engineers.select do |eng|
24
- eng[:github] == pr_owner
25
- end.first[:slack]
28
+ # add them to the list of usernames to ping
29
+ usernames_to_ping = usernames_to_ping.concat(mentions).uniq
26
30
 
27
- commenter = config.engineers.select do |eng|
28
- eng[:github] == commenter
29
- end.first[:slack]
31
+ # slackify all of the users
32
+ usernames_to_ping.map! { |user| github_username_to_slack_username(user) }
33
+ end
30
34
 
31
35
  message = "New PR comment from #{commenter}:\n"
32
- message += "#{pr_url}\n> #{comment}"
33
-
34
- puts "Got a comment on something, sending message to #{pr_owner}"
36
+ message += "#{pr_url}\n#{comment}"
35
37
 
36
- send_dm(pr_owner, message)
38
+ puts "Got a comment on something, sending messages to #{usernames_to_ping}"
37
39
 
40
+ usernames_to_ping.each { |user| send_dm(user, message) }
38
41
  end
39
42
 
40
-
41
43
  response
42
44
  end
43
45
 
@@ -47,6 +49,12 @@ module Lita
47
49
  robot.send_message(source, message)
48
50
  end
49
51
 
52
+ def github_username_to_slack_username(github_username)
53
+ config.engineers.select do |eng|
54
+ eng[:github] == github_username
55
+ end.first[:slack]
56
+ end
57
+
50
58
  def send_dm(username, content)
51
59
  if user = Lita::User.fuzzy_find(username)
52
60
  source = Lita::Source.new(user: user)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-github-pinger"
3
- spec.version = "0.3.6"
3
+ spec.version = "0.3.7"
4
4
  spec.authors = ["Taylor Lapeyre"]
5
5
  spec.email = ["taylorlapeyre@gmail.com"]
6
6
  spec.description = "A Lita handler that detects github comment notifications and regurgitates a ping to the correct slack username."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-github-pinger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre