9 % rbot [options] [config directory]
14 display a help message and exit
16 display version information and exit
19 [-l, --loglevel _level_]
20 sets the minimum log level verbosity
22 background (daemonize) the bot
23 [-p, --pidfile _filename_]
24 write the bot pid to _filename_
26 The default config directory is <tt>~/.rbot</tt>.
28 The default pidfile is <tt><i>botdir</i>/rbot.pid</tt>.
30 The logfile is located at <tt><i>botdir</i>/<i>botname</i>.log</tt>, and
31 the default loglevel is 1 (INFO messages). Possible values for the loglevel
32 are 0 (DEBUG), 1 (INFO), 2 (WARN), 3 (ERROR), 4 (FATAL).
34 Please note that the logfile doesn't contain IRC logs (which are located at
35 <tt><i>botdir</i>/logs/*</tt>, but only rbot diagnostic messages.
39 # Copyright (C) 2002-2006 Tom Gilbert.
40 # Copyright (C) 2007-2008 Giuseppe Bilotta and the rbot development team
42 # This is free software, see COPYING for licensing details
49 $version_timestamp ||= 0
54 opts = GetoptLong.new(
55 ['--background', '-b', GetoptLong::NO_ARGUMENT],
56 ['--debug', '-d', GetoptLong::NO_ARGUMENT],
57 ['--help', '-h', GetoptLong::NO_ARGUMENT],
58 ['--loglevel', '-l', GetoptLong::REQUIRED_ARGUMENT],
59 ['--trace', '-t', GetoptLong::REQUIRED_ARGUMENT],
60 ['--pidfile', '-p', GetoptLong::REQUIRED_ARGUMENT],
61 ['--version', '-v', GetoptLong::NO_ARGUMENT]
66 opts.each do |opt, arg|
67 $daemonize = true if opt == '--background'
68 $opts[opt.sub(/^-+/, '')] = arg
72 set_trace_func proc { |event, file, line, id, binding, classname|
73 if classname.to_s == $opts['trace']
74 printf "TRACE: %8s %s:%-2d %10s %8s\n", event, File.basename(file), line, id, classname
79 defaultlib = File.expand_path("#{File.dirname($PROGRAM_NAME)}/../lib")
81 if File.directory? "#{defaultlib}/rbot"
82 unless $LOAD_PATH.include? defaultlib
83 $LOAD_PATH.unshift defaultlib
88 Encoding.default_internal = Encoding::UTF_8
89 Encoding.default_external = Encoding::UTF_8
92 puts "Error: couldn't find the rbot/ircbot module (or one of its dependencies)\n"
98 puts "rbot #{$version}"
103 puts 'usage: rbot [options] [config directory]'
104 puts ' -h, --help this message'
105 puts ' -v, --version version information'
106 puts ' -d, --debug enable debug messages'
107 puts ' -l, --loglevel sets the log level verbosity'
108 puts ' -b, --background background (daemonize) the bot'
109 puts ' -p, --pidfile write the bot pid to file'
110 puts 'config directory defaults to ~/.rbot'
114 # setup logger based on command line arguments
115 loglevel = $opts['loglevel'] ? $opts['loglevel'].to_i : nil
116 loglevel = $opts['debug'] ? 0 : loglevel
118 Irc::Bot::LoggerManager.instance.set_level(loglevel)
121 if (bot = Irc::Bot.new(ARGV.shift, argv: orig_opts))
126 Irc::Bot::LoggerManager.instance.flush
127 Irc::Bot::LoggerManager.instance.halt_logger