mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
feat(emacs-org): Add telegram notifications
This commit is contained in:
parent
bab5604731
commit
59ee28eef6
6 changed files with 66 additions and 23 deletions
2
LICENSE
2
LICENSE
|
|
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
dotfiles Copyright (C) 2024-2025 js0ny
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
|
||||||
51
tools/doom/+pomodoro-telegram.el
Normal file
51
tools/doom/+pomodoro-telegram.el
Normal 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
2
tools/doom/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
org-pomo-music.el
|
||||||
|
.custom.el
|
||||||
|
|
@ -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)
|
|
||||||
|
|
@ -121,7 +121,7 @@
|
||||||
;;coq ; proofs-as-programs
|
;;coq ; proofs-as-programs
|
||||||
;;crystal ; ruby at the speed of c
|
;;crystal ; ruby at the speed of c
|
||||||
;;csharp ; unity, .NET, and mono shenanigans
|
;;csharp ; unity, .NET, and mono shenanigans
|
||||||
;;data ; config/data formats
|
data ; config/data formats
|
||||||
;;(dart +flutter) ; paint ui and not much else
|
;;(dart +flutter) ; paint ui and not much else
|
||||||
;;dhall
|
;;dhall
|
||||||
;;elixir ; erlang done right
|
;;elixir ; erlang done right
|
||||||
|
|
@ -140,15 +140,15 @@
|
||||||
(haskell +lsp) ; a language that's lazier than I am
|
(haskell +lsp) ; a language that's lazier than I am
|
||||||
;;hy ; readability of scheme w/ speed of python
|
;;hy ; readability of scheme w/ speed of python
|
||||||
;;idris ; a language you can depend on
|
;;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
|
;;(java +lsp) ; the poster child for carpal tunnel syndrome
|
||||||
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
|
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||||
;;julia ; a better, faster MATLAB
|
;;julia ; a better, faster MATLAB
|
||||||
;;kotlin ; a better, slicker Java(Script)
|
;;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
|
;;lean ; for folks with too much to prove
|
||||||
;;ledger ; be audit you can be
|
;;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
|
markdown ; writing docs for people to ignore
|
||||||
;;nim ; python + lisp at the speed of c
|
;;nim ; python + lisp at the speed of c
|
||||||
;;nix ; I hereby declare "nix geht mehr!"
|
;;nix ; I hereby declare "nix geht mehr!"
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
;;plantuml ; diagrams for confusing people more
|
;;plantuml ; diagrams for confusing people more
|
||||||
;;graphviz ; diagrams for confusing yourself even more
|
;;graphviz ; diagrams for confusing yourself even more
|
||||||
;;purescript ; javascript, but functional
|
;;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
|
;;qt ; the 'cutest' gui framework ever
|
||||||
;;racket ; a DSL for DSLs
|
;;racket ; a DSL for DSLs
|
||||||
;;raku ; the artist formerly known as perl6
|
;;raku ; the artist formerly known as perl6
|
||||||
|
|
@ -174,13 +174,13 @@
|
||||||
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
||||||
;;scala ; java, but good
|
;;scala ; java, but good
|
||||||
(scheme +guile) ; a fully conniving family of lisps
|
(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
|
;;sml
|
||||||
;;solidity ; do you need a blockchain? No.
|
;;solidity ; do you need a blockchain? No.
|
||||||
;;swift ; who asked for emoji variables?
|
;;swift ; who asked for emoji variables?
|
||||||
;;terra ; Earth and Moon in alignment for performance.
|
;;terra ; Earth and Moon in alignment for performance.
|
||||||
;;web ; the tubes
|
;;web ; the tubes
|
||||||
;;yaml ; JSON, but readable
|
(yaml +lsp +tree-sitter) ; JSON, but readable
|
||||||
;;zig ; C, but simpler
|
;;zig ; C, but simpler
|
||||||
|
|
||||||
:email
|
:email
|
||||||
|
|
@ -198,3 +198,6 @@
|
||||||
:config
|
:config
|
||||||
;;literate
|
;;literate
|
||||||
(default +bindings +smartparens))
|
(default +bindings +smartparens))
|
||||||
|
|
||||||
|
(setq custom-file (expand-file-name ".custom.el" doom-user-dir))
|
||||||
|
(load custom-file t)
|
||||||
|
|
|
||||||
|
|
@ -100,3 +100,5 @@
|
||||||
|
|
||||||
(if (bound-and-true-p ISMAC)
|
(if (bound-and-true-p ISMAC)
|
||||||
(setq org-babel-C-compiler "clang"))
|
(setq org-babel-C-compiler "clang"))
|
||||||
|
|
||||||
|
(load! "+pomodoro-telegram.el")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue