Download
(require 'rcirc)
(defvar rcirc-pounces nil
"Alist with a message queue per nick.")
(when (boundp 'session-globals-include)
(add-to-list 'session-globals-include 'rcirc-pounces))
(when (boundp 'desktop-globals-to-save)
(add-to-list 'desktop-globals-to-save 'rcirc-pounces))
(defun rcirc-add-pounce (nick message)
"Add MESSAGE for NICK to `rcirc-pounces'."
(let ((cell (assoc nick rcirc-pounces)))
(if cell
(setcdr cell (cons message (cdr cell)))
(setq rcirc-pounces (cons (list nick message) rcirc-pounces)))))
(defun rcirc-pounce-queue (nick)
"Show queue for NICK."
(dolist (msg (or (cdr (assoc nick rcirc-pounces)) '("No messages")))
(rcirc-print process nick "NOTICE" target msg)))
(defun rcirc-pounce-queue-overview ()
"Show nicks in queue."
(rcirc-print process (rcirc-nick process) "NOTICE" target
(or (mapconcat 'identity (mapcar 'car rcirc-pounces) " ")
"Empty queue")))
(defun-rcirc-command pounce (message)
"Add private MESSAGE for TARGET to its queue.
Without any argument, show the list of targets.
Without a message, show the list of messages for a target."
(interactive "i")
(if (not (string-match "\\([^ ]+\\)\\( \\(.+\\)\\)?" message))
(rcirc-pounce-queue-overview)
(let ((nick (match-string 1 message))
(text (match-string 3 message)))
(if text
(rcirc-add-pounce nick text)
(rcirc-pounce-queue nick)))))
(defun-rcirc-command unpounce (nick)
"Clear queue for NICK."
(interactive "i")
(setq rcirc-pounces (delete (assoc nick rcirc-pounces) rcirc-pounces)))
(defun rcirc-pounce-process (sender)
"Send all messages for SENDER."
(let ((nick (rcirc-user-nick sender)))
(dolist (msg (cdr (assoc nick rcirc-pounces)))
(rcirc-send-message process nick msg))
(rcirc-cmd-unpounce nick)))
(defadvice rcirc-handler-JOIN (after rcirc-handler-JOIN-pounce activate)
"Process pounces in `rcirc-pounces'."
(rcirc-pounce-process sender))
(defadvice rcirc-handler-MODE (after rcirc-handler-MODE-pounce activate)
"Process pounces in `rcirc-pounces' on mode change."
(rcirc-pounce-process sender))
(provide 'rcirc-pounce)