require 'etc'
require 'getoptlong'
require 'rbot/ircbot'
+require 'fileutils'
+require 'rbconfig'
$debug = true
$version="0.9.8"
$opts[opt.sub(/^-+/, "")] = arg
}
-botclass = ARGV.shift
-user = Etc.getlogin
-botclass = "/home/#{user}/.rbot" unless(botclass);
-
-unless FileTest.directory? botclass
- # TODO copy in samples/templates from install directory
- puts "no #{botclass} directory found, creating from templates.."
- # copy DATA/rbot/templates to botclass
-
-end
-
-if(bot = Irc::IrcBot.new(botclass))
+if(bot = Irc::IrcBot.new(ARGV.shift))
if($opts["help"])
+ # query bot help from the commandline
puts bot.help($opts["help"])
else
- # run the bot
+ # just run the bot
bot.mainloop
end
end
:prompt => "Language",
:key => "core.language",
:type => :enum,
- :items => Dir.new(File.dirname(__FILE__) + "/languages/").collect {|f|
+ :items => Dir.new(@bot.datadir + "/languages").collect {|f|
f =~ /\.lang$/ ? f.gsub(/\.lang$/, "") : nil
}.compact
},
module Irc
class Language
- def initialize(language, file="")
+ def initialize(bot, language, file="")
+ @bot = bot
@language = language
if file.empty?
- file = File.dirname(__FILE__) + "/languages/#{@language}.lang"
+ file = bot.datadir + "/languages/#{@language}.lang"
end
unless(FileTest.exist?(file))
raise "no such language: #{@language} (no such file #{file})"
# load plugins from pre-assigned list of directories
def scan
dirs = Array.new
- dirs << File.dirname(__FILE__) + "/plugins"
+ dirs << @bot.datadir + "/plugins"
dirs += @dirs
dirs.each {|dir|
if(FileTest.directory?(dir))