-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathghostwheel.rb
59 lines (44 loc) · 977 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
48
49
50
51
52
53
54
55
56
57
58
59
require 'rubygems'
require 'logger'
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
logfile = open 'irc.log', 'a'
logfile.sync = true
logger = Logger.new logfile
configure do |c|
c.nick = opts[:nick]
c.server = 'irc.freenode.net'
end
on :connect do
join *opts[:channels]
logger.info "#" * 20
logger.info "Connected!"
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
on :channel do
logger.debug message.inspect
end