Twitch chat IRC server connection from within emacs.

The credits for this post goes to mplscorwin and emacsomancer especially Corwin was very patient with an elisp noob like me. Thanks.

I started broadcasting my web application hacking & learning adventures on twitch not long ago. On twitch, your channel has a chat panel where viewers may comment or ask questions. But there is a problem. If you want to see the chat you should open your own channel and this causes echoing your sound if you enabled desktop audio for background music. What i wanted was connecting to twitch chat from within emacs and being notified on my desktop with libnotify, when someone messaged in my channel, regardless of the message. The channel is not so busy yet, so i want all messages to show up on my desktop. The config is working on my own channel and my favorite which is nahamsec but there are channels which doesn’t work and i couldn’t figure out why. If you happen to debug those problems please do message me on twitter. There may be some channel specific settings which block irc clients somehow. Below are the steps taken for my mostly working configuration:

Be sure that libnotify is installed and notify-send command is working.

Get your oauth key from this link which is referenced on twitch’s own dev site which made the app trustable enough for me.

Do remember to change “onurcyukruk” to your nickname.

Now i assume you have a working erc configuration. Mine is something like this:

(defun start-irc ()
  "Connect to IRC."
  (erc-tls :server ""
           :port 6697
           :nick "onurcyukruk"
           :password (password-store-get "twitch/ircpass"))
(setq erc-kill-buffer-on-part t)
(setq erc-kill-server-buffer-on-quit t)

The important part here is this -> :password (password-store-get “twitch/ircpass”)) -> for password you should use the oauth key which you got from the link above. I’m using command line password store utility pass. I don’t recommend it but you may put your oauth key in your config file.

Now after installing sauron and alert from emacs gurus djcb and jwiegley just add the below snippet to your “init.el” file.

;; alert
(use-package alert
  :ensure t
  (require 'alert)
  (setq alert-default-style 'libnotify)
  (setq alert-fade-time 4))

;;; sauron
(use-package sauron
  :ensure t
  (require 'sauron-org) 
  (setq sauron-modules '(sauron-erc
  (setq sauron-dbus-cookie t)
  (setq sauron-debug t)
   sauron-max-line-length 144

  (add-hook 'sauron-event-added-functions #'sauron-alert-el-adapter)
  (global-set-key (kbd "\C-c1") 'sauron-start))

(setq sauron-separate-frame nil) 

(alert-add-rule  :mode     'erc-mode
                 #'(lambda (info)
                     (string-match (concat "\\`[^&].*onurcyukruk\\'")
                 :style 'libnotify
                 :continue t)

Eval your buffer or restart your emacs. M-x sauron-start && M-x start-irc. Now you should be good to go.

Here is a screenshot from my config.