Sha256: 80e6413587c68825333f63e56dc9be9f59f9c75a1aaf70c14851273d7f36cb89

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 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; $logger.bye; 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.log "#{@bot.name} is online"  if @bot.online?
$logger.log "#{@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

3 entries across 3 versions & 1 rubygems

Version Path
botolo-0.55.2 bin/botolo
botolo-0.55.1 bin/botolo
botolo-0.55.0 bin/botolo