forked from github/github-services
/
talker.rb
49 lines (40 loc) · 1 KB
/
talker.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Service::Talker < Service
string :url, :token
boolean :digest
def receive_push
repository = payload['repository']['name']
branch = branch_name
commits = payload['commits']
prepare_http
say "#{summary_message} – #{summary_url}"
if data['digest'].to_i == 0
if distinct_commits.size == 1
commit = distinct_commits.first
say format_commit_message(commit)
else
distinct_commits.each do |commit|
say "#{format_commit_message(commit)} – #{commit['url']}"
end
end
end
end
def receive_pull_request
return unless opened?
prepare_http
say summary_message
end
def receive_issues
return unless opened?
prepare_http
say summary_message
end
private
def prepare_http
http.ssl[:verify] = false
http.headers["X-Talker-Token"] = data['token']
http.url_prefix = data['url']
end
def say(message)
http_post 'messages.json', :message => message
end
end