]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rework various modules to use the installed directories
authorTom Gilbert <tom@linuxbrit.co.uk>
Wed, 27 Jul 2005 16:49:34 +0000 (16:49 +0000)
committerTom Gilbert <tom@linuxbrit.co.uk>
Wed, 27 Jul 2005 16:49:34 +0000 (16:49 +0000)
bin/rbot
lib/rbot/config.rb
lib/rbot/language.rb
lib/rbot/plugins.rb

index 9b0de6775454d61f46fded6737b3a79cebb17449..c46b9571051601b34ec8657717494f0a91136b22 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -26,6 +26,8 @@ $VERBOSE=true
 require 'etc'
 require 'getoptlong'
 require 'rbot/ircbot'
+require 'fileutils'
+require 'rbconfig'
 
 $debug = true
 $version="0.9.8"
@@ -47,22 +49,12 @@ opts.each {|opt, arg|
   $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
index 971a413c45f62838fedf28f15a2420dee42ff6ef..f021d8271c8545c82d39351aa10819f968e61044 100644 (file)
@@ -143,7 +143,7 @@ module Irc
           :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
         },
index 9788b2bb4908e63e2b09c3a80704b63e25888465..75885a51def9a95fe58270ec2926202e3afe61aa 100644 (file)
@@ -1,10 +1,11 @@
 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})"
index 5db047fba88b8275e48eec952daea70385a92579..d239c5e6bfcd3626ac911e7f4ce6b3c164e7d4dc 100644 (file)
@@ -170,7 +170,7 @@ module Irc
     # 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))