Sha256: 62877b5ca1e589cf53f6e8ab096a7bf75899f4e9ed9390ecccdf2f9f82376426

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')

require 'chatterbot'
require 'optparse'

include Chatterbot::Helpers
include Chatterbot::Blacklist
include Chatterbot::Config
include Chatterbot::DB
include Chatterbot::Logging

@display_blacklist = false

#
# pull in any arguments and set them as env variables
#
opts = OptionParser.new
opts.banner = "Usage: #{File.basename($0)} [options]"

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

opts.on('-d', '--db [ARG]', "Specify a DB connection URI")    { |d| ENV["chatterbot_db"] = d }
opts.on('-c', '--config [ARG]', "Specify a config file to use")    { |c| ENV["chatterbot_config"] = c }
opts.on('-p', '--print', "Print out the current blacklist")    { @display_blacklist = true }
opts.on_tail("-h", "--help", "Show this message") do
  puts opts
  exit
end      

extra = opts.parse!(ARGV)

if ! has_db?
  puts "You need to specify a db connection!"
  exit
end


if @display_blacklist
  db[:blacklist].each do |u|
    puts u.inspect
  end
  
elsif extra.empty?
  #
  # iterate through STDIN and add anything to the blacklist.  nothing too shiny here.
  #
  $stdin.each_line do |l|
    add_to_blacklist(l.chomp)
  end 
else
  #
  # add any users specified on the command-line
  #
  extra.each do |l|
    add_to_blacklist(l.chomp)
  end  
  
end



Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chatterbot-0.2.8 bin/chatterbot-blacklist
chatterbot-0.2.7 bin/chatterbot-blacklist
chatterbot-0.2.6 bin/chatterbot-blacklist
chatterbot-0.2.5 bin/chatterbot-blacklist
chatterbot-0.2.4 bin/chatterbot-blacklist
chatterbot-0.2.3 bin/chatterbot-blacklist
chatterbot-0.2.2 bin/chatterbot-blacklist
chatterbot-0.2.1 bin/chatterbot-blacklist
chatterbot-0.2.0 bin/chatterbot-blacklist