-
Notifications
You must be signed in to change notification settings - Fork 2
/
nadoka.rb
91 lines (73 loc) · 1.5 KB
/
nadoka.rb
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env ruby
#
##
## Nadoka:
## Irc Client Server Program
##
#
# Copyright (c) 2004-2005 SASADA Koichi <ko1 at atdot.net>
#
# This program is free software with ABSOLUTELY NO WARRANTY.
# You can re-distribute and/or modify this program under
# the same terms of the Ruby's license.
#
#
# $Id$
# Create : K.S. 03/07/10 20:29:07
#
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'ndk/version'
if $0 == __FILE__
require 'optparse'
require 'ndk/server'
require 'ndk/bot'
$stdout.sync=true
$NDK_Debug = false
rcfile = nil
optparse = OptionParser.new{|opts|
opts.banner = "Usage: ruby #{$0} [options]"
opts.separator ""
opts.separator "Require options:"
opts.on("-r", "--rc [RCFILE]",
"Specify rcfile(required)"){|f|
rcfile = f
}
opts.separator ""
opts.separator "Optional:"
opts.on("-d", "--debug",
"Debug Nadoka"){
$NDK_Debug = true
$DEBUG = true
puts 'Enter Nadoka Debug mode'
}
opts.separator ""
opts.separator "Common options:"
opts.on_tail("-h", "--help", "Show this message"){
puts Nadoka.version
puts opts
exit
}
opts.on_tail("-v", "--version", "Show version"){
puts Nadoka.version
}
}
optparse.parse!(ARGV)
unless rcfile
puts Nadoka.version
puts optparse
exit
end
begin
GC.start
Nadoka::NDK_Server.new(rcfile).start
rescue Nadoka::NDK_QuitProgram
#
rescue Nadoka::NDK_RestartProgram
retry
rescue Exception => e
open('nadoka_fatal_error', 'w'){|f|
f.puts e
f.puts e.backtrace.join("\n")
}
end
end