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 +4 -4
- data/lib/lita/handlers/github_pinger.rb +30 -11
- data/lita-github-pinger.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d12a4430193d253237eac9a65735cdb2f6cfa5
|
4
|
+
data.tar.gz: ce1ca14e173036d664e2596a5fe1b76009a6c45c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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|
|
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
|
-
|
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
|
61
|
+
def find_engineer(slack: nil, github: nil)
|
51
62
|
config.engineers.select do |eng|
|
52
|
-
|
53
|
-
|
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
|
-
|
80
|
+
alert_eng_pr("Could not find user with name #{username}, please configure everbot.")
|
62
81
|
end
|
63
82
|
end
|
64
83
|
end
|
data/lita-github-pinger.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-github-pinger"
|
3
|
-
spec.version = "0.3.
|
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."
|