post2irc 0.0.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +24 -3
- data/bin/post2irc +2 -2
- data/lib/post2irc/sinatra_listener.rb +12 -3
- data/lib/post2irc/version.rb +1 -1
- metadata +8 -8
data/README.textile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Post2irc gem by by javier ramirez
|
2
|
+
|
2
3
|
======================================
|
3
4
|
|
4
|
-
This gem will start a sinatra script that will listen to posts and will publish the contents to an irc channel.
|
5
|
+
This gem will start a sinatra script that will listen to posts and will publish the contents to an irc channel. Simple authentication via a secret token in the URL is provided
|
5
6
|
|
6
7
|
You can just install the gem and run the provided post2irc command with appropriate parameters
|
7
8
|
|
@@ -14,13 +15,33 @@ The local webserver would listen on the 0.0.0.0 interface at port 8080
|
|
14
15
|
|
15
16
|
Now you can issue a post like this
|
16
17
|
|
17
|
-
curl -X POST http://localhost:8080?q=hi
|
18
|
+
curl -X POST http://localhost:8080/public?q=hi
|
18
19
|
|
19
20
|
and you should see the bot saying "hi" on IRC
|
20
21
|
|
21
22
|
|
22
23
|
There is a built-in service hook for bitbucket, so you can receive alerts of your commits on irc. Go to the admin of your bitbucket repository, look for services and select the POST service. Now just enter this value for the URL
|
23
|
-
|
24
|
+
|
25
|
+
http://your_url:8080/public/sources/bitbucket/service
|
24
26
|
|
25
27
|
Of course both the url and port must be accessible from the internet
|
26
28
|
|
29
|
+
|
30
|
+
Authentication
|
31
|
+
|
32
|
+
========================
|
33
|
+
|
34
|
+
If you want to authenticate the request, there is a basic mechanism built in. You can pass an extra parameter when starting the server and it will be used in the url instead of /public. For example
|
35
|
+
|
36
|
+
post2irc "irc.freenode.net" "6667" "#your_channel" "nickname" "0.0.0.0" "8080" "supersecr3t"
|
37
|
+
|
38
|
+
Would respond to POSTs sent to the following URLs
|
39
|
+
|
40
|
+
http://localhost:8080/supersecr3t
|
41
|
+
|
42
|
+
|
43
|
+
http://your_url:8080/supersecr3t/sources/bitbucket/service
|
44
|
+
|
45
|
+
|
46
|
+
Take into account the secret is part of the URL, so unless you are using https it's not really that secure, but still better than nothing and easy to integrate with external tools
|
47
|
+
|
data/bin/post2irc
CHANGED
@@ -15,8 +15,8 @@ rescue LoadError => e
|
|
15
15
|
require 'post2irc'
|
16
16
|
end
|
17
17
|
|
18
|
-
irc_server, irc_port, irc_channels, irc_nickname, sinatra_bind, sinatra_port = ARGV
|
18
|
+
irc_server, irc_port, irc_channels, irc_nickname, sinatra_bind, sinatra_port, secret = ARGV
|
19
19
|
|
20
20
|
Ircbot.start irc_server, irc_port, irc_channels, irc_nickname
|
21
|
-
SinatraListener.start sinatra_bind, sinatra_port
|
21
|
+
SinatraListener.start sinatra_bind, sinatra_port, secret
|
22
22
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
|
2
2
|
class SinatraListener < Sinatra::Base
|
3
|
-
|
3
|
+
UNAUTHORIZED = [ 401, 'unauthorized']
|
4
|
+
|
5
|
+
def self.start(bind='0.0.0.0',port='4567',token='public')
|
6
|
+
@@token = token
|
4
7
|
configure :production, :development do
|
5
8
|
enable :logging
|
6
9
|
set :port, port
|
@@ -14,11 +17,17 @@ class SinatraListener < Sinatra::Base
|
|
14
17
|
message.gsub /[^[:print:]]/m, "."
|
15
18
|
end
|
16
19
|
|
17
|
-
|
20
|
+
def authorized?(prefix)
|
21
|
+
@@token == prefix
|
22
|
+
end
|
23
|
+
|
24
|
+
post "/:prefix" do
|
25
|
+
return UNAUTHORIZED unless authorized?(params[:prefix])
|
18
26
|
Ircbot.report string_cleaner(params[:q])
|
19
27
|
end
|
20
28
|
|
21
|
-
post "/sources/bitbucket/service" do
|
29
|
+
post "/:prefix/sources/bitbucket/service" do
|
30
|
+
return UNAUTHORIZED unless authorized?(params[:prefix])
|
22
31
|
unless params[:payload].nil?
|
23
32
|
payload=JSON.parse params[:payload]
|
24
33
|
puts payload
|
data/lib/post2irc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: post2irc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &71760210 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *71760210
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cinch
|
27
|
-
requirement: &
|
27
|
+
requirement: &71758950 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *71758950
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &71758330 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *71758330
|
47
47
|
description: This gem will start a sinatra script that will listen to posts and will
|
48
48
|
publish the contents to an irc channel. No authentication is provided.
|
49
49
|
email:
|