lita-github-pinger 0.3.8 → 0.3.9

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: 8bacfd86e21e49be2aeaf27442ec4ab2cb195b50
4
- data.tar.gz: 6103685ca7f649f4a4af5dd92cf4a3a900c454da
3
+ metadata.gz: 33d12a4430193d253237eac9a65735cdb2f6cfa5
4
+ data.tar.gz: ce1ca14e173036d664e2596a5fe1b76009a6c45c
5
5
  SHA512:
6
- metadata.gz: 12414a7712309ea09cbf18f3f656b3db812454f65e7f722510a56561a2ec9e69daccf5ab320c4726528e9cb3e15ddb24d933ba41330df17b79f52b2308594ae2
7
- data.tar.gz: 96edd8cf33e0c24e30f23145b09820e7bee3badf8ed806f35bce255e0bcb2fcfe4fe2f3cf658b2b08ebb91dafc747e79f748e3b7052ca345a6773f588c8a83eb
6
+ metadata.gz: c46a08c0045397962ac8f40b101aa4df2c9a3cfd819d2a4c58ba6908744d6059148949edde87cbd5543c07400a421f34d21600bce0cf92c78b54b03a7d9463ab
7
+ data.tar.gz: 0240b620b9a96e61ef1434a4b158584238cc5b200a49dc36ef9408c1392351dc6f41cba19c4bc93227f1bbbff4ef6b09212a497f48ace40b6fd3adc3c971be85
@@ -13,7 +13,7 @@ module Lita
13
13
  thing = body["pull_request"] || body["issue"]
14
14
  pr_url = thing["html_url"]
15
15
  comment = body["comment"]["body"]
16
- commenter = body["comment"]["user"]["login"]
16
+ commenter = github_to_slack_username(body["comment"]["user"]["login"])
17
17
 
18
18
  # automatically include the creator of the PR
19
19
  usernames_to_ping = [thing["user"]["login"]]
@@ -27,30 +27,49 @@ module Lita
27
27
  usernames_to_ping = usernames_to_ping.concat(mentions).uniq
28
28
 
29
29
  # slackify all of the users
30
- usernames_to_ping.map! { |user| github_username_to_slack_username(user) }
30
+ usernames_to_ping.map! { |user| github_to_slack_username(user) }
31
31
  end
32
32
 
33
- message = "New PR comment from #{commenter}:\n"
34
- message += "#{pr_url}\n#{comment}"
35
-
36
33
  puts "Got a comment on something, sending messages to #{usernames_to_ping}"
34
+ usernames_to_ping.each do |user|
35
+
36
+ pref = find_engineer(slack: user)[:preference]
37
+ case pref
38
+ when "off" return
39
+ when "dm", nil
40
+ private_message = "New PR comment from @#{commenter}:\n"
41
+ private_message += "#{pr_url}\n#{comment}"
42
+ send_dm(user, private_message)
43
+ when "eng-pr", "eng_pr"
44
+ public_message = "@#{user}, new PR mention: "
45
+ public_message += "#{pr_url}\n#{comment}" if user == usernames_to_ping.last
46
+ alert_eng_pr(public_message)
47
+ end
37
48
 
38
- usernames_to_ping.each { |user| send_dm(user, message) }
49
+ end
39
50
  end
40
51
 
41
52
  response
42
53
  end
43
54
 
44
55
  def alert_eng_pr(message)
45
- room = Lita::Room.fuzzy_find("eng")
56
+ room = Lita::Room.fuzzy_find("eng-pr")
46
57
  source = Lita::Source.new(room: room)
47
58
  robot.send_message(source, message)
48
59
  end
49
60
 
50
- def github_username_to_slack_username(github_username)
61
+ def find_engineer(slack: nil, github: nil)
51
62
  config.engineers.select do |eng|
52
- eng[:github] == github_username
53
- end.first[:slack]
63
+ if slack
64
+ eng[:github] == slack
65
+ elsif github
66
+ eng[:github] == github
67
+ end
68
+ end.first
69
+ end
70
+
71
+ def github_to_slack_username(github_username)
72
+ find_engineer(github: github_username)[:slack]
54
73
  end
55
74
 
56
75
  def send_dm(username, content)
@@ -58,7 +77,7 @@ module Lita
58
77
  source = Lita::Source.new(user: user)
59
78
  robot.send_message(source, content)
60
79
  else
61
- puts "Could not find user with name #{username}"
80
+ alert_eng_pr("Could not find user with name #{username}, please configure everbot.")
62
81
  end
63
82
  end
64
83
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-github-pinger"
3
- spec.version = "0.3.8"
3
+ spec.version = "0.3.9"
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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre