Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e98f1df5be
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 70 lines (55 sloc) 1.961 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#!/usr/bin/env ruby

$:.unshift "lib"
require 'rubygems'
require 'choice'
require_gem 'choice', '>= 0.1.2'
require 'matzbot'

Choice.options do
  header ""
  header "Specific options:"

  options :server => {
    :short => '-s', :long => '--server SERVER',
    :desc => ["The irc server to connect to.", "(default irc.freenode.org)"], :default => 'irc.freenode.org'
  },

  :port => {
    :short => '-p', :long => '--port PORT', :desc => ["The irc server's port.", "(default 6667)"],
    :default => 6667, :cast => Integer
  },

  :nick => {
    :short => '-n', :long => '--nick NICK', :desc => ["The irc bot's nick.", "(default matz)"],
    :default => 'matz'
  },

  :password => {
    :short => '-w', :long => '--password PASSWORD', :desc => "Your nick's password, if registered."
  },

  :channel => {
    :short => '-c', :long => '--channel CHANNEL', :desc => ["The channel to join on connect -- without a hash.", "(default polymorphs)"],
    :default => 'polymorphs'
  },

  :user => {
    :short => '-u', :long => '--user USER', :desc => ["The irc bot's username.", "(default matz)"], :default => 'matz'
  },

  :name => {
    :short => '-m', :long => '--name NAME', :desc => ["The irc bot's name.", "(default Matz)"], :default => 'Matz'
  },

  :daemonize => {
    :short => '-d', :long => '--daemon',
    :desc => ["Run as a daemon - pass it nothing, start, stop, or restart.", "If you pass nothing, `start' is assumed."]
  },
  
  :only_when_addressed => {
    :short => '-a', :long => '--addressed',
    :desc => ["Only speak if being addressed.", "(default false)"]
  }
end

MatzBot::Session.load unless Choice.choices[:daemonize] == 'stop'

require 'daemon'

if Choice.choices[:daemonize]
  MatzBot::Daemonize.daemonize(Choice.choices.merge('daemonize' => Choice.choices[:daemonize] == 'stop' ? 'stop' : 'start'))
else
  MatzBot::Daemonize.store
  begin
    MatzBot::Client.start(Choice.choices)
  ensure
    MatzBot::Session.save
  end
end
Something went wrong with that request. Please try again.