:prompt => "Language",
:key => "core.language",
:type => :enum,
- :items => Dir.new(@bot.datadir + "/languages").collect {|f|
+ :items => Dir.new(CONFIG::DATADIR + "/languages").collect {|f|
f =~ /\.lang$/ ? f.gsub(/\.lang$/, "") : nil
}.compact
},
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'thread'
+require 'etc'
+require 'fileutils'
require 'rbot/rfc2812'
require 'rbot/keywords'
require 'rbot/dbhash'
require 'rbot/registry'
require 'rbot/httputil'
+require 'rbot/rbotconfig'
module Irc
# create a new IrcBot with botclass +botclass+
def initialize(botclass)
+ unless Config::DATA_DIR && FileTest.directory? Config::DATA_DIR
+ puts "no data directory '#{Config::DATA_DIR}' found, did you run install.rb?"
+ exit 2
+ end
+
+ botclass = "/home/#{Etc.getlogin}/.rbot" unless botclass
@botclass = botclass.gsub(/\/$/, "")
- @startup_time = Time.new
+
+ unless FileTest.directory? botclass
+ puts "no #{botclass} directory found, creating from templates.."
+ if FileTest.exist? botclass
+ puts "Error: file #{botclass} exists but isn't a directory"
+ exit 2
+ end
+ FileUtils.cp_r Config::DATA_DIR+'/templates', botclass
+ end
- Dir.mkdir("#{botclass}") if(!File.exist?("#{botclass}"))
Dir.mkdir("#{botclass}/logs") if(!File.exist?("#{botclass}/logs"))
+ @startup_time = Time.new
@config = Irc::BotConfig.new(self)
@timer = Timer::Timer.new
@registry = BotRegistry.new self
module Irc
class Language
- def initialize(bot, language, file="")
- @bot = bot
+ def initialize(language, file="")
@language = language
if file.empty?
- file = bot.datadir + "/languages/#{@language}.lang"
+ file = Config::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 << @bot.datadir + "/plugins"
+ dirs << CONFIG::DATADIR + "/plugins"
dirs += @dirs
dirs.each {|dir|
if(FileTest.directory?(dir))