feat(emacs-org): Add telegram notifications

This commit is contained in:
js0ny 2025-02-27 03:26:18 +00:00
parent bab5604731
commit 59ee28eef6
6 changed files with 66 additions and 23 deletions

View file

@ -0,0 +1,51 @@
;;; org-pomodoro-telegram-notifier.el --- 发送 Telegram 通知当 org-pomodoro 休息结束
(require 'org-pomodoro)
(require 'request)
(defcustom org-pomodoro-telegram-bot-token ""
"你的 Telegram Bot Token。"
:type 'string
:group 'org-pomodoro)
(defcustom org-pomodoro-telegram-chat-id ""
"接收通知的 Telegram Chat ID。"
:type 'string
:group 'org-pomodoro)
(defcustom org-pomodoro-telegram-break-end-message "休息时间结束"
"休息结束时发送的消息。"
:type 'string
:group 'org-pomodoro)
(defun org-pomodoro-send-telegram-message (message)
(interactive)
"使用 Telegram bot 发送消息。"
(when (and (not (string-empty-p org-pomodoro-telegram-bot-token))
(not (string-empty-p org-pomodoro-telegram-chat-id)))
(request
(format "https://api.telegram.org/bot%s/sendMessage" org-pomodoro-telegram-bot-token)
:type "POST"
:data `(("chat_id" . ,org-pomodoro-telegram-chat-id)
("text" . ,"⏳<b>[Emacs]</b> <code>org-pomodoro</code>: 休息时间结束")
("parse_mode" . "HTML"))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "成功发送 Telegram 通知")))
:error (cl-function
(lambda (&key error-thrown &allow-other-keys)
(message "发送 Telegram 通知失败: %S" error-thrown))))
)
)
(defun org-pomodoro-telegram-break-finished-hook ()
"当休息时间结束时发送 Telegram 通知。"
(org-pomodoro-send-telegram-message org-pomodoro-telegram-break-end-message))
(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
(add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
(provide 'org-pomodoro-telegram-notifier)
;;; org-pomodoro-telegram-notifier.el ends here

2
tools/doom/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
org-pomo-music.el
.custom.el

View file

@ -1,15 +0,0 @@
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("5c7720c63b729140ed88cf35413f36c728ab7c70f8cd8422d9ee1cedeb618de5" "e4a702e262c3e3501dfe25091621fe12cd63c7845221687e36a79e17cf3a67e0" "456697e914823ee45365b843c89fbc79191fdbaff471b29aad9dcbe0ee1d5641" "3c08da65265d80a7c8fc99fe51df3697d0fa6786a58a477a1b22887b4f116f62" "df6dfd55673f40364b1970440f0b0cb8ba7149282cf415b81aaad2d98b0f0290" "0325a6b5eea7e5febae709dab35ec8648908af12cf2d2b569bedc8da0a3a81c1" "d6b934330450d9de1112cbb7617eaf929244d192c4ffb1b9e6b63ad574784aad" "56044c5a9cc45b6ec45c0eb28df100d3f0a576f18eef33ff8ff5d32bac2d9700" "2b501400e19b1dd09d8b3708cefcb5227fda580754051a24e8abf3aff0601f87" default)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(org-verbatim ((t (:foreground "orange")))))
(put 'customize-face 'disabled nil)
(put 'customize-variable 'disabled nil)

View file

@ -121,7 +121,7 @@
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
;;data ; config/data formats
data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
@ -140,15 +140,15 @@
(haskell +lsp) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python
;;idris ; a language you can depend on
;;json ; At least it ain't XML
(json +lsp +tree-sitter) ; At least it ain't XML
;;(java +lsp) ; the poster child for carpal tunnel syndrome
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
latex ; writing papers in Emacs has never been so fun
(latex +latexmk +cdlatex +lsp) ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove
;;ledger ; be audit you can be
lua ; one-based indices? one-based indices
;lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
;;nix ; I hereby declare "nix geht mehr!"
@ -164,7 +164,7 @@
;;plantuml ; diagrams for confusing people more
;;graphviz ; diagrams for confusing yourself even more
;;purescript ; javascript, but functional
python ; beautiful is better than ugly
(python +lsp +tree-sitter +pyright) ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
@ -174,13 +174,13 @@
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
(scheme +guile) ; a fully conniving family of lisps
sh ; she sells {ba,z,fi}sh shells on the C xor
(sh +lsp +tree-sitter +fish) ; she sells {ba,z,fi}sh shells on the C xor
;;sml
;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance.
;;web ; the tubes
;;yaml ; JSON, but readable
(yaml +lsp +tree-sitter) ; JSON, but readable
;;zig ; C, but simpler
:email
@ -198,3 +198,6 @@
:config
;;literate
(default +bindings +smartparens))
(setq custom-file (expand-file-name ".custom.el" doom-user-dir))
(load custom-file t)

View file

@ -100,3 +100,5 @@
(if (bound-and-true-p ISMAC)
(setq org-babel-C-compiler "clang"))
(load! "+pomodoro-telegram.el")