用erc来聊天?

这个是配置文件,直接摘抄过来

(require 'erc)
(require 'erc-log)
(require 'erc-notify)
(require 'erc-spelling)
(require 'erc-autoaway)
(require 'tls)

;; utf-8 always and forever
(setq erc-server-coding-system '(utf-8 . utf-8))
;; Interpret mIRC-style color commands in IRC chats
(setq erc-interpret-mirc-color t)
;; Kill buffers for channels after /part
(setq erc-kill-buffer-on-part t)
;; Kill buffers for private queries after quitting the server
(setq erc-kill-queries-on-quit t)
;; Kill buffers for server messages after quitting the server
(setq erc-kill-server-buffer-on-quit t)
;; exclude boring stuff from tracking
(erc-track-mode t)
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
                                "324" "329" "332" "333" "353" "477"))

(setq erc-autojoin-channels-alist '(("freenode.net"
                                     "#python"
                                     "#emacs")))

(defun read-lines (filePath)
  "Return a list of lines of a file at filePath."
  (with-temp-buffer (insert-file-contents filePath)
                    (split-string (buffer-string) "\n" t)))

(defun start-irc ()
  (interactive)
  (when (y-or-n-p "Do you want to start IRC? ")
    (let* ((acc (read-lines "~/.irc-account"))
           (irc-nick (car acc))
           (irc-password (nth 1 acc))
           (tls-program '("gnutls-cli --insecure -p %p %h" "gnutls-cli --insecure -p %p %h --protocols ssl3" "openssl s_client -connect %h:%p -no_ssl2 -ign_eof")))
      (erc-tls :server "irc.freenode.net"
               :port 6697
               :nick irc-nick
               :password irc-password))))

(defun filter-server-buffers ()
  (delq nil
        (mapcar
         (lambda (x) (and (erc-server-buffer-p x) x))
         (buffer-list))))

(defun stop-irc ()
  (interactive)
  (dolist (buffer (filter-server-buffers))
    (message "Server buffer: %s" (buffer-name buffer))
    (with-current-buffer buffer
      (erc-quit-server "zzZZ"))))

(provide 'init-erc)

然后把用户名和密码写在"~/.irc-account"里

user
password

然后 start-irc 就可以聊天了

需要事先配置gnutls,或者也可以用openssl (ssl加密不是必须的,但是在某些内网里使用似乎必须要求加密

1 个赞