summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--data/rbot/plugins/nickserv.rb26
2 files changed, 30 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index fc5beeb4..b82b3b0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
title/author/copyright/license information. Authors of new plugins are
encouraged to use it. Many existing plugins have been changed to
follow the same spec.
+ * NickServ plugin: delegate #identified() to other plugins after
+ successfull identification. Also provide #identified?() method to test
+ if the bot has successfully identified. Not perfect yet (gets reset
+ after a rescan.)
2007-02-15 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb
index 85270933..f23705e3 100644
--- a/data/rbot/plugins/nickserv.rb
+++ b/data/rbot/plugins/nickserv.rb
@@ -15,12 +15,16 @@
# Takes over proper nick if required and nick is registered
# TODO:: allow custom IDENTIFY and GHOST names
+#
+# FIXME:: identified? status returns false after a rescan, even if the bot
+# previously identified successfully
class NickServPlugin < Plugin
BotConfig.register BotConfigStringValue.new('nickserv.name',
:default => "nickserv", :requires_restart => false,
:desc => "Name of the nick server (all lowercase)")
+
BotConfig.register BotConfigStringValue.new('nickserv.ident_request',
:default => "IDENTIFY", :requires_restart => false,
:on_change => Proc.new { |bot, v| bot.plugins.delegate "set_ident_request", v },
@@ -30,9 +34,16 @@ class NickServPlugin < Plugin
:requires_restart => false,
:on_change => Proc.new { |bot, v| bot.plugins.delegate "set_nick_avail", v },
:desc => "String to look for to see if the nick server is informing us that our nick is now available")
+ BotConfig.register BotConfigStringValue.new('nickserv.identified_string',
+ :default => "(Password|Contrase|Mot de passe).+(acce[pt]t|r[ie]cog?n).+(identif|r[ie]cog?n)",
+ :requires_restart => false,
+ :on_change => Proc.new { |bot, v| bot.plugins.delegate "set_identified_string", v },
+ :desc => "String to look for to see if the nick server is informing us that we have identified successfully")
+
BotConfig.register BotConfigBooleanValue.new('nickserv.wants_nick',
:default => false, :requires_restart => false,
:desc => "Set to false if the nick server doesn't expect the nick as a parameter in the identify command")
+
BotConfig.register BotConfigIntegerValue.new('nickserv.wait',
:default => 30, :validate => Proc.new { |v| v > 0 }, :requires_restart => false,
:desc => "Seconds to wait after sending a message to nickserv, e.g. after ghosting")
@@ -64,6 +75,10 @@ class NickServPlugin < Plugin
@nick_avail = Regexp.new(val)
end
+ def set_identified_string(val)
+ @identified_string = Regexp.new(val)
+ end
+
def initialize
super
# this plugin only wants to store strings!
@@ -77,6 +92,8 @@ class NickServPlugin < Plugin
end
set_ident_request(@bot.config['nickserv.ident_request'])
set_nick_avail(@bot.config['nickserv.nick_avail'])
+ set_identified_string(@bot.config['nickserv.identified'])
+ @identified = false
end
# Returns the nickserv name
@@ -152,6 +169,7 @@ class NickServPlugin < Plugin
end
def connect
+ @identified = false
do_identify
end
@@ -172,9 +190,17 @@ class NickServPlugin < Plugin
when @nick_avail
debug "our nick seems to be free now"
@bot.nickchg @bot.config['irc.nick']
+ when @identified_string
+ debug "we identified successfully to nickserv"
+ @identified = true
+ @bot.plugins.delegate('identified')
end
end
+ def identified?
+ return @identified
+ end
+
end
plugin = NickServPlugin.new
plugin.map 'nickserv password [:nick] :passwd', :action => "password"