Skip to content

Commit 9247d5e

Browse files
sssiongggdefunkt
authored andcommitted
Add Talker support to Github Services.
1 parent 6f24784 commit 9247d5e

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ Thanks to the following people for making this possible
2828
- Grant Limberg
2929
- Jess Martin
3030
- Édouard Brière
31+
- Teng Siong Ong

docs/github_payload

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
{
44
"data" => {
5-
"username" => "foo",
6-
"password" => "bar"
5+
"token" => "token",
6+
"url" => "https://youraccount.talkerapp.com/rooms/ROOM_ID",
7+
"digest" => 1
78
},
89

910
"payload" => {

docs/talker

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Talker
2+
========
3+
4+
Install Notes
5+
-------------
6+
7+
1. url should be your room url, for example https://youraccount.talkerapp.com/rooms/ROOM_ID
8+
2. token should be on your settings page
9+
3. if digest is checked, all commits will be compressed in one message
10+
11+
Note: replace https with http on the url if you're on the Free plan as it doesn't include enhanced security (SSL).
12+
13+
Developer Notes
14+
---------------
15+
16+
data
17+
- url
18+
- token
19+
- digest (boolean)
20+
21+
payload
22+
- refer to docs/github_payload

services/talker.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
service :talker do |data, payload|
2+
repository = payload['repository']['name']
3+
branch = payload['ref'].split('/').last
4+
commits = payload['commits']
5+
token = data['token']
6+
url = URI.parse("#{data['url']}/messages.json")
7+
8+
if data['digest'] == 1
9+
commit = commits.last
10+
message = "[#{repository}/#{branch}] #{commit['message']} (+#{commits.size - 1} more commits...) - #{commit['author']['name']} (#{commit['url']}))"
11+
12+
req = Net::HTTP::Post.new(url.path)
13+
req["X-Talker-Token"] = "#{token}"
14+
req.set_form_data('message' => message)
15+
16+
Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
17+
else
18+
commits.each do |commit|
19+
message = "[#{repository}/#{branch}] #{commit['message']} - #{commit['author']['name']} (#{commit['url']})"
20+
21+
req = Net::HTTP::Post.new(url.path)
22+
req["X-Talker-Token"] = "#{token}"
23+
req.set_form_data('message' => message)
24+
25+
Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy