### Home Classes Methods

### In Files

- lib/rbot/core/utils/wordlist.rb

### Parent

Object

### Methods

- ::exist?
- ::get
- ::list
- ::wordlist_base

### Class/Module Index

Quicksearch

- Irc
- Irc::AsciiCasemap
- Irc::BanlistMessage
- Irc::BasicUserMessage
- Irc::Bot
- Irc::Bot::Auth
- Irc::Bot::Auth::BotOwnerClass
- Irc::Bot::Auth::BotUser
- Irc::Bot::Auth::Command
- Irc::Bot::Auth::DefaultBotUserClass
- Irc::Bot::Auth::InvalidPassword
- Irc::Bot::Auth::ManagerClass
- Irc::Bot::Auth::PermissionSet
- Irc::Bot::Config
- Irc::Bot::Config::ArrayValue
- Irc::Bot::Config::BooleanValue
- Irc::Bot::Config::EnumValue
- Irc::Bot::Config::FloatValue
- Irc::Bot::Config::IntegerValue
- Irc::Bot::Config::ManagerClass
- Irc::Bot::Config::StringValue
- Irc::Bot::Config::Value
- Irc::Bot::Config::Wizard
- Irc::Bot::DataFilter
- Irc::Bot::DataStream
- Irc::Bot::Language
- Irc::Bot::MessageMapper
- Irc::Bot::MessageMapper::Failure
- Irc::Bot::MessageMapper::FriendlyFailure
- Irc::Bot::MessageMapper::NoActionFailure
- Irc::Bot::MessageMapper::NoMatchFailure
- Irc::Bot::MessageMapper::NotPrivateFailure
- Irc::Bot::MessageMapper::NotPublicFailure
- Irc::Bot::MessageMapper::PartialMatchFailure
- Irc::Bot::MessageParameter
- Irc::Bot::MessageTemplate
- Irc::Bot::Plugins
- Irc::Bot::Plugins::BotModule
- Irc::Bot::Plugins::CoreBotModule
- Irc::Bot::Plugins::Plugin
- Irc::Bot::Plugins::PluginManagerClass
- Irc::Bot::Plugins::RecurseTooDeep
- Irc::Bot::Plugins::RemoteBotModule
- Irc::Bot::Plugins::RemoteCoreBotModule
- Irc::Bot::Plugins::RemotePlugin
- Irc::Bot::Registry
- Irc::Bot::Registry::Accessor
- Irc::Bot::RemoteDispatcher
- Irc::Bot::RemoteMessage
- Irc::Bot::RemoteObject
- Irc::Bot::Wordlist
- Irc::BotConfig
- Irc::Casemap
- Irc::Channel
- Irc::Channel::Mode
- Irc::Channel::ModeHash
- Irc::Channel::ModeTypeA
- Irc::Channel::ModeTypeB
- Irc::Channel::ModeTypeC
- Irc::Channel::ModeTypeD
- Irc::Channel::Topic
- Irc::Channel::UserMode
- Irc::ChannelList
- Irc::Client
- Irc::DBHash
- Irc::DBTree
- Irc::InviteMessage
- Irc::JoinMessage
- Irc::KickMessage
- Irc::MessageQueue
- Irc::ModeChangeMessage
- Irc::MotdMessage
- Irc::NamesMessage
- Irc::Netmask
- Irc::NetmaskDb
- Irc::NetmaskDb::Tree
- Irc::NetmaskList
- Irc::NickMessage
- Irc::NoSuchTargetMessage
- Irc::NoticeMessage
- Irc::PartMessage
- Irc::PrivMessage
- Irc::QueueRing
- Irc::QuitMessage
- Irc::RfcCasemap
- Irc::Server
- Irc::ServerOrCasemap
- Irc::Socket
- Irc::Socket::IdentityFilter
- Irc::StrictRfcCasemap
- Irc::TopicMessage
- Irc::UnknownMessage
- Irc::User
- Irc::UserList
- Irc::UserMessage
- Irc::Utils
- Irc::Utils::HttpUtil
- Irc::Utils::HttpUtil::CachedObject
- Irc::Utils::ParseTime
- Irc::WelcomeMessage
- Irc::WhoisMessage
- BDB
- BDB::CIBtree
- MonitorMixin
- MonitorMixin::ConditionVariable
- Net
- Net::HTTPResponse
- Regexp
- Regexp::Irc
- Singleton
- Singleton::SingletonClassMethods
- Timer
- Timer::Action
- TokyoCabinet
- TokyoCabinet::CIBDB
- UnicodePlugin
- UnicodePlugin::UnicodeFilter
- Array
- ArrayOf
- AuthModule
- BasicsModule
- ConditionVariable
- ConfigModule
- DottedIndex
- Enumerable
- Exception
- FiltersModule
- GetText
- GetTextVersionError
- HttpUtilPlugin
- IrcLogModule
- Module
- Numeric
- Object
- Range
- RemoteModule
- ServerError
- String
- Symbol
- UserDataModule
- WordlistModule
- YAML

No matching classes.

# Irc::Bot::Wordlist

### Public Class Methods

exist?(path) click to toggle source

    # File lib/rbot/core/utils/wordlist.rb, line 57
    def self.exist?(path)
      fn = path.to_s
      # refuse to check outside of the wordlist base directory
      return false if fn =~ /\.\.\//
      File.exist?(File.join(self.wordlist_base, fn))
    end

get(path, options={}) click to toggle source

    # File lib/rbot/core/utils/wordlist.rb, line 17
    def self.get(path, options={})
      opts = { :spaces => false }.merge(options)

      wordlist_path = File.join(wordlist_base, path)
      raise "wordlist not found: #{wordlist_path}" unless File.exist?(wordlist_path)

      # Location is a directory -> combine all lists beneath it
      wordlist = if File.directory?(wordlist_path)
        wordlists = []
        Find.find(wordlist_path) do |path|
          next if path == wordlist_path
          wordlists << path unless File.directory?(path)
        end

        wordlists.map { |list| File.readlines(list) }.flatten
      else
        File.readlines(wordlist_path)
      end

      # wordlists are assumed to be UTF-8, but we need to strip the BOM, if present
      wordlist.map! { |l| l.sub("\xef\xbb\xbf",'').strip }
      wordlist.reject do |word|
        word =~ /\s/ && !opts[:spaces] ||
        word.empty?
      end
    end

list(options={}) click to toggle source

Return an array with the list of available wordlists. Available options:

pattern | pattern that should be matched by the wordlist filename

    # File lib/rbot/core/utils/wordlist.rb, line 47
    def self.list(options={})
      pattern = options[:pattern] || "**"
      # refuse patterns that contain ../
      return [] if pattern =~ /\.\.\//
      striplen = self.wordlist_base.length+1
      Dir.glob(File.join(self.wordlist_base, pattern)).map { |name|
        name[striplen..-1]
      }
    end

wordlist_base() click to toggle source

    # File lib/rbot/core/utils/wordlist.rb, line 13
    def self.wordlist_base
      @@wordlist_base ||= Utils.bot.path 'wordlists'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.