summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-join.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc/erc-join.el')
-rw-r--r--lisp/erc/erc-join.el27
1 files changed, 25 insertions, 2 deletions
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index da894ba5977..85d1edf6427 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -32,6 +32,7 @@
;;; Code:
(require 'erc)
+(require 'auth-source)
(eval-when-compile (require 'cl))
(defgroup erc-autojoin nil
@@ -56,6 +57,13 @@ Every element in the alist has the form (SERVER . CHANNELS).
SERVER is a regexp matching the server, and channels is the
list of channels to join.
+If the channel(s) require channel keys for joining, the passwords
+are found via auth-source. For instance, if you use ~/.authinfo
+as your auth-source backend, then put something like the
+following in that file:
+
+machine irc.example.net login \"#fsf\" password sEcReT
+
Customize this variable to set the value for your first connect.
Once you are connected and join and part channels, this alist
keeps track of what channels you are on, and will join them
@@ -131,7 +139,7 @@ This function is run from `erc-nickserv-identified-hook'."
(when (string-match (car l) server)
(dolist (chan (cdr l))
(unless (erc-member-ignore-case chan joined)
- (erc-server-send (concat "join " chan))))))))
+ (erc-server-join-channel server chan)))))))
nil)
(defun erc-autojoin-channels (server nick)
@@ -148,10 +156,25 @@ This function is run from `erc-nickserv-identified-hook'."
(dolist (l erc-autojoin-channels-alist)
(when (string-match (car l) server)
(dolist (chan (cdr l))
- (erc-server-send (concat "join " chan))))))
+ (erc-server-join-channel server chan)))))
;; Return nil to avoid stomping on any other hook funcs.
nil)
+(defun erc-server-join-channel (server channel)
+ (let* ((secret (plist-get (nth 0 (auth-source-search
+ :max 1
+ :host server
+ :port "irc"
+ :user channel))
+ :secret))
+ (password (if (functionp secret)
+ (funcall secret)
+ secret)))
+ (erc-server-send (concat "join " channel
+ (if password
+ (concat " " password)
+ "")))))
+
(defun erc-autojoin-add (proc parsed)
"Add the channel being joined to `erc-autojoin-channels-alist'."
(let* ((chnl (erc-response.contents parsed))