+2011-03-05 Deniz Dogan <deniz.a.m.dogan@gmail.com>
+
+ * net/rcirc.el: Add functionality to authenticate before
+ autojoining channels.
+ (rcirc-authenticate-before-join): New option.
+ (rcirc-authenticated-hook): New variable.
+ (rcirc-connect): Make local variable rcirc-user-authenticated.
+ (rcirc-handler-001): Respect rcirc-authenticate-before-join.
+ (rcirc-check-auth-status, rcirc-join-channels-post-auth): New
+ functions.
+ (rcirc-handler-PRIVMSG, rcirc-handler-NOTICE): Call
+ rcirc-check-auth-status.
+
2011-03-05 Alex Harsanyi <AlexHarsanyi@gmail.com>
* net/soap-client.el (soap-namespace-put-link): Check if the target
:type 'boolean
:group 'rcirc)
+(defcustom rcirc-authenticate-before-join t
+ "*Non-nil means authenticate to services before joining channels.
+Currently only works with NickServ on some networks."
+ :version "24.1"
+ :type 'boolean
+ :group 'rcirc)
+
(defcustom rcirc-prompt "> "
"Prompt string to use in IRC buffers.
:type 'hook
:group 'rcirc)
+(defvar rcirc-authenticated-hook nil
+ "Hook run after successfully authenticated.")
+
(defcustom rcirc-always-use-server-buffer-flag nil
"Non-nil means messages without a channel target will go to the server buffer."
:type 'boolean
(setq rcirc-timeout-timer nil)
(make-local-variable 'rcirc-user-disconnect)
(setq rcirc-user-disconnect nil)
+ (make-local-variable 'rcirc-user-authenticated)
+ (setq rcirc-user-authenticated nil)
(make-local-variable 'rcirc-connecting)
(setq rcirc-connecting t)
(setq rcirc-server-name sender)
(setq rcirc-nick (car args))
(rcirc-update-prompt)
- (when rcirc-auto-authenticate-flag (rcirc-authenticate))
+ (if rcirc-auto-authenticate-flag
+ (if rcirc-authenticate-before-join
+ (progn
+ (with-rcirc-process-buffer process
+ (add-hook 'rcirc-authenticated-hook 'rcirc-join-channels-post-auth t t))
+ (rcirc-authenticate))
+ (rcirc-authenticate)
+ (rcirc-join-channels process rcirc-startup-channels))
+ (rcirc-join-channels process rcirc-startup-channels))))
+
+(defun rcirc-join-channels-post-auth (process)
+ "Join `rcirc-startup-channels' after authenticating."
+ (with-rcirc-process-buffer process
(rcirc-join-channels process rcirc-startup-channels)))
(defun rcirc-handler-PRIVMSG (process sender args text)
+ (rcirc-check-auth-status process sender args text)
(let ((target (if (rcirc-channel-p (car args))
(car args)
sender))
(rcirc-put-nick-channel process sender target rcirc-current-line))))
(defun rcirc-handler-NOTICE (process sender args text)
+ (rcirc-check-auth-status process sender args text)
(let ((target (car args))
(message (cadr args)))
(if (string-match "^\C-a\\(.*\\)\C-a$" message)
sender)))
message t))))
+(defun rcirc-check-auth-status (process sender args text)
+ "Check if the user just authenticated.
+If authenticated, runs `rcirc-authenticated-hook' with PROCESS as
+the only argument."
+ (with-rcirc-process-buffer process
+ (when (and (not rcirc-user-authenticated)
+ rcirc-authenticate-before-join
+ rcirc-auto-authenticate-flag)
+ (let ((target (car args))
+ (message (cadr args)))
+ (when (or
+ (and ;; nickserv
+ (string= sender "NickServ")
+ (string= target rcirc-nick)
+ (member message
+ (list
+ (format "You are now identified for \C-b%s\C-b." rcirc-nick)
+ "Password accepted - you are now recognized."
+ )))
+ ;; place for other methods
+ )
+ (setq rcirc-user-authenticated t)
+ (run-hook-with-args 'rcirc-authenticated-hook process)
+ (remove-hook 'rcirc-authenticated-hook 'rcirc-join-channels-post-auth t))))))
+
(defun rcirc-handler-WALLOPS (process sender args text)
(rcirc-print process sender "WALLOPS" sender (car args) t))