EOS: IRC Module

Table of Contents

(provide 'eos-irc)

IRC With ZNC and ERC

IRC in Emacs

(defun start-erc ()
  (load-file "~/.ercpass")
  (use-package erc
    (setq erc-nick "dakrone"
          erc-keywords '("clj-http")
          erc-pals '("hiredman"
          erc-hide-list '("JOIN" "PART" "QUIT")
          erc-fill-column 100
          erc-server-reconnect-timeout 5
          erc-server-reconnect-attempts 3
          '(("irc.genevairc.net" "#prosapologian")
            ("writequit.org" "#elasticsearch" "#84115")))
    (defun eos/disable-font-lock ()
      (font-lock-mode -1))
    ;; ERC is crazy, for some reason it doesn't like font-lock...
    (add-hook 'erc-mode-hook #'eos/disable-font-lock))
  (use-package erc-hl-nicks :ensure t)
  (use-package ercn
    :ensure t
    (setq ercn-notify-rules
          '((current-nick . all)
            (keyword . all)
            (pal . ("#elasticsearch"))
            (query-buffer . all)))

    (use-package s :ensure t)
    (when (fboundp 'alert)
      (defun do-notify (nickname message)
        ;; Alert not needed, Sauron handles this now
        ;; (alert (concat nickname ": "
        ;;                (s-trim (s-collapse-whitespace message)))
        ;;        :title (buffer-name))
        (message "[%s] %s: %s"
                 (buffer-name) nickname (s-trim (s-collapse-whitespace message))))
      (add-hook 'ercn-notify-hook 'do-notify)))

  (defun erc-cmd-UNTRACK (&optional target)
    "Add TARGET to the list of target to be tracked."
    (if target
          (let ((untracked (car (erc-member-ignore-case target erc-track-exclude))))
            (if untracked
                 (erc-make-notice (format "%s is not currently tracked!" target))
              (add-to-list 'erc-track-exclude target)
               (erc-make-notice (format "Now not tracking %s" target))

      (if (null erc-track-exclude)
          (erc-display-line (erc-make-notice "Untracked targets list is empty") 'active)

        (erc-display-line (erc-make-notice "Untracked targets list:") 'active)
        (mapc #'(lambda (item)
                  (erc-display-line (erc-make-notice item) 'active))
              (erc-with-server-buffer erc-track-exclude))))

  (defun erc-cmd-TRACK (target)
    "Remove TARGET of the list of targets which they should not be tracked.
   If no TARGET argument is specified, list the contents of `erc-track-exclude'."
    (when target
        (let ((tracked (not (car (erc-member-ignore-case target erc-track-exclude)))))
          (if tracked
               (erc-make-notice (format "%s is currently tracked!" target))
            (setq erc-track-exclude (remove target erc-track-exclude))
             (erc-make-notice (format "Now tracking %s" target))

  (defun eos/add-server-to-chan-name (orig-fun server port target)
    (let ((generated-name (funcall orig-fun server port target)))
      (concat (cl-subseq server 0 2) "-" generated-name)))

  ;;(advice-add 'erc-generate-new-buffer-name :around #'eos/add-server-to-chan-name)

  (let ((tls-program
         '("gnutls-cli --priority secure256 --x509certfile ~/host.pem -p %p %h"
           "openssl s_client -connect %h:%p -no_ssl2 -ign_eof -cert ~/host.pem")))
    (erc-tls :server "writequit.org"
             :port 31425
             :nick "dakrone"
             :password freenode-znc-pass)
    ;; (erc :server "irc.genevairc.net"
    ;;      :port 6667
    ;;      :nick "dakrone")
    ;; (erc-tls :server "elastic.irc.slack.com"
    ;;          :port 6697
    ;;          :nick "dakrone"
    ;;          :password (format "%s-novoice" elastic-slack-pass))


I use Slack for work, not because it's better than IRC (it isn't), but because we have to :)

(use-package slack
  :ensure t
  :disabled t
  :commands (slack-start)
  (require 'slack)
  (require 'slack-message-formatter)
  ;; No Emoji (sorry internet)
  (setq slack-buffer-emojify nil)
  (setq slack-prefer-current-team t)
  ;; The `slack-register-team' goes into ~/.slackpass
  (when (file-exists-p "~/.slackpass")
    (load-file "~/.slackpass")))

Author: Lee Hinman

Created: 2017-08-21 Mon 14:27