lib/chatterbot/dsl.rb
def bot
      return @bot unless @bot.nil?

      @bot_command = nil
      
      #
      # parse any command-line options and use them to initialize the bot
      #
      params = {}

      #:nocov:
      opts = OptionParser.new

      opts.banner = "Usage: #{File.basename($0)} [options]"

      opts.separator ""
      opts.separator "Specific options:"


      opts.on('-c', '--config [ARG]', "Specify a config file to use")    { |c| ENV["chatterbot_config"] = c }
      opts.on('-t', '--test', "Run the bot without actually sending any tweets") { params[:debug_mode] = true }
      opts.on('-v', '--verbose', "verbose output to stdout")    { params[:verbose] = true }
      opts.on('--dry-run', "Run the bot in test mode, and also don't update the database")    { params[:debug_mode] = true ; params[:no_update] = true }

      opts.on('-r', '--reset', "Reset your bot to ignore old tweets") {
        @bot_command = :reset_since_id_counters
      }

      opts.on('--profile [ARG]', "get/set your bot's profile text") { |p| 
        @bot_command = :profile_text
        @bot_command_args = [ p ]
      }

      opts.on('--website [ARG]', "get/set your bot's profile URL") { |u| 
        @bot_command = :profile_website
        @bot_command_args = [ u ]
      }
      
      opts.on_tail("-h", "--help", "Show this message") do
        puts opts
        exit
      end

      opts.parse!(ARGV)
      #:nocov:

      @bot = Chatterbot::Bot.new(params)
      if @bot_command != nil
        @bot.skip_run = true
        result = @bot.send(@bot_command, *@bot_command_args)
        puts result
      end

      @bot
    end
def bot
      return @bot unless @bot.nil?

      @bot_command = nil
      
      #
      # parse any command-line options and use them to initialize the bot
      #
      params = {}

      #:nocov:
      opts = OptionParser.new

      opts.banner = "Usage: #{File.basename($0)} [options]"

      opts.separator ""
      opts.separator "Specific options:"


      opts.on('-c', '--config [ARG]', "Specify a config file to use")    { |c| ENV["chatterbot_config"] = c }
      opts.on('-t', '--test', "Run the bot without actually sending any tweets") { params[:debug_mode] = true }
      opts.on('-v', '--verbose', "verbose output to stdout")    { params[:verbose] = true }
      opts.on('--dry-run', "Run the bot in test mode, and also don't update the database")    { params[:debug_mode] = true ; params[:no_update] = true }

      opts.on('-r', '--reset', "Reset your bot to ignore old tweets") {
        @bot_command = :reset_since_id_counters
      }

      opts.on('--profile [ARG]', "get/set your bot's profile text") { |p| 
        @bot_command = :profile_text
        @bot_command_args = [ p ]
      }

      opts.on('--website [ARG]', "get/set your bot's profile URL") { |u| 
        @bot_command = :profile_website
        @bot_command_args = [ u ]
      }
      
      opts.on_tail("-h", "--help", "Show this message") do
        puts opts
        exit
      end

      opts.parse!(ARGV)
      #:nocov:

      @bot = Chatterbot::Bot.new(params)
      if @bot_command != nil
        @bot.skip_run = true
        result = @bot.send(@bot_command, *@bot_command_args)
        puts result
      end

      @bot
    end
generate a Bot object. if the DSL is being called from a Bot object, just return it
 otherwise create a bot and return that