Created
May 5, 2020 21:42
-
-
Save neuro-sys/81b7d95490ac5dd045ba2af2f149d975 to your computer and use it in GitHub Desktop.
ERC ZNC connection and extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; M-x erc-start to connect | |
;; M-p to prompt ZNC password | |
;; Once the server buffer is killed, kills all erc-mode buffers | |
(require 'erc) | |
(defconst *erc-my-user-name* "my_nickname") | |
(defconst *erc-my-server-name* "myzncserver.com") | |
(defconst *erc-my-server-port* 8888) | |
(defconst *erc-my-server-buffer-name* (concat *erc-my-server-name* ":" (number-to-string *erc-my-server-port*))) | |
(defun erc-start () | |
(interactive) | |
(erc-tls :server *erc-my-server-name* :port *erc-my-server-port* | |
:nick *erc-my-user-name* :full-name *erc-my-user-name*)) | |
(defun erc-pass () | |
(interactive) | |
(with-current-buffer (get-buffer *erc-my-server-buffer-name*) | |
(let ((pass (read-passwd "Password:"))) | |
(erc-send-input (concat "/quote PASS " *erc-my-user-name* ":" pass))))) | |
(add-hook 'erc-mode-hook | |
(lambda () (local-set-key (kbd "M-p") #'erc-pass))) | |
(with-current-buffer (elt (buffer-list) 0) major-mode) | |
(add-hook 'erc-kill-server-hook | |
(lambda () | |
(dolist (buffer (buffer-list)) | |
(if (and (string= (with-current-buffer buffer major-mode) "erc-mode") | |
(not (string= (buffer-name buffer) *erc-my-server-buffer-name*))) | |
(kill-buffer buffer))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment