]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - bin/rbot
move rbot into lib - still rearranging for packaging/installation
[user/henk/code/ruby/rbot.git] / bin / rbot
1 #!/usr/bin/env ruby
2
3 # Copyright (C) 2002 Tom Gilbert.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to
7 # deal in the Software without restriction, including without limitation the
8 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 # sell copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies of the Software and its documentation and acknowledgment shall be
14 # given in the documentation and software packages that this Software was
15 # used.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 $VERBOSE=true
25
26 require 'etc'
27 require 'getoptlong'
28 require 'rbot/ircbot'
29
30 $debug = true
31 $version="0.9.8"
32 $opts = Hash.new
33
34 # print +message+ if debugging is enabled
35 def debug(message=nil)
36   print "DEBUG: #{message}\n" if($debug && message)
37   #yield
38 end
39
40 opts = GetoptLong.new(
41   [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
42   [ "--help",  "-h", GetoptLong::OPTIONAL_ARGUMENT ]
43 )
44
45 opts.each {|opt, arg|
46   $debug = true if(opt == "--debug")
47   $opts[opt.sub(/^-+/, "")] = arg
48 }
49
50 botclass = ARGV.shift
51 user = Etc.getlogin
52 botclass = "/home/#{user}/.rbot" unless(botclass);
53
54 unless FileTest.directory? botclass
55   # TODO copy in samples/templates from install directory
56   puts "no #{botclass} directory found, creating from templates.."
57   # copy DATA/rbot/templates to botclass
58
59 end
60
61 if(bot = Irc::IrcBot.new(botclass))
62   if($opts["help"])
63     puts bot.help($opts["help"])
64   else
65     # run the bot
66     bot.mainloop
67   end
68 end
69