aboutsummaryrefslogtreecommitdiffstats
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 @@
32;;; Code: 32;;; Code:
33 33
34(require 'erc) 34(require 'erc)
35(require 'auth-source)
35(eval-when-compile (require 'cl)) 36(eval-when-compile (require 'cl))
36 37
37(defgroup erc-autojoin nil 38(defgroup erc-autojoin nil
@@ -56,6 +57,13 @@ Every element in the alist has the form (SERVER . CHANNELS).
56SERVER is a regexp matching the server, and channels is the 57SERVER is a regexp matching the server, and channels is the
57list of channels to join. 58list of channels to join.
58 59
60If the channel(s) require channel keys for joining, the passwords
61are found via auth-source. For instance, if you use ~/.authinfo
62as your auth-source backend, then put something like the
63following in that file:
64
65machine irc.example.net login \"#fsf\" password sEcReT
66
59Customize this variable to set the value for your first connect. 67Customize this variable to set the value for your first connect.
60Once you are connected and join and part channels, this alist 68Once you are connected and join and part channels, this alist
61keeps track of what channels you are on, and will join them 69keeps track of what channels you are on, and will join them
@@ -131,7 +139,7 @@ This function is run from `erc-nickserv-identified-hook'."
131 (when (string-match (car l) server) 139 (when (string-match (car l) server)
132 (dolist (chan (cdr l)) 140 (dolist (chan (cdr l))
133 (unless (erc-member-ignore-case chan joined) 141 (unless (erc-member-ignore-case chan joined)
134 (erc-server-send (concat "join " chan)))))))) 142 (erc-server-join-channel server chan)))))))
135 nil) 143 nil)
136 144
137(defun erc-autojoin-channels (server nick) 145(defun erc-autojoin-channels (server nick)
@@ -148,10 +156,25 @@ This function is run from `erc-nickserv-identified-hook'."
148 (dolist (l erc-autojoin-channels-alist) 156 (dolist (l erc-autojoin-channels-alist)
149 (when (string-match (car l) server) 157 (when (string-match (car l) server)
150 (dolist (chan (cdr l)) 158 (dolist (chan (cdr l))
151 (erc-server-send (concat "join " chan)))))) 159 (erc-server-join-channel server chan)))))
152 ;; Return nil to avoid stomping on any other hook funcs. 160 ;; Return nil to avoid stomping on any other hook funcs.
153 nil) 161 nil)
154 162
163(defun erc-server-join-channel (server channel)
164 (let* ((secret (plist-get (nth 0 (auth-source-search
165 :max 1
166 :host server
167 :port "irc"
168 :user channel))
169 :secret))
170 (password (if (functionp secret)
171 (funcall secret)
172 secret)))
173 (erc-server-send (concat "join " channel
174 (if password
175 (concat " " password)
176 "")))))
177
155(defun erc-autojoin-add (proc parsed) 178(defun erc-autojoin-add (proc parsed)
156 "Add the channel being joined to `erc-autojoin-channels-alist'." 179 "Add the channel being joined to `erc-autojoin-channels-alist'."
157 (let* ((chnl (erc-response.contents parsed)) 180 (let* ((chnl (erc-response.contents parsed))