Created
November 5, 2023 18:36
-
-
Save tychoish/9dde2739b31a5be1318d1985472b0672 to your computer and use it in GitHub Desktop.
This file contains 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 telega--chat-observable-p (msg) | |
(let ((chat (telega-msg-chat msg))) | |
(with-telega-chatbuf chat | |
(and (telega-chatbuf--msg-observable-p msg) | |
(not (telega-chatbuf--history-state-get :newer-freezed)))))) | |
(defun telega-notifications-msg-notify-p (msg) | |
"tychoish's custom override for notificationable" | |
(let* ((chat (telega-msg-chat msg)) | |
(title (plist-get chat :title))) | |
(cond | |
;; if it's muted, don't notify | |
((telega-chat-muted-p chat) | |
(progn (telega-debug "NOTIFY-CHECK: muted chat [%s], skip notify" title) nil)) | |
;; chat window is open, don't notify | |
((telega--chat-observable-p msg) | |
(progn (telega-debug "NOTIFY-CHECK: observed chat [%s], skip notify" title) nil)) | |
;; if we have a mention definitely notify | |
((plist-get msg :contains_unread_mention) | |
(progn (telega-debug "NOTIFY-CHECK: contains mentions [%s], notify notify" title) t)) | |
;; notifications are explicitly disabled | |
((telega-chat-notification-setting chat :disable_mention_notifications) | |
(progn (telega-debug "NOTIFY-CHECK: disabled notifications [%s], skip" title) nil)) | |
;; definitely notify for DMs | |
((telega-chat-match-p chat '(or (type private secret))) | |
(progn (telega-debug "NOTIFY-CHECK: is DM [%s], can notify" title) t)) | |
;; for things that are a group, and I am a member, notify | |
((telega-chat-match-p chat 'me-is-member) | |
(progn (telega-debug "NOTIFY-CHECK: member of a group [%s], can notify" title) t)) | |
;; get messages from bots and notify them | |
((telega-chat-match-p chat '(type bot)) | |
(progn (telega-debug "NOTIFY-CHECK: from bot [%s], can notify" title) t)) | |
;; notify, in this very weird case | |
(t | |
(progn (telega-debug "NOTIFY-CHECK: got something weird [%s], notifying anyway" title) t))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment