Created
December 2, 2014 10:45
-
-
Save weissjeffm/29d456cf4eb0fc6135ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun rcirc-notify-allowed (nick &optional delay) | |
"Return non-nil if a notification should be made for NICK. | |
If DELAY is specified, it will be the minimum time in seconds | |
that can occur between two notifications. The default is | |
`rcirc-notify-timeout'." | |
(unless delay (setq delay rcirc-notify-timeout)) | |
(let ((cur-time (time-to-seconds (current-time))) | |
(cur-assoc (assoc nick rcirc-notify--nick-alist)) | |
(last-time)) | |
(if cur-assoc | |
(progn | |
(setq last-time (cdr cur-assoc)) | |
(setcdr cur-assoc cur-time) | |
(> (abs (- cur-time last-time)) delay)) | |
(push (cons nick cur-time) rcirc-notify--nick-alist) | |
t))) | |
(defun rcirc-notify-me (proc sender response target text) | |
"Notify the current user when someone sends a message that | |
matches the current nick or keywords." | |
(interactive) | |
(when (and (not (string= (rcirc-nick proc) sender)) | |
(not (string= (rcirc-server-name proc) sender))) | |
(cond ((and (string-match (concat "\\b" (rcirc-nick proc) "\\b") text) | |
(rcirc-notify-allowed sender)) | |
;; (my-rcirc-notify sender text) | |
(my-notify sender target text) ) | |
(rcirc-notify-keywords | |
(let (keywords) | |
(dolist (key rcirc-keywords keywords) | |
(when (string-match (concat "\\<" key "\\>") | |
text) | |
(push key keywords))) | |
(when keywords | |
(if (rcirc-notify-allowed sender) | |
;;(my-rcirc-notify-keyword sender keywords text) | |
(my-notify sender target text)))))))) | |
(defun rcirc-notify-privmsg (proc sender response target text) | |
"Notify the current user when someone sends a private message | |
to them." | |
(interactive) | |
(when (and (string= response "PRIVMSG") | |
(not (string= sender (rcirc-nick proc))) | |
(not (rcirc-channel-p target)) | |
(rcirc-notify-allowed sender)) | |
(my-notify sender target text))) | |
(defun-rcirc-command reconnect (arg) | |
"Reconnect the server process." | |
(interactive "i") | |
(if (buffer-live-p rcirc-server-buffer) | |
(with-current-buffer rcirc-server-buffer | |
(let ((reconnect-buffer (current-buffer)) | |
(server (or rcirc-server rcirc-default-server)) | |
(port (if (boundp 'rcirc-port) rcirc-port rcirc-default-port)) | |
(nick (or rcirc-nick rcirc-default-nick)) | |
channels) | |
(dolist (buf (buffer-list)) | |
(with-current-buffer buf | |
(when (equal reconnect-buffer rcirc-server-buffer) | |
(remove-hook 'change-major-mode-hook | |
'rcirc-change-major-mode-hook) | |
(let ((server-plist (cdr (assoc-string server rcirc-server-alist)))) | |
(when server-plist | |
(setq channels (plist-get server-plist :channels)))) | |
))) | |
(if process (delete-process process)) | |
(rcirc-connect server port nick | |
nil | |
nil | |
channels))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment