$dateformat = "%Y/%m/%d %H:%M:%S"
$logger = Logger.new($stderr)
$logger.datetime_format = $dateformat
-$logger.level = $cl_loglevel if $cl_loglevel
+$logger.level = $cl_loglevel if defined? $cl_loglevel
$logger.level = 0 if $debug
require 'pp'
# The following global is used for the improved signal handling.
$interrupted = 0
+require 'rbot/load-gettext'
+
# these first
require 'rbot/rbotconfig'
require 'rbot/config'
:default => [], :wizard => true,
:desc => "What channels the bot should always join at startup. List multiple channels using commas to separate. If a channel requires a password, use a space after the channel name. e.g: '#chan1, #chan2, #secretchan secritpass, #chan3'")
BotConfig.register BotConfigArrayValue.new('irc.ignore_users',
- :default => [],
+ :default => [],
:desc => "Which users to ignore input from. This is mainly to avoid bot-wars triggered by creative people")
BotConfig.register BotConfigIntegerValue.new('core.save_every',
end
# See http://blog.humlab.umu.se/samuel/archives/000107.html
- # for the backgrounding code
+ # for the backgrounding code
if $daemonize
begin
exit if fork
$logger = Logger.new(@logfile, @config['log.keep'], @config['log.max_size']*1024*1024)
$logger.datetime_format= $dateformat
$logger.level = @config['log.level']
- $logger.level = $cl_loglevel if $cl_loglevel
+ $logger.level = $cl_loglevel if defined? $cl_loglevel
$logger.level = 0 if $debug
log_session_start
+ File.open($opts['pidfile'] || "#{@botclass}/rbot.pid", 'w') do |pf|
+ pf << "#{$$}\n"
+ end
+
@registry = BotRegistry.new self
@timer = Timer::Timer.new(1.0) # only need per-second granularity
}
}
@client[:nicktaken] = proc { |data|
- new = "#{data[:nick]}_"
+ new = "#{data[:nick]}_"
nickchg new
# If we're setting our nick at connection because our choice was taken,
# we have to fix our nick manually, because there will be no NICK message
@plugins.delegate "nicktaken", data[:nick]
}
@client[:badnick] = proc {|data|
- arning "bad nick (#{data[:nick]})"
+ warning "bad nick (#{data[:nick]})"
}
@client[:ping] = proc {|data|
sendq "PONG #{data[:pingid]}"
@plugins.delegate("listen", m)
@plugins.delegate("join", m)
+ sendq "WHO #{data[:channel]}", data[:channel], 2
}
@client[:part] = proc {|data|
m = PartMessage.new(self, server, data[:source], data[:channel], data[:message])
quit if $interrupted > 0
realname = @config['irc.name'].clone || 'Ruby bot'
- realname << ' ' + COPYRIGHT_NOTICE if @config['irc.name_copyright']
+ realname << ' ' + COPYRIGHT_NOTICE if @config['irc.name_copyright']
@socket.emergency_puts "PASS " + @config['server.password'] if @config['server.password']
@socket.emergency_puts "NICK #{@config['irc.nick']}\nUSER #{@config['irc.user']} 4 #{@socket.server_uri.host} :#{realname}"