help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ERC: Gets buffer/channel name in erc-text-matched-hook ?


From: Mathieu Poussin
Subject: ERC: Gets buffer/channel name in erc-text-matched-hook ?
Date: Thu, 21 May 2015 18:17:58 +0200

Hello,

I wrote a simple system that send me a notification using pushover and
shows the revelant line in emacs.
Currently I get the nick and message, I would like to include the buffer
name / channel name in the notification message, but I don't know how can I
do this.

Here is my code :

(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 "ERC Notification" (concat "<" (car (split-string nick
"!")) "> " message))
    (display-message-or-buffer (concat "<" (car (split-string nick "!")) ">
" message) "ERC Notifications")
   ))
(add-hook 'erc-text-matched-hook 'erc-global-notify)


How can I do this ?
Thank you.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]