Sha256: 35c24663fc07549f322c64597f45cd355b49591961e09ac52b08d017997697a4

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

#!/usr/bin/env ruby

require 'botolo'
require 'openssl'
require 'logger'
require 'getoptlong'

opts = GetoptLong.new(
  [ "--debug",   "-D", GetoptLong::NO_ARGUMENT],
  [ "--help",    "-h", GetoptLong::NO_ARGUMENT],
  [ "--version", "-v", GetoptLong::NO_ARGUMENT ]
)

DEFAULT_BEHAVIOUR = "./lib/botolo/bot/behaviour.rb"
BOTOLO_PID = File.join(".", "botolo.pid")

OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

$logger = Logger.new(STDOUT)
$logger.datetime_format = '%Y-%m-%d %H:%M:%S'

trap("INT")   { @bot.stop; File.delete(BOTOLO_PID); Kernel.exit(0); }

opts.quiet=true
debug = false

begin
  opts.each do |opt, val|
    case opt
    when '--version'
      puts "#{Botolo::VERSION}"
      Kernel.exit(0)
    when '--help'
      puts "I'll put an help here... promise"
      Kernel.exit(0)
    when '--debug'
      debug = true
    end
  end
rescue GetoptLong::InvalidOption => e
  $logger.helo "botolo", Botolo::VERSION, BOTOLO_PID
  $logger.err e.message
  Kernel.exit(-1)
end

behaviour_file = DEFAULT_BEHAVIOUR
config_file = nil
config_file = ARGV[0] if ARGV.count == 1

$logger.die "usage: botolo bot_configuration_file" if config_file.nil?

$logger.helo "botolo", Botolo::VERSION

@bot = Botolo::Bot::Engine.new({:config=>config_file})
$logger.info "#{@bot.name} is online"  if @bot.online?
$logger.info "#{@bot.name} is offline" unless @bot.online?

if debug
  $logger.debug "forcing #{@bot.name} run"
  @bot.run
else
  @bot.run if @bot.online?
end
@bot.infinite_loop


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
botolo-0.70.1 bin/botolo
botolo-0.70.0 bin/botolo