forked from the-kenny/weechat.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weechat-sauron.el
65 lines (51 loc) · 2.6 KB
/
weechat-sauron.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;;; weechat-sauron --- Sauron Notifications ;; -*- lexical-binding: t -*-
;; Copyright (C) 2013 Moritz Ulrich
;; Author: Moritz Ulrich <[email protected]>
;; Rüdiger Sonderfeld <[email protected]>
;; Aristid Breitkreuz <[email protected]>
;; Keywords: irc chat network weechat
;; URL: https://github.com/the-kenny/weechat.el
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Notifications using Sauron https://github.com/djcb/sauron
;;; Code:
(require 'weechat)
(if (require 'sauron nil 'noerr)
(progn
(defun weechat-sauron-handler (type &optional sender text _date buffer-ptr)
(setq text (if text (weechat-strip-formatting text)))
(setq sender (if sender (weechat-strip-formatting sender)))
(let ((jump-position (point-max-marker)))
(sauron-add-event 'weechat 3
(cl-case type
(:highlight
(format "%s in %s: %S"
sender
(weechat-buffer-name buffer-ptr)
text))
(:query
(format "Query from %s: %S"
sender
text))
(:disconnect
"Disconnected from WeeChat"))
(lambda ()
(when (fboundp 'sauron-switch-to-marker-or-buffer)
(sauron-switch-to-marker-or-buffer jump-position)))
;; Flood protection based on sender
(when sender
(list :sender sender)))))
(add-hook 'weechat-notification-handler-functions
'weechat-sauron-handler))
(weechat-warn "Error while loading weechat-sauron. Sauron notifications are disabled."))
(provide 'weechat-sauron)
;;; weechat-sauron.el ends here