]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
nickserv plugin: export information on current identification status
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 20:44:40 +0000 (20:44 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 20:44:40 +0000 (20:44 +0000)
ChangeLog
data/rbot/plugins/nickserv.rb

index fc5beeb4846be503a4983c6a71cb603415cf0754..b82b3b0f685b3dc2b9b4176891c2ef1597d04694 100644 (file)
--- 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>
 
index 85270933c794a51439d8bcb1e34bc94341e1b3f6..f23705e38448b716151e0e183588063886243e5e 100644 (file)
 # 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"