X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fircbot.rb;h=29d4711d974246fc50eff205286d7997cce6def3;hb=0ee075cd1ea745e0a96e4f12476e554714619a31;hp=7cfda371b13c11db067f820ebcf377c451cb6229;hpb=ed78f06271350b42b36b4bcd5ede7395529823f6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 7cfda371..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 @@ -459,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) @@ -631,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)