]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
+ @bot.wanted_nick stores the nick wanted by the bot
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 30 Jul 2008 17:25:24 +0000 (19:25 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 30 Jul 2008 17:25:24 +0000 (19:25 +0200)
lib/rbot/core/config.rb
lib/rbot/ircbot.rb

index fc99fd8c961f5de8dae44dc89050362337a5ea0e..1459d557607004fc800dcf851579aca5996a1ef2 100644 (file)
@@ -181,6 +181,7 @@ class ConfigModule < CoreBotModule
 
   def bot_nick(m, param)
     @bot.nickchg(param[:nick])
+    @bot.wanted_nick = param[:nick]
   end
 
   def bot_status(m, param)
index f56813386abfa307a9c4a52ca438d4a54e0b0f5f..01dbb12b4e6c1111bde3ad073a54fea7a770615a 100644 (file)
@@ -207,6 +207,22 @@ class Bot
     myself.nick
   end
 
+  # nick wanted by the bot. This defaults to the irc.nick config value,
+  # but may be overridden by a manual !nick command
+  def wanted_nick
+    @wanted_nick || config['irc.nick']
+  end
+
+  # set the nick wanted by the bot
+  def wanted_nick=(wn)
+    if wn.nil? or wn.to_s.downcase == config['irc.nick'].downcase
+      @wanted_nick = nil
+    else
+      @wanted_nick = wn.to_s.dup
+    end
+  end
+
+
   # bot inspection
   # TODO multiserver
   def inspect
@@ -584,6 +600,10 @@ class Bot
     #
     @quiet = Set.new
 
+    # the nick we want, if it's different from the irc.nick config value
+    # (e.g. as set by a !nick command)
+    @wanted_nick = nil
+
     @client[:welcome] = proc {|data|
       m = WelcomeMessage.new(self, server, data[:source], data[:target], data[:message])