|
|
@@ -460,6 +460,26 @@
|
|
|
(db-vk-ensure-domain domain last-id)
|
|
|
domain))
|
|
|
|
|
|
+(defun %vk-find-best-photo (photo)
|
|
|
+ (let ((sizes (loop for (k . v) in photo
|
|
|
+ when (equal "photo_" (subseq k 0 (min 6 (length k))))
|
|
|
+ collect (cons (parse-integer (subseq k 6)) v))))
|
|
|
+ (cdr (assoc (apply #'max (mapcar #'car sizes)) sizes))))
|
|
|
+
|
|
|
+(defun %format-attachment (item)
|
|
|
+ (cond
|
|
|
+ ((equal "photo" (aget "type" item))
|
|
|
+ (%vk-find-best-photo (aget "photo" item)))))
|
|
|
+
|
|
|
+(defun %vk-post-text (post)
|
|
|
+ (alexandria:when-let (reposts (aget "copy_history" post))
|
|
|
+ (setf post (car (last reposts))))
|
|
|
+ (let ((text (aget "text" post))
|
|
|
+ (attachs (format nil "~{~A~^~%~}"
|
|
|
+ (remove nil (mapcar #'%format-attachment
|
|
|
+ (aget "attachments" post))))))
|
|
|
+ (format nil "~{~A~^~%~}" (remove "" (list text attachs) :test #'equal))))
|
|
|
+
|
|
|
(defun %format-wall-post (domain post)
|
|
|
(format nil "[~A](https://vk.com/~A?w=wall~A_~A)~@[ @ _~A_~]~%~A~%"
|
|
|
domain domain (aget "from_id" post) (aget "id" post)
|
|
|
@@ -468,7 +488,7 @@
|
|
|
nil ts
|
|
|
:format '((:year 2) "-" (:month 2) "-" (:day 2)
|
|
|
" " (:hour 2) ":" (:min 2))))
|
|
|
- (aget "text" post)))
|
|
|
+ (%vk-post-text post)))
|
|
|
|
|
|
(defun handle-cmd-wall (chat-id message-id args)
|
|
|
(log:info "handle-cmd-wall" chat-id message-id args)
|