summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-07-30 19:25:24 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-07-30 19:25:24 +0200
commitd2bdf50753338cde9cdb806f912a822344d7097a (patch)
treea4c4004b65fb15b220b7a11ed8d15f3f262b835e /lib
parent6367bb1e0ec7ecc03ebfc9370a096c2a2c18adae (diff)
+ @bot.wanted_nick stores the nick wanted by the bot
Diffstat (limited to 'lib')
-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])