+ def initialize(botclass, params = {})
+ # BotConfig for the core bot
+ # TODO should we split socket stuff into ircsocket, etc?
+ BotConfig.register BotConfigStringValue.new('server.name',
+ :default => "localhost", :requires_restart => true,
+ :desc => "What server should the bot connect to?",
+ :wizard => true)
+ BotConfig.register BotConfigIntegerValue.new('server.port',
+ :default => 6667, :type => :integer, :requires_restart => true,
+ :desc => "What port should the bot connect to?",
+ :validate => Proc.new {|v| v > 0}, :wizard => true)
+ BotConfig.register BotConfigStringValue.new('server.password',
+ :default => false, :requires_restart => true,
+ :desc => "Password for connecting to this server (if required)",
+ :wizard => true)
+ BotConfig.register BotConfigStringValue.new('server.bindhost',
+ :default => false, :requires_restart => true,
+ :desc => "Specific local host or IP for the bot to bind to (if required)",
+ :wizard => true)
+ BotConfig.register BotConfigIntegerValue.new('server.reconnect_wait',
+ :default => 5, :validate => Proc.new{|v| v >= 0},
+ :desc => "Seconds to wait before attempting to reconnect, on disconnect")
+ BotConfig.register BotConfigFloatValue.new('server.sendq_delay',
+ :default => 2.0, :validate => Proc.new{|v| v >= 0},
+ :desc => "(flood prevention) the delay between sending messages to the server (in seconds)",
+ :on_change => Proc.new {|bot, v| bot.socket.sendq_delay = v })
+ BotConfig.register BotConfigIntegerValue.new('server.sendq_burst',
+ :default => 4, :validate => Proc.new{|v| v >= 0},
+ :desc => "(flood prevention) max lines to burst to the server before throttling. Most ircd's allow bursts of up 5 lines",
+ :on_change => Proc.new {|bot, v| bot.socket.sendq_burst = v })
+ BotConfig.register BotConfigStringValue.new('server.byterate',
+ :default => "400/2", :validate => Proc.new{|v| v.match(/\d+\/\d/)},
+ :desc => "(flood prevention) max bytes/seconds rate to send the server. Most ircd's have limits of 512 bytes/2 seconds",
+ :on_change => Proc.new {|bot, v| bot.socket.byterate = v })
+ BotConfig.register BotConfigIntegerValue.new('server.ping_timeout',
+ :default => 10, :validate => Proc.new{|v| v >= 0},
+ :on_change => Proc.new {|bot, v| bot.start_server_pings},
+ :desc => "reconnect if server doesn't respond to PING within this many seconds (set to 0 to disable)")
+
+ BotConfig.register BotConfigStringValue.new('irc.nick', :default => "rbot",
+ :desc => "IRC nickname the bot should attempt to use", :wizard => true,
+ :on_change => Proc.new{|bot, v| bot.sendq "NICK #{v}" })
+ BotConfig.register BotConfigStringValue.new('irc.user', :default => "rbot",
+ :requires_restart => true,
+ :desc => "local user the bot should appear to be", :wizard => true)
+ BotConfig.register BotConfigArrayValue.new('irc.join_channels',
+ :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 => [],
+ :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',
+ :default => 60, :validate => Proc.new{|v| v >= 0},
+ # TODO change timer via on_change proc
+ :desc => "How often the bot should persist all configuration to disk (in case of a server crash, for example)")
+ # BotConfig.register BotConfigBooleanValue.new('core.debug',
+ # :default => false, :requires_restart => true,
+ # :on_change => Proc.new { |v|
+ # debug ((v ? "Enabling" : "Disabling") + " debug output.")
+ # $debug = v
+ # debug (($debug ? "Enabled" : "Disabled") + " debug output.")
+ # },
+ # :desc => "Should the bot produce debug output?")
+ BotConfig.register BotConfigBooleanValue.new('core.run_as_daemon',
+ :default => false, :requires_restart => true,
+ :desc => "Should the bot run as a daemon?")
+ BotConfig.register BotConfigStringValue.new('core.logfile',
+ :default => false, :requires_restart => true,
+ :desc => "Name of the logfile to which console messages will be redirected when the bot is run as a daemon")
+
+ @argv = params[:argv]
+
+ unless FileTest.directory? Config::datadir
+ error "data directory '#{Config::datadir}' not found, did you setup.rb?"