Emacs ERC pushover notifications

Mathieu Poussin
Kedare’s Blog
Published in
1 min readOct 11, 2016

This adds a message inside Emacs, and a better message format on both Emacs and Pushover.

(defcustom pushover-token nil
"pushover application token")
(defcustom pushover-user-key nil
"pushover user-key")
(defun pushover-notify (title msg)
(let ((url-request-method "POST")
(url-request-data (concat "token=" pushover-token
"&user=" pushover-user-key
"&title=" title
"&message=" msg)))
(url-retrieve "https://api.pushover.net/1/messages.json" 'pushover-kill-url-buffer)))
(defun pushover-kill-url-buffer (status)
"Kill the buffer returned by `url-retrieve'."
(kill-buffer (current-buffer)))
;; Notify my when someone mentions my nick.
(defun erc-global-notify (matched-type nick msg)
(interactive)
(when (eq matched-type 'current-nick)
(pushover-notify (concat "ERC: " (buffer-name)) (concat "<" (car (split-string nick "!")) "> " message))
(display-message-or-buffer (concat "ERC: " (buffer-name) ": <" (car (split-string nick "!")) "> " message) "ERC Notifications")
))
(add-hook 'erc-text-matched-hook 'erc-global-notify)

 by the author.

--

--

Mathieu Poussin
Kedare’s Blog

Network Automation Engineer at @scaleway, #avgeek, In #Nantes