erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][emacs22] erc-services: Avoid BitlBee error, minor


From: mwolson
Subject: [Erc-commit] [commit][emacs22] erc-services: Avoid BitlBee error, minor code cleanup
Date: Sun, 14 Oct 2007 00:48:40 -0400

commit 25f2a8d3b5ece2e849291fc08acea9b0fe60ca40
Author: Michael Olson <address@hidden>
Date:   Thu Jan 11 01:08:46 2007 +0000

    erc-services: Avoid BitlBee error, minor code cleanup
    
    2007-01-11  Michael Olson  <address@hidden>
    
        * erc-bbdb.el (erc-bbdb-popup-type): Fix customization type and
        documentation.
    
        * erc-services.el (erc-nickserv-identify-mode): Improve
        documentation for nick-change option and move higher to fix
        compiler warning.
        (erc-nickserv-alist): Add simple entry for BitlBee, to avoid
        "NickServ is AWAY: User is offline" error.  Oddly enough, bitlbee
        was smart enough to recognize that as an authentication request
        and log in regardless, which is why I didn't notice this earlier.
        (erc-nickserv-alist-sender, erc-nickserv-alist-regexp)
        (erc-nickserv-alist-nickserv, erc-nickserv-alist-ident-keyword)
        (erc-nickserv-alist-use-nick-p)
        (erc-nickserv-alist-ident-command): New accessors for
        erc-nickserv-alist.  Using nth is unwieldy.
        (erc-nickserv-identify-autodetect)
        (erc-nickserv-identify-on-connect)
        (erc-nickserv-identify-on-nick-change, erc-nickserv-identify): Use
        the new accessors.
    git-archimport-id: address@hidden/erc--main--0--patch-83

diff --git a/ChangeLog b/ChangeLog
index 1cda541..9e955d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2007-01-11  Michael Olson  <address@hidden>
+
+       * erc-bbdb.el (erc-bbdb-popup-type): Fix customization type and
+       documentation.
+
+       * erc-services.el (erc-nickserv-identify-mode): Improve
+       documentation for nick-change option and move higher to fix
+       compiler warning.
+       (erc-nickserv-alist): Add simple entry for BitlBee, to avoid
+       "NickServ is AWAY: User is offline" error.  Oddly enough, bitlbee
+       was smart enough to recognize that as an authentication request
+       and log in regardless, which is why I didn't notice this earlier.
+       (erc-nickserv-alist-sender, erc-nickserv-alist-regexp)
+       (erc-nickserv-alist-nickserv, erc-nickserv-alist-ident-keyword)
+       (erc-nickserv-alist-use-nick-p)
+       (erc-nickserv-alist-ident-command): New accessors for
+       erc-nickserv-alist.  Using nth is unwieldy.
+       (erc-nickserv-identify-autodetect)
+       (erc-nickserv-identify-on-connect)
+       (erc-nickserv-identify-on-nick-change, erc-nickserv-identify): Use
+       the new accessors.
+
 2007-01-11  Diane Murray  <address@hidden>
 
        * NEWS: Added note for `erc-my-nick-face'.  Fixed capab-identify
diff --git a/erc-bbdb.el b/erc-bbdb.el
index 854256f..611b90b 100644
--- a/erc-bbdb.el
+++ b/erc-bbdb.el
@@ -78,10 +78,15 @@ on if you want to have lots of People named \"John Doe\" in 
your BBDB."
 (defcustom erc-bbdb-popup-type 'visible
   "*If t, pop up a BBDB buffer showing the record of a WHOISed person
 or the person who has just joined a channel.
+
 If set to 'visible, the BBDB buffer only pops up when someone was WHOISed
-or a person joined a channel visible on any frame."
+or a person joined a channel visible on any frame.
+
+If set to nil, never pop up a BBDD buffer."
   :group 'erc-bbdb
-  :type 'sexp)
+  :type '(choice (const :tag "When visible" visible)
+                (const :tag "When joining" t)
+                (const :tag "Never" nil)))
 
 (defcustom erc-bbdb-irc-nick-field 'irc-nick
   "The notes field name to use for annotating IRC nicknames."
diff --git a/erc-services.el b/erc-services.el
index b93317e..63ee77c 100644
--- a/erc-services.el
+++ b/erc-services.el
@@ -77,6 +77,27 @@ This group allows you to set variables to somewhat automate
 communication with those Services."
   :group 'erc)
 
+(defcustom erc-nickserv-identify-mode 'both
+  "The mode which is used when identifying to Nickserv.
+
+Possible settings are:.
+
+'autodetect  - Identify when the real Nickserv sends an identify request.
+'nick-change - Identify when you log in or change your nickname.
+'both        - Do the former if the network supports it, otherwise do the
+               latter.
+nil          - Disables automatic Nickserv identification.
+
+You can also use M-x erc-nickserv-identify-mode to change modes."
+  :group 'erc-services
+  :type '(choice (const autodetect)
+                (const nick-change)
+                (const both)
+                (const nil))
+  :set (lambda (sym val)
+        (set sym val)
+        (erc-nickserv-identify-mode val)))
+
 ;;;###autoload (autoload 'erc-services-mode "erc-services" nil t)
 (define-erc-module services nickserv
   "This mode automates communication with services."
@@ -128,27 +149,6 @@ communication with those Services."
         (remove-hook 'erc-nick-changed-functions
                      'erc-nickserv-identify-on-nick-change))))
 
-(defcustom erc-nickserv-identify-mode 'both
-  "The mode which is used when identifying to Nickserv.
-
-Possible settings are:.
-
-'autodetect  - Identify when the real Nickserv sends an identify request.
-'nick-change - Identify when you change your nickname.
-'both        - Do the former if the network supports it, otherwise do the
-               latter.
-nil          - Disables automatic Nickserv identification.
-
-You can also use M-x erc-nickserv-identify-mode to change modes."
-  :group 'erc-services
-  :type '(choice (const autodetect)
-                (const nick-change)
-                (const both)
-                (const nil))
-  :set (lambda (sym val)
-        (set sym val)
-        (erc-nickserv-identify-mode val)))
-
 (defcustom erc-prompt-for-nickserv-password t
   "Ask for the password when identifying to NickServ."
   :group 'erc-services
@@ -184,7 +184,13 @@ Example of use:
 ;; Variables:
 
 (defcustom erc-nickserv-alist
-  '((DALnet
+  '((BitlBee
+     nil
+     nil
+     "&bitlbee"
+     "identify"
+     nil)
+    (DALnet
      "address@hidden"
      "/address@hidden<password>"
      "address@hidden"
@@ -266,6 +272,24 @@ ANSWER is the command to use for the answer.  The default 
is 'privmsg.
                  (string :tag "Command")
                  (const :tag "No special command necessary" nil)))))
 
+(defsubst erc-nickserv-alist-sender (network &optional entry)
+  (nth 1 (or entry (assoc network erc-nickserv-alist))))
+
+(defsubst erc-nickserv-alist-regexp (network &optional entry)
+  (nth 2 (or entry (assoc network erc-nickserv-alist))))
+
+(defsubst erc-nickserv-alist-nickserv (network &optional entry)
+  (nth 3 (or entry (assoc network erc-nickserv-alist))))
+
+(defsubst erc-nickserv-alist-ident-keyword (network &optional entry)
+  (nth 4 (or entry (assoc network erc-nickserv-alist))))
+
+(defsubst erc-nickserv-alist-use-nick-p (network &optional entry)
+  (nth 5 (or entry (assoc network erc-nickserv-alist))))
+
+(defsubst erc-nickserv-alist-ident-command (network &optional entry)
+  (nth 6 (or entry (assoc network erc-nickserv-alist))))
+
 ;; Functions:
 
 (defun erc-nickserv-identify-autodetect (proc parsed)
@@ -277,14 +301,14 @@ password for this nickname, otherwise try to send it 
automatically."
   (unless (and (null erc-nickserv-passwords)
               (null erc-prompt-for-nickserv-password))
     (let* ((network (erc-network))
-          (nickserv (nth 1 (assoc network erc-nickserv-alist)))
-          (identify-regex (nth 2 (assoc network erc-nickserv-alist)))
+          (sender (erc-nickserv-alist-sender network))
+          (identify-regex (erc-nickserv-alist-regexp network))
           (sspec (erc-response.sender parsed))
           (nick (car (erc-response.command-args parsed)))
           (msg (erc-response.contents parsed)))
       ;; continue only if we're sure it's the real nickserv for this network
       ;; and it's asked us to identify
-      (when (and nickserv (equal sspec nickserv)
+      (when (and sender (equal sspec sender)
                 (string-match identify-regex msg))
        (erc-log "NickServ IDENTIFY request detected")
        (erc-nickserv-call-identify-function nick)
@@ -295,7 +319,7 @@ password for this nickname, otherwise try to send it 
automatically."
   (unless (or (and (null erc-nickserv-passwords)
                   (null erc-prompt-for-nickserv-password))
              (and (eq erc-nickserv-identify-mode 'both)
-                  (nth 2 (assoc (erc-network) erc-nickserv-alist))))
+                  (erc-nickserv-alist-regexp (erc-network))))
     (erc-nickserv-call-identify-function nick)))
 
 (defun erc-nickserv-identify-on-nick-change (nick old-nick)
@@ -303,7 +327,7 @@ password for this nickname, otherwise try to send it 
automatically."
   (unless (or (and (null erc-nickserv-passwords)
                   (null erc-prompt-for-nickserv-password))
              (and (eq erc-nickserv-identify-mode 'both)
-                  (nth 2 (assoc (erc-network) erc-nickserv-alist))))
+                  (erc-nickserv-alist-regexp (erc-network))))
     (erc-nickserv-call-identify-function nick)))
 
 (defun erc-nickserv-call-identify-function (nickname)
@@ -333,12 +357,16 @@ When called interactively, read the password using 
`read-passwd'."
     (let* ((erc-auto-discard-away nil)
           (network (erc-network))
           (nickserv-info (assoc network erc-nickserv-alist))
-          (nickserv (or (nth 3 nickserv-info) "NickServ"))
-          (identify-word (or (nth 4 nickserv-info) "IDENTIFY"))
-          (nick (if (nth 5 nickserv-info)
+          (nickserv (or (erc-nickserv-alist-nickserv nil nickserv-info)
+                        "NickServ"))
+          (identify-word (or (erc-nickserv-alist-ident-keyword
+                              nil nickserv-info)
+                             "IDENTIFY"))
+          (nick (if (erc-nickserv-alist-use-nick-p nil nickserv-info)
                     (concat (erc-current-nick) " ")
                   ""))
-          (msgtype (or (nth 6 nickserv-info) "PRIVMSG")))
+          (msgtype (or (erc-nickserv-alist-ident-command nil nickserv-info)
+                       "PRIVMSG")))
       (erc-message msgtype
                   (concat nickserv " " identify-word " " nick password)))))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]