]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/nickserv.rb
lart plugin: ensure that the lart/praise being added/removed is a string
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / nickserv.rb
index 7a9ff0c601f40ca83891f90d407f3199895a1d8c..b89e61d96489dcccf23b3c433f4af01a2d13c890 100644 (file)
@@ -1,12 +1,30 @@
+#-- vim:sw=2:et
+#++
+#
+# :title: Nickserv management plugin for rbot
+#
+# Author:: Tom Gilbert (giblet) <tom@linuxbrit.co.uk>
+# Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
+#
+# Copyright:: (C) 2002-2005 Tom Gilbert
+# Copyright:: (C) 2006 Tom Gilbert, Giuseppe Bilotta
+# Copyright:: (C) 2006-2007 Giuseppe Bilotta
+#
 # Automatically lookup nicks in @registry and identify when asked
+#
 # Takes over proper nick if required and nick is registered
-# TODO allow custom IDENTIFY and GHOST names
+
+# 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 },
@@ -16,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")
@@ -50,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!
@@ -63,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_string'])
+    @identified = false
   end
 
   # Returns the nickserv name
@@ -138,6 +169,7 @@ class NickServPlugin < Plugin
   end
   
   def connect
+    @identified = false
     do_identify
   end
   
@@ -158,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"