forked from bitprophet/ghostwheel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathghostwheel.rb
47 lines (35 loc) · 779 Bytes
/
ghostwheel.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'rubygems'
require 'isaac'
require 'trollop'
require 'lib/redmine'
#
# Option parsing
#
opts = Trollop::options do
opt :channels,
"Comma-separated list of channels to join (#s optional)",
:default => "fabfile"
opt :nick,
"Bot nickname",
:default => 'Ghostwheel'
end
opts[:channels] = opts[:channels].split(",").map {|x|
(x =~ /^#/) ? x : "\##{x}"
}
#
# Bot configuration
#
include Redmine
configure do |c|
c.nick = opts[:nick]
c.server = 'irc.freenode.net'
end
on :connect do
join *opts[:channels]
end
on :channel, /\#(\d+)/ do |ticket_id|
uri = "http://code.fabfile.org/issues/show/#{ticket_id}"
subject = ticket_subject uri
reply = "Ticket \##{ticket_id}: #{subject} (#{uri})"
msg(channel, reply) unless subject.nil?
end