agig 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/agig/session.rb +18 -9
  2. data/lib/agig/version.rb +1 -1
  3. metadata +3 -3
@@ -17,12 +17,14 @@ class Agig::Session < Net::IRC::Server::Session
17
17
  'PushEvent' => '14',
18
18
  }
19
19
 
20
- ACTIVITIES = %w(
21
- GistEvent
22
- ForkEvent
23
- FollowEvent
24
- WatchEvent
25
- )
20
+ CHANNEL_SELECTOR = {
21
+ 'GistEvent' => '#activity',
22
+ 'ForkEvent' => '#activity',
23
+ 'FollowEvent' => '#activity',
24
+ 'WatchEvent' => '#activity',
25
+ 'PullRequestEvent' => '#pull_requests',
26
+ 'PullRequestReviewCommentEvent' => '#pull_requests',
27
+ }
26
28
 
27
29
  def server_name
28
30
  "github"
@@ -36,6 +38,14 @@ class Agig::Session < Net::IRC::Server::Session
36
38
  @opts.main_channel || "#github"
37
39
  end
38
40
 
41
+ def channels
42
+ CHANNEL_SELECTOR.values.uniq << main_channel
43
+ end
44
+
45
+ def channel(type)
46
+ CHANNEL_SELECTOR[type] || main_channel
47
+ end
48
+
39
49
  def initialize(*args)
40
50
  super
41
51
  @last_retrieved = Time.now
@@ -58,7 +68,7 @@ class Agig::Session < Net::IRC::Server::Session
58
68
  else value
59
69
  end
60
70
  }
61
- [main_channel, '#activity'].each {|c| post @nick, JOIN, c }
71
+ channels.each {|c| post @nick, JOIN, c }
62
72
 
63
73
  @retrieve_thread = Thread.start do
64
74
  loop do
@@ -79,8 +89,7 @@ class Agig::Session < Net::IRC::Server::Session
79
89
  entries.reverse_each do |entry|
80
90
  next if entry[:datetime] <= @last_retrieved
81
91
  type = entry[:id][%r|tag:github.com,2008:(.+?)/\d+|, 1]
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"
92
+ post entry[:author], PRIVMSG, channel(type), "\003#{EVENTS[type] || '5'}#{entry[:title]}\017 \00314#{entry[:link]}\017"
84
93
  end
85
94
 
86
95
  @last_retrieved = entries.first[:datetime]
@@ -1,3 +1,3 @@
1
1
  module Agig
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-irc
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 1.8.21
86
+ rubygems_version: 1.8.23
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: agig is another Github IRC Gateway. agig is forked from gig.rb, and contained