summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rbot/core/config.rb1
-rw-r--r--lib/rbot/ircbot.rb20
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb
index fc99fd8c..1459d557 100644
--- a/lib/rbot/core/config.rb
+++ b/lib/rbot/core/config.rb
@@ -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)
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index f5681338..01dbb12b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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])