Parcourir la source

[tescort] text-chunks

Innocenty Enikeew il y a 7 ans
Parent
commit
d795f6a252
1 fichiers modifiés avec 9 ajouts et 8 suppressions
  1. 9 8
      plugins/tescort.lisp

+ 9 - 8
plugins/tescort.lisp

@@ -58,19 +58,20 @@
 (defun merge-results (results)
   (loop for (name . res) in results append res))
 
-(defun format-blacklist (blacklist)
-  (with-output-to-string (s)
-    (loop for item in blacklist
-       do (format s "~A, ~A: ~A *~A*~%~A~%~%"
-                  (agets item :date) (agets item :city)
-                  (agets item :name) (agets item :phone)
-                  (agets item :comment)))))
+(defun format-blacklist (item)
+  (format nil "~A, ~A: ~A *~A*~%~A"
+          (agets item :date) (agets item :city)
+          (agets item :name) (agets item :phone)
+          (agets item :comment)))
 
 (defun handle-blacklist (chat-id query)
   (with-chat-cookies (chat-id *chat-cookie-jars*)
     (telegram-send-chat-action chat-id "typing")
     (let ((results (merge-results (search-blacklists query))))
-      (bot-send-message chat-id (if results (format-blacklist results) "Not found")
+      (bot-send-message chat-id (if results
+                                    (text-chunks (mapcar #'format-blacklist results)
+                                                 :pre-pre "" :pre-post "")
+                                    "Not found")
                         :parse-mode "markdown" :disable-web-preview "true"))))
 
 (def-message-cmd-handler handler-cmd-blacklist (:blacklist :bl)