|
@@ -221,8 +221,14 @@
|
|
|
collect (cons (cons :account (node->alist account t))
|
|
collect (cons (cons :account (node->alist account t))
|
|
|
(node->alist move)))))
|
|
(node->alist move)))))
|
|
|
|
|
|
|
|
-(defun format-changes (entries)
|
|
|
|
|
- (format nil "```~%~{~A~^~%~%~}```" (mapcar #'pta-ledger:render entries)))
|
|
|
|
|
|
|
+(defun format-entries (changes)
|
|
|
|
|
+ (loop for entry in changes
|
|
|
|
|
+ for text = (pta-ledger:render entry)
|
|
|
|
|
+ with page
|
|
|
|
|
+ when (> (+ (length page) (length text) 2)
|
|
|
|
|
+ 2048)
|
|
|
|
|
+ collect (format nil "```~%~A```" page) and do (setf page nil)
|
|
|
|
|
+ do (setf page (format nil "~@[~A~%~%~]~A" page text))))
|
|
|
|
|
|
|
|
(defun format-balance (accounts)
|
|
(defun format-balance (accounts)
|
|
|
(format nil "```~%~{~A~^~%~}```" (mapcar #'account->balance accounts)))
|
|
(format nil "```~%~{~A~^~%~}```" (mapcar #'account->balance accounts)))
|
|
@@ -267,7 +273,7 @@
|
|
|
(intern "LEDGER/NEW-CHAT-ENTRY" ledger-package))))
|
|
(intern "LEDGER/NEW-CHAT-ENTRY" ledger-package))))
|
|
|
(dolist (entry changes)
|
|
(dolist (entry changes)
|
|
|
(funcall new-chat-entry chat-id entry)))
|
|
(funcall new-chat-entry chat-id entry)))
|
|
|
- (bot-send-message chat-id (format-changes changes) :parse-mode "markdown"))))
|
|
|
|
|
|
|
+ (bot-send-message chat-id (format-entries changes) :parse-mode "markdown"))))
|
|
|
(setf (gethash chat-id *last-entries*) new)))))
|
|
(setf (gethash chat-id *last-entries*) new)))))
|
|
|
|
|
|
|
|
(def-message-cmd-handler handler-raif (:raif)
|
|
(def-message-cmd-handler handler-raif (:raif)
|
|
@@ -275,4 +281,4 @@
|
|
|
(if (string= arg "bal")
|
|
(if (string= arg "bal")
|
|
|
(bot-send-message chat-id (format-balance (get-chat-accounts chat-id)) :parse-mode "markdown")
|
|
(bot-send-message chat-id (format-balance (get-chat-accounts chat-id)) :parse-mode "markdown")
|
|
|
(let ((last (get-chat-last-entries chat-id (* (if arg (parse-integer arg) 7) +day+))))
|
|
(let ((last (get-chat-last-entries chat-id (* (if arg (parse-integer arg) 7) +day+))))
|
|
|
- (bot-send-message chat-id (format-changes last) :parse-mode "markdown")))))
|
|
|
|
|
|
|
+ (bot-send-message chat-id (format-entries last) :parse-mode "markdown")))))
|