agig 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/agig.gemspec +1 -1
- data/lib/agig/session.rb +23 -25
- data/lib/agig/version.rb +1 -1
- metadata +61 -49
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Agig is another Github IRC Gateway, forked cho45's [gig.rb](https://github.com/cho45/net-irc/blob/master/examples/gig.rb)
|
4
4
|
|
5
|
+
Modified from original gig.rb:
|
6
|
+
|
7
|
+
* use Nokogiri instead of libxml-ruby
|
8
|
+
* use open-uri instead of net/https
|
9
|
+
* create new channel, it includes user activities.
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
data/agig.gemspec
CHANGED
data/lib/agig/session.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'net/irc'
|
3
|
-
require '
|
4
|
-
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
require 'open-uri'
|
5
6
|
require 'ostruct'
|
6
7
|
require 'time'
|
7
8
|
|
@@ -16,6 +17,13 @@ class Agig::Session < Net::IRC::Server::Session
|
|
16
17
|
'PushEvent' => '14',
|
17
18
|
}
|
18
19
|
|
20
|
+
ACTIVITIES = %w(
|
21
|
+
GistEvent
|
22
|
+
ForkEvent
|
23
|
+
FollowEvent
|
24
|
+
WatchEvent
|
25
|
+
)
|
26
|
+
|
19
27
|
def server_name
|
20
28
|
"github"
|
21
29
|
end
|
@@ -31,8 +39,6 @@ class Agig::Session < Net::IRC::Server::Session
|
|
31
39
|
def initialize(*args)
|
32
40
|
super
|
33
41
|
@last_retrieved = Time.now
|
34
|
-
@cert_store = OpenSSL::X509::Store.new
|
35
|
-
@cert_store.set_default_paths
|
36
42
|
end
|
37
43
|
|
38
44
|
def on_disconnected
|
@@ -41,6 +47,7 @@ class Agig::Session < Net::IRC::Server::Session
|
|
41
47
|
|
42
48
|
def on_user(m)
|
43
49
|
super
|
50
|
+
|
44
51
|
@real, *@opts = @real.split(/\s+/)
|
45
52
|
@opts = OpenStruct.new @opts.inject({}) {|r, i|
|
46
53
|
key, value = i.split("=", 2)
|
@@ -51,38 +58,29 @@ class Agig::Session < Net::IRC::Server::Session
|
|
51
58
|
else value
|
52
59
|
end
|
53
60
|
}
|
54
|
-
post @nick, JOIN,
|
61
|
+
[main_channel, '#activity'].each {|c| post @nick, JOIN, c }
|
55
62
|
|
56
63
|
@retrieve_thread = Thread.start do
|
57
64
|
loop do
|
58
65
|
begin
|
59
66
|
@log.info 'retrieveing feed...'
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
ns = %w|a:http://www.w3.org/2005/Atom|
|
70
|
-
entries = []
|
71
|
-
doc.find('/a:feed/a:entry', ns).each do |n|
|
72
|
-
entries << {
|
73
|
-
:datetime => Time.parse(n.find('string(a:published)', ns)),
|
74
|
-
:id => n.find('string(a:id)', ns),
|
75
|
-
:title => n.find('string(a:title)', ns),
|
76
|
-
:author => n.find('string(a:author/a:name)', ns),
|
77
|
-
:link => n.find('string(a:link/@href)', ns),
|
67
|
+
atom = open("https://github.com/#{@real}.private.atom?token=#{@pass}").read
|
68
|
+
ns = {'a' => 'http://www.w3.org/2005/Atom'}
|
69
|
+
entries = Nokogiri::XML(atom).xpath('/a:feed/a:entry', ns).map do |entry|
|
70
|
+
{
|
71
|
+
:datetime => Time.parse(entry.xpath('string(a:published)', ns)),
|
72
|
+
:id => entry.xpath('string(a:id)', ns),
|
73
|
+
:title => entry.xpath('string(a:title)', ns),
|
74
|
+
:author => entry.xpath('string(a:author/a:name)', ns),
|
75
|
+
:link => entry.xpath('string(a:link/@href)', ns),
|
78
76
|
}
|
79
77
|
end
|
80
78
|
|
81
79
|
entries.reverse_each do |entry|
|
82
80
|
next if entry[:datetime] <= @last_retrieved
|
83
81
|
type = entry[:id][%r|tag:github.com,2008:(.+?)/\d+|, 1]
|
84
|
-
|
85
|
-
"\003#{EVENTS[type] || '5'}#{entry[:title]}\017 \00314#{entry[:link]}\017"
|
82
|
+
channel = ACTIVITIES.include? type ? '#activity' : main_channel
|
83
|
+
post entry[:author], PRIVMSG, channel, "\003#{EVENTS[type] || '5'}#{entry[:title]}\017 \00314#{entry[:link]}\017"
|
86
84
|
end
|
87
85
|
|
88
86
|
@last_retrieved = entries.first[:datetime]
|
data/lib/agig/version.rb
CHANGED
metadata
CHANGED
@@ -1,56 +1,60 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: agig
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- SHIBATA Hiroshi
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-03-31 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: net-irc
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
38
32
|
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: nokogiri
|
39
36
|
prerelease: false
|
40
|
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
46
48
|
description: another Github IRC Gateway
|
47
|
-
email:
|
49
|
+
email:
|
48
50
|
- shibata.hiroshi@gmail.com
|
49
|
-
executables:
|
51
|
+
executables:
|
50
52
|
- agig
|
51
53
|
extensions: []
|
54
|
+
|
52
55
|
extra_rdoc_files: []
|
53
|
-
|
56
|
+
|
57
|
+
files:
|
54
58
|
- .gitignore
|
55
59
|
- Gemfile
|
56
60
|
- LICENSE
|
@@ -65,28 +69,36 @@ files:
|
|
65
69
|
- lib/agig/version.rb
|
66
70
|
homepage: https://github.com/hsbt/agig
|
67
71
|
licenses: []
|
72
|
+
|
68
73
|
post_install_message:
|
69
74
|
rdoc_options: []
|
70
|
-
|
75
|
+
|
76
|
+
require_paths:
|
71
77
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
79
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
88
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
84
96
|
requirements: []
|
97
|
+
|
85
98
|
rubyforge_project:
|
86
99
|
rubygems_version: 1.8.21
|
87
100
|
signing_key:
|
88
101
|
specification_version: 3
|
89
|
-
summary: agig is another Github IRC Gateway. agig is forked from gig.rb, and contained
|
90
|
-
net-irc gems.
|
102
|
+
summary: agig is another Github IRC Gateway. agig is forked from gig.rb, and contained net-irc gems.
|
91
103
|
test_files: []
|
92
|
-
|
104
|
+
|