post2irc 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -2
- data/README.textile +26 -0
- data/bin/post2irc +2 -0
- data/lib/post2irc/sinatra_listener.rb +19 -1
- data/lib/post2irc/version.rb +1 -1
- data/lib/post2irc.rb +1 -0
- data/pkg/post2irc-0.0.2.gem +0 -0
- data/post2irc.gemspec +1 -1
- metadata +10 -8
data/Gemfile.lock
CHANGED
data/README.textile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Post2irc gem by by javier ramirez
|
2
|
+
======================================
|
3
|
+
|
4
|
+
This gem will start a sinatra script that will listen to posts and will publish the contents to an irc channel. No authentication is provided.
|
5
|
+
|
6
|
+
You can just install the gem and run the provided post2irc command with appropriate parameters
|
7
|
+
|
8
|
+
post2irc "irc.freenode.net" "6667" "#your_channel" "nickname" "0.0.0.0" "8080"
|
9
|
+
|
10
|
+
|
11
|
+
This would connect to the irc server "irc.freenode.net" at port 6667 entering the channel "#your_channel" using the nickname "nickname"
|
12
|
+
|
13
|
+
The local webserver would listen on the 0.0.0.0 interface at port 8080
|
14
|
+
|
15
|
+
Now you can issue a post like this
|
16
|
+
|
17
|
+
curl -X POST http://localhost:8080?q=hi
|
18
|
+
|
19
|
+
and you should see the bot saying "hi" on IRC
|
20
|
+
|
21
|
+
|
22
|
+
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
|
+
http://your_url:8080/sources/bitbucket/service
|
24
|
+
|
25
|
+
Of course both the url and port must be accessible from the internet
|
26
|
+
|
data/bin/post2irc
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
begin
|
4
4
|
require 'cinch'
|
5
5
|
require 'sinatra'
|
6
|
+
require 'json'
|
6
7
|
require 'post2irc'
|
7
8
|
rescue LoadError => e
|
8
9
|
require 'rubygems'
|
@@ -10,6 +11,7 @@ rescue LoadError => e
|
|
10
11
|
$:.unshift(path) if File.directory?(path) && !$:.include?(path)
|
11
12
|
require 'cinch'
|
12
13
|
require 'sinatra'
|
14
|
+
require 'json'
|
13
15
|
require 'post2irc'
|
14
16
|
end
|
15
17
|
|
@@ -9,8 +9,26 @@ class SinatraListener < Sinatra::Base
|
|
9
9
|
self.run!
|
10
10
|
end
|
11
11
|
|
12
|
+
def string_cleaner(message)
|
13
|
+
#remove all non printable characters and replace with a dot
|
14
|
+
message.gsub /[^[:print:]]/m, "."
|
15
|
+
end
|
16
|
+
|
12
17
|
post "/" do
|
13
|
-
Ircbot.report params[:q]
|
18
|
+
Ircbot.report string_cleaner(params[:q])
|
19
|
+
end
|
20
|
+
|
21
|
+
post "/sources/bitbucket/service" do
|
22
|
+
unless params[:payload].nil?
|
23
|
+
payload=JSON.parse params[:payload]
|
24
|
+
puts payload
|
25
|
+
messages_authors=payload['commits'].map{|c| "#{c['message']} (#{c['author']})"}.join(',') rescue nil
|
26
|
+
base_uri=payload['canon_url']
|
27
|
+
repository_uri=payload['repository']['absolute_url']
|
28
|
+
repository_name=payload['repository']['name']
|
29
|
+
|
30
|
+
Ircbot.report string_cleaner( [repository_name, messages_authors, "#{base_uri}#{repository_uri}"].compact.join(' :: ') )
|
31
|
+
end
|
14
32
|
end
|
15
33
|
end
|
16
34
|
|
data/lib/post2irc/version.rb
CHANGED
data/lib/post2irc.rb
CHANGED
Binary file
|
data/post2irc.gemspec
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.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-08-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &74975570 !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: *74975570
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cinch
|
27
|
-
requirement: &
|
27
|
+
requirement: &74974310 !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: *74974310
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: json
|
38
|
+
requirement: &74973690 !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: *74973690
|
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:
|
@@ -55,6 +55,7 @@ extra_rdoc_files: []
|
|
55
55
|
files:
|
56
56
|
- Gemfile
|
57
57
|
- Gemfile.lock
|
58
|
+
- README.textile
|
58
59
|
- Rakefile
|
59
60
|
- bin/post2irc
|
60
61
|
- lib/post2irc.rb
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/post2irc/sinatra_listener.rb
|
63
64
|
- lib/post2irc/version.rb
|
64
65
|
- pkg/post2irc-0.0.1.gem
|
66
|
+
- pkg/post2irc-0.0.2.gem
|
65
67
|
- post2irc.gemspec
|
66
68
|
homepage: http://javier-ramirez.com
|
67
69
|
licenses: []
|