/usr/bin/rabbirc is in rabbit 2.1.9-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/ruby
# -*- ruby -*-
require 'net/irc'
require 'drb'
require 'nkf'
require "optparse"
require "ostruct"
class RabbIRC < Net::IRC::Client
def initialize(*args)
super
@rabbit = DRb::DRbObject.new_with_uri(@opts.rabbit_uri)
end
def on_rpl_welcome(m)
super
@opts.join_to.each do |channel|
post(JOIN, channel)
end
end
def on_privmsg(m)
channel, message = *m
if @opts.join_to.include?(channel)
begin
@rabbit.append_comment(NKF.nkf('-w', message))
rescue DRb::DRbConnError
@log.error("RABBIT: #{$!.message} (#{$!.class})")
end
end
end
end
options = OpenStruct.new
options.server = "irc.freenode.net"
options.port = 6667
options.nick = 'rabbirc'
options.user = ENV['USER'] || ENV['USERNAME']
options.real = "rabbirc bot"
options.channels = ['#rabbirc']
options.rabbit_uri = 'druby://localhost:10101'
opts = OptionParser.new do |opts|
opts.on("--server=SERVER", "IRC server (#{options.server})") do |server|
options.server = server
end
opts.on("--port=PORT", Integer, "IRC port (#{options.port})") do |port|
options.port = port
end
opts.on("--nick=NAME", "IRC nick name (#{options.nick})") do |nick|
options.nick = nick
end
opts.on("--user=NAME", "IRC user name (#{options.user})") do |user|
options.user = user
end
opts.on("--real=NAME", "IRC real name (#{options.real})") do |real|
options.real = real
end
opts.on("--channels=CHANNEL1,CHANNEL2,...", Array,
"IRC channels to join specified as comma separated list",
"(#{options.channels.inspect})") do |channels|
options.channels = channels
end
opts.on("--rabbit-uri=URI",
"Rabbit's dRuby URI(#{options.rabbit_uri})") do |uri|
options.rabbit_uri = uri
end
end
opts.parse!(ARGV)
rabbirc = RabbIRC.new(options.server, options.port,
:nick => options.nick,
:user => options.user,
:real => options.real,
:join_to => options.channels,
:rabbit_uri => options.rabbit_uri)
rabbirc.start
|