:app irc

how neckbeards socialize

1. Description

This module turns Emacs into an IRC client, capable of OS notifications.

1.1. Maintainers

This module has no dedicated maintainers. Become a maintainer?

1.2. Module flags

This module has no flags.

1.4. Hacks

No hacks documented for this module.

2. Prerequisites

This module requires gnutls for secure IRC connections to work.

2.1. macOS

brew install gnutls

2.2. Debian / Ubuntu

apt install gnutls-bin

2.3. Arch Linux

pacman -S gnutls

2.4. NixOS

environment.systemPackages = [ pkgs.gnutls ];

3. TODO Usage

This module’s usage documentation is incomplete. Complete it?

3.1. An IRC Client in Emacs

To connect to IRC you can invoke the =irc function using M-x or your own custom keybinding.

command description
=irc Connect to IRC and all configured servers

When in a circe buffer these keybindings will be available.

command key description
+irc/tracking-next-buffer <leader> m a Switch to the next active buffer
circe-command-JOIN <leader> m j Join a channel
+irc/send-message <leader> m m Send a private message
circe-command-NAMES <leader> m n List the names of the current channel
circe-command-PART <leader> m p Part the current channel
+irc/quit <leader> m Q Kill the current circe session and workgroup
circe-reconnect <leader> m R Reconnect the current server

4. Configuration

Use the (set-irc-server! SERVER PLIST) function to configure IRC servers. Its second argument (a plist) takes the same arguments as circe-network-options:

;; if you omit =:host=, ~SERVER~ is used instead.
(after! circe
  (set-irc-server! "irc.libera.chat"
    `(:tls t
      :port 6697
      :nick "doom"
      :sasl-username "myusername"
      :sasl-password "mypassword"
      :channels ("#emacs"))))

However, it is a obviously a bad idea to store your password in plaintext, so here are ways to avoid that:

4.1. Pass: the unix password manager

Pass is my tool of choice. I use it to manage my passwords. If you activate the :tools pass module you get an elisp API through which to access your password store.

set-irc-server! accepts a plist can use functions instead of strings. +pass-get-user and +pass-get-secret can help here:

(set-irc-server! "irc.libera.chat"
  `(:tls t
    :port 6697
    :nick "doom"
    :sasl-username ,(+pass-get-user   "irc/libera.chat")
    :sasl-password ,(+pass-get-secret "irc/libera.chat")
    :channels ("#emacs")))

But wait, there’s more! This stores your password in a public variable which could be accessed or appear in backtraces. Not good! So we go a step further:

(set-irc-server! "irc.libera.chat"
  `(:tls t
    :port 6697
    :nick "doom"
    :sasl-username ,(+pass-get-user "irc/libera.chat")
    :sasl-password (lambda (&rest _) (+pass-get-secret "irc/libera.chat"))
    :channels ("#emacs")))

And you’re good to go!

Note that +pass-get-user tries to find your username by looking for the fields listed in +pass-user-fields (by default login, user=, username= and email)=). An example configuration looks like

username: myusername

4.2. Emacs’ auth-source API

auth-source is built into Emacs. As suggested in the circe wiki, you can store (and retrieve) encrypted passwords with it.

(setq auth-sources '("~/.authinfo.gpg"))

(defun my-fetch-password (&rest params)
  (require 'auth-source)
  (let ((match (car (apply #'auth-source-search params))))
    (if match
	(let ((secret (plist-get match :secret)))
	  (if (functionp secret)
	      (funcall secret)
      (error "Password not found for %S" params))))

(defun my-nickserv-password (server)
  (my-fetch-password :user "forcer" :host "irc.libera.chat"))

(set-irc-server! "irc.libera.chat"
  '(:tls t
    :port 6697
    :nick "doom"
    :sasl-password my-nickserver-password
    :channels ("#emacs")))

5. Troubleshooting

There are no known problems with this module. Report one?

6. TODO Appendix

This module has no appendix yet. Write one?