forked from github/github-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yammer.rb
27 lines (23 loc) · 1019 Bytes
/
yammer.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
service :yammer do |data, payload|
statuses = [ ]
repository = payload['repository']['name']
if data['digest'] == '1'
commit = payload['commits'][-1]
tiny_url = shorten_url(payload['repository']['url'] + '/commits/' + payload['ref_name'])
statuses << "@#{commit['author']['name']} pushed #{payload['commits'].length}. #{tiny_url} \##{repository}"
else
payload['commits'].each do |commit|
tiny_url = shorten_url(commit['url'])
statuses << "#{commit['message']} (committer: @#{commit['author']['name']}) #{tiny_url} \##{repository}"
end
end
yammer = Yammer::Client.new(:consumer =>
{:key => data['consumer_key'],
:secret => data['consumer_secret']},
:access =>
{:token => data['access_token'],
:secret => data['access_secret']})
statuses.each do |status|
yammer.message(:post, :body => status)
end
end