]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
More nickserv cleanups
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 31 Aug 2006 15:15:41 +0000 (15:15 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 31 Aug 2006 15:15:41 +0000 (15:15 +0000)
ChangeLog
data/rbot/plugins/nickserv.rb

index 5a334901f0b80ac88568900f9c9bb9af62dcf33b..f5bc4ab0c1c8aaba6890e70edf63802f60199296 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-31  Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
+
+       * Nickserv plugin: bot will now try to inform nickserv when password
+       is changed. Moreover it's not necessary to specify the nick anymore if
+       you want to change the password for the current bot nick. Also do some
+       internal cleanups while we're at it.
+
 2006-08-29  Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
 
        * Script plugin: new (UNSAFE!) echo functions. Just like eval, but
index 5c2e068f79d58b1725c50a4f6a4fa39e543e7d00..6d6e55a4f3235ba49996d6e234f525a287b0c9ca 100644 (file)
@@ -62,13 +62,23 @@ class NickServPlugin < Plugin
     set_ident_request(@bot.config['nickserv.ident_request'])
   end
 
+  # Returns the nickserv name
+  def ns_nick
+    @bot.config['nickserv.name']
+  end
+
+  # say something to nickserv
+  def ns_say(msg)
+    @bot.say ns_nick, msg
+  end
+
   def password(m, params)
     nick = params[:nick] || @bot.nick
     passwd = params[:passwd]
     if nick == @bot.nick
-      @bot.say @bot.config['nickserv.name'], "SET PASSWORD #{passwd}"
+      ns_say "SET PASSWORD #{passwd}"
     else
-      m.reply "I'm only changing this in my database, I won't inform #{@bot.config['nickserv.name']} of the change"
+      m.reply "I'm only changing this in my database, I won't inform #{ns_nick} of the change"
     end
     @registry[nick] = passwd
     m.okay
@@ -78,7 +88,7 @@ class NickServPlugin < Plugin
     passwd = params[:passwd] ? params[:passwd] : genpasswd
     message = "REGISTER #{passwd}"
     message += " #{params[:email]}" if params[:email]
-    @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], message
+    ns_say message
     @registry[@bot.nick] = passwd
     m.okay
   end
@@ -96,10 +106,10 @@ class NickServPlugin < Plugin
   def do_identify(nick=@bot.nick)
     if @registry.has_key?(nick)
       if @bot.config['nickserv.wants_nick']
-        @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{nick} #{@registry[nick]}"
+        ns_say "IDENTIFY #{nick} #{@registry[nick]}"
       else
         if nick == @bot.nick
-          @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{@registry[nick]}"
+          ns_say "IDENTIFY #{@registry[nick]}"
         else
           # We cannot identify for different nicks if we can't use the nickname ...
           return false
@@ -107,14 +117,20 @@ class NickServPlugin < Plugin
       end
       return true
     end
-    return false
+    return nil
   end
 
   def identify(m, params)
-    if do_identify
+    ided = do_identify
+    case ided
+    when true
       m.okay
-    else
+    when false
+      m.reply "I cannot identify for a this nick"
+    when nil
       m.reply "I dunno the nickserv password for the nickname #{@bot.nick} :("
+    else
+      m.reply "uh ... something went wrong ..."
     end
   end
   
@@ -124,7 +140,7 @@ class NickServPlugin < Plugin
   
   def nicktaken(nick)
     if @registry.has_key?(nick)
-      @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "GHOST #{nick} #{@registry[nick]}"
+      ns_say "GHOST #{nick} #{@registry[nick]}"
       if do_identify nick
         sleep @bot.config['nickserv.wait']
         @bot.nickchg nick
@@ -141,7 +157,7 @@ class NickServPlugin < Plugin
   def listen(m)
     return unless(m.kind_of? NoticeMessage)
 
-    if (m.sourcenick == @bot.config['nickserv.name'] && m.message =~ @ident_request)
+    if (m.sourcenick == ns_nick && m.message =~ @ident_request)
       debug "nickserv asked us to identify for nick #{@bot.nick}"
       do_identify
     end