|
@@ -83,6 +83,28 @@
|
|
|
((null args) (ledger/handle-balance chat-id "assets"))
|
|
((null args) (ledger/handle-balance chat-id "assets"))
|
|
|
(:otherwise (ledger/handle-balance chat-id (spaced args)))))
|
|
(:otherwise (ledger/handle-balance chat-id (spaced args)))))
|
|
|
|
|
|
|
|
|
|
+(defun ledger/handle-journal (chat-id query)
|
|
|
|
|
+ (let ((pair (gethash chat-id *ledger/chat-journals*)))
|
|
|
|
|
+ (if pair
|
|
|
|
|
+ (destructuring-bind (journal . ut) pair
|
|
|
|
|
+ (let* ((entries (pta-ledger:journal-print journal query))
|
|
|
|
|
+ (len (length entries))
|
|
|
|
|
+ (count (min len 20)))
|
|
|
|
|
+ (bot-send-message chat-id (format nil "```~%~{~A~^ ~%~%~}```Обновлено: ~A"
|
|
|
|
|
+ (subseq entries (- len count) len)
|
|
|
|
|
+ (ledger/format-time ut))
|
|
|
|
|
+ :parse-mode "markdown")))
|
|
|
|
|
+ (with-secret (uri (list :ledger chat-id))
|
|
|
|
|
+ (if uri
|
|
|
|
|
+ (progn (ledger/parse-uri chat-id uri)
|
|
|
|
|
+ (ledger/handle-balance chat-id query))
|
|
|
|
|
+ (send-response chat-id "Добавь урл журнала, /ledger <url>"))))))
|
|
|
|
|
+
|
|
|
|
|
+(def-message-cmd-handler handler-journal (:journal)
|
|
|
|
|
+ (cond
|
|
|
|
|
+ ((null args) (ledger/handle-journal chat-id "date:thisweek"))
|
|
|
|
|
+ (:otherwise (ledger/handle-journal chat-id (spaced args)))))
|
|
|
|
|
+
|
|
|
(def-webhook-handler ledger/handle-webhook ("ledger")
|
|
(def-webhook-handler ledger/handle-webhook ("ledger")
|
|
|
(when (= 2 (length paths))
|
|
(when (= 2 (length paths))
|
|
|
(destructuring-bind (chat-id hmac) paths
|
|
(destructuring-bind (chat-id hmac) paths
|