# File rbot/keywords.rb, line 119
    def scan
      # first scan for old DBHash files, and convert them
      Dir["#{@bot.botclass}/keywords/*"].each {|f|
        next unless f =~ /\.db$/
        puts "upgrading keyword db #{f} (rbot 0.9.5 or prior) database format"
        newname = f.gsub(/\.db$/, ".kdb")
        old = BDB::Hash.open f, nil, 
                             "r+", 0600, "set_pagesize" => 1024,
                             "set_cachesize" => [0, 32 * 1024, 0]
        new = BDB::CIBtree.open newname, nil, 
                                BDB::CREATE | BDB::EXCL | BDB::TRUNCATE,
                                0600, "set_pagesize" => 1024,
                                "set_cachesize" => [0, 32 * 1024, 0]
        old.each {|k,v|
          new[k] = v
        }
        old.close
        new.close
        File.delete(f)
      }
      
      # then scan for current DBTree files, and load them
      Dir["#{@bot.botclass}/keywords/*"].each {|f|
        next unless f =~ /\.kdb$/
        hsh = DBTree.new @bot, f, true
        key = File.basename(f).gsub(/\.kdb$/, "")
        debug "keywords module: loading DBTree file #{f}, key #{key}"
        @statickeywords[key] = hsh
      }
      
      # then scan for non DB files, and convert/import them and delete
      Dir["#{@bot.botclass}/keywords/*"].each {|f|
        next if f =~ /\.kdb$/
        puts "auto converting keywords from #{f}"
        key = File.basename(f)
        unless @statickeywords.has_key?(key)
          @statickeywords[key] = DBHash.new @bot, "#{f}.db", true
        end
        IO.foreach(f) {|line|
          if(line =~ /^(.*?)\s*<?=(is|are)?=?>\s*(.*)$/)
            lhs = $1
            mhs = $2
            rhs = $3
            # support infobot style factfiles, by fixing them up here
            rhs.gsub!(/\$who/, "<who>")
            mhs = "is" unless mhs
            rhs = Keyword.escape rhs
            values = rhs.split("<=or=>")
            @statickeywords[key][lhs] = Keyword.new(mhs, values).dump
          end
        }
        File.delete(f)
        @statickeywords[key].flush
      }
    end