aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeniz Dogan2011-03-05 14:34:55 +0100
committerDeniz Dogan2011-03-05 14:34:55 +0100
commit72d2c2e3b9fb11f19d58ab20e4760cebbe120350 (patch)
tree9a6a0445803579a7ee4b0c78f21960cc3829ce0d
parent706b5974cd6e3169f6c5ec45ac6b4af2ba283695 (diff)
downloademacs-72d2c2e3b9fb11f19d58ab20e4760cebbe120350.tar.gz
emacs-72d2c2e3b9fb11f19d58ab20e4760cebbe120350.zip
* lisp/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.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/net/rcirc.el53
2 files changed, 65 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6aaadf2bae9..cc0f051d419 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12011-03-05 Deniz Dogan <deniz.a.m.dogan@gmail.com>
2
3 * net/rcirc.el: Add functionality to authenticate before
4 autojoining channels.
5 (rcirc-authenticate-before-join): New option.
6 (rcirc-authenticated-hook): New variable.
7 (rcirc-connect): Make local variable rcirc-user-authenticated.
8 (rcirc-handler-001): Respect rcirc-authenticate-before-join.
9 (rcirc-check-auth-status, rcirc-join-channels-post-auth): New
10 functions.
11 (rcirc-handler-PRIVMSG, rcirc-handler-NOTICE): Call
12 rcirc-check-auth-status.
13
12011-03-05 Alex Harsanyi <AlexHarsanyi@gmail.com> 142011-03-05 Alex Harsanyi <AlexHarsanyi@gmail.com>
2 15
3 * net/soap-client.el (soap-namespace-put-link): Check if the target 16 * net/soap-client.el (soap-namespace-put-link): Check if the target
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 644f7eca10f..3bdaf83d7a9 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -232,6 +232,13 @@ See also `rcirc-authinfo'."
232 :type 'boolean 232 :type 'boolean
233 :group 'rcirc) 233 :group 'rcirc)
234 234
235(defcustom rcirc-authenticate-before-join t
236 "*Non-nil means authenticate to services before joining channels.
237Currently only works with NickServ on some networks."
238 :version "24.1"
239 :type 'boolean
240 :group 'rcirc)
241
235(defcustom rcirc-prompt "> " 242(defcustom rcirc-prompt "> "
236 "Prompt string to use in IRC buffers. 243 "Prompt string to use in IRC buffers.
237 244
@@ -282,6 +289,9 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT."
282 :type 'hook 289 :type 'hook
283 :group 'rcirc) 290 :group 'rcirc)
284 291
292(defvar rcirc-authenticated-hook nil
293 "Hook run after successfully authenticated.")
294
285(defcustom rcirc-always-use-server-buffer-flag nil 295(defcustom rcirc-always-use-server-buffer-flag nil
286 "Non-nil means messages without a channel target will go to the server buffer." 296 "Non-nil means messages without a channel target will go to the server buffer."
287 :type 'boolean 297 :type 'boolean
@@ -524,6 +534,8 @@ If ARG is non-nil, instead prompt for connection parameters."
524 (setq rcirc-timeout-timer nil) 534 (setq rcirc-timeout-timer nil)
525 (make-local-variable 'rcirc-user-disconnect) 535 (make-local-variable 'rcirc-user-disconnect)
526 (setq rcirc-user-disconnect nil) 536 (setq rcirc-user-disconnect nil)
537 (make-local-variable 'rcirc-user-authenticated)
538 (setq rcirc-user-authenticated nil)
527 (make-local-variable 'rcirc-connecting) 539 (make-local-variable 'rcirc-connecting)
528 (setq rcirc-connecting t) 540 (setq rcirc-connecting t)
529 541
@@ -2428,10 +2440,23 @@ keywords when no KEYWORD is given."
2428 (setq rcirc-server-name sender) 2440 (setq rcirc-server-name sender)
2429 (setq rcirc-nick (car args)) 2441 (setq rcirc-nick (car args))
2430 (rcirc-update-prompt) 2442 (rcirc-update-prompt)
2431 (when rcirc-auto-authenticate-flag (rcirc-authenticate)) 2443 (if rcirc-auto-authenticate-flag
2444 (if rcirc-authenticate-before-join
2445 (progn
2446 (with-rcirc-process-buffer process
2447 (add-hook 'rcirc-authenticated-hook 'rcirc-join-channels-post-auth t t))
2448 (rcirc-authenticate))
2449 (rcirc-authenticate)
2450 (rcirc-join-channels process rcirc-startup-channels))
2451 (rcirc-join-channels process rcirc-startup-channels))))
2452
2453(defun rcirc-join-channels-post-auth (process)
2454 "Join `rcirc-startup-channels' after authenticating."
2455 (with-rcirc-process-buffer process
2432 (rcirc-join-channels process rcirc-startup-channels))) 2456 (rcirc-join-channels process rcirc-startup-channels)))
2433 2457
2434(defun rcirc-handler-PRIVMSG (process sender args text) 2458(defun rcirc-handler-PRIVMSG (process sender args text)
2459 (rcirc-check-auth-status process sender args text)
2435 (let ((target (if (rcirc-channel-p (car args)) 2460 (let ((target (if (rcirc-channel-p (car args))
2436 (car args) 2461 (car args)
2437 sender)) 2462 sender))
@@ -2444,6 +2469,7 @@ keywords when no KEYWORD is given."
2444 (rcirc-put-nick-channel process sender target rcirc-current-line)))) 2469 (rcirc-put-nick-channel process sender target rcirc-current-line))))
2445 2470
2446(defun rcirc-handler-NOTICE (process sender args text) 2471(defun rcirc-handler-NOTICE (process sender args text)
2472 (rcirc-check-auth-status process sender args text)
2447 (let ((target (car args)) 2473 (let ((target (car args))
2448 (message (cadr args))) 2474 (message (cadr args)))
2449 (if (string-match "^\C-a\\(.*\\)\C-a$" message) 2475 (if (string-match "^\C-a\\(.*\\)\C-a$" message)
@@ -2461,6 +2487,31 @@ keywords when no KEYWORD is given."
2461 sender))) 2487 sender)))
2462 message t)))) 2488 message t))))
2463 2489
2490(defun rcirc-check-auth-status (process sender args text)
2491 "Check if the user just authenticated.
2492If authenticated, runs `rcirc-authenticated-hook' with PROCESS as
2493the only argument."
2494 (with-rcirc-process-buffer process
2495 (when (and (not rcirc-user-authenticated)
2496 rcirc-authenticate-before-join
2497 rcirc-auto-authenticate-flag)
2498 (let ((target (car args))
2499 (message (cadr args)))
2500 (when (or
2501 (and ;; nickserv
2502 (string= sender "NickServ")
2503 (string= target rcirc-nick)
2504 (member message
2505 (list
2506 (format "You are now identified for \C-b%s\C-b." rcirc-nick)
2507 "Password accepted - you are now recognized."
2508 )))
2509 ;; place for other methods
2510 )
2511 (setq rcirc-user-authenticated t)
2512 (run-hook-with-args 'rcirc-authenticated-hook process)
2513 (remove-hook 'rcirc-authenticated-hook 'rcirc-join-channels-post-auth t))))))
2514
2464(defun rcirc-handler-WALLOPS (process sender args text) 2515(defun rcirc-handler-WALLOPS (process sender args text)
2465 (rcirc-print process sender "WALLOPS" sender (car args) t)) 2516 (rcirc-print process sender "WALLOPS" sender (car args) t))
2466 2517