X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fircbot.rb;h=29d4711d974246fc50eff205286d7997cce6def3;hb=0ee075cd1ea745e0a96e4f12476e554714619a31;hp=24ee6de3f6cf407bbb31108b6fe9995cb8ed9c6f;hpb=83fd5d3b11539a07b740048ad93c09e31e8d6701;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 24ee6de3..29d4711d 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -120,7 +120,7 @@ class IrcBot exit 2 end - botclass = "/home/#{Etc.getlogin}/.rbot" unless botclass + botclass = "#{Etc.getpwnam(Etc.getlogin).dir}/.rbot" unless botclass @botclass = botclass.gsub(/\/$/, "") unless FileTest.directory? botclass @@ -136,6 +136,7 @@ class IrcBot @startup_time = Time.new @config = BotConfig.new(self) +# TODO background self after botconfig has a chance to run wizard @timer = Timer::Timer.new(1.0) # only need per-second granularity @registry = BotRegistry.new self @timer.add(@config['core.save_every']) { save } if @config['core.save_every'] @@ -152,11 +153,6 @@ class IrcBot @socket = IrcSocket.new(@config['server.name'], @config['server.port'], @config['server.bindhost'], @config['server.sendq_delay'], @config['server.sendq_burst']) @nick = @config['irc.nick'] - if @config['core.address_prefix'] - @addressing_prefixes = @config['core.address_prefix'].split(" ") - else - @addressing_prefixes = Array.new - end @client = IrcClient.new @client[:privmsg] = proc { |data| @@ -463,8 +459,9 @@ class IrcBot end # totally shutdown and respawn the bot - def restart - shutdown("restarting, back in #{@config['server.reconnect_wait']}...") + def restart(message = false) + msg = message ? message : "restarting, back in #{@config['server.reconnect_wait']}..." + shutdown(msg) sleep @config['server.reconnect_wait'] # now we re-exec exec($0, *@argv) @@ -635,8 +632,8 @@ class IrcBot part $1 if(@auth.allow?("join", m.source, m.replyto)) when (/^quit(?:\s+(.*))?$/i) quit $1 if(@auth.allow?("quit", m.source, m.replyto)) - when (/^restart$/i) - restart if(@auth.allow?("quit", m.source, m.replyto)) + when (/^restart(?:\s+(.*))?$/i) + restart $1 if(@auth.allow?("quit", m.source, m.replyto)) when (/^hide$/i) join 0 if(@auth.allow?("join", m.source, m.replyto)) when (/^save$/i) @@ -710,7 +707,7 @@ class IrcBot else # stuff to handle when not addressed case m.message - when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi(\W|$)|yo(\W|$))[\s,-.]+#{@nick}$/i) + when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{@nick}$/i) say m.replyto, @lang.get("hello_X") % m.sourcenick when (/^#{@nick}!*$/) say m.replyto, @lang.get("hello_X") % m.sourcenick