|
|
@@ -474,20 +474,28 @@
|
|
|
(defparameter +vk-link-scanner+ (cl-ppcre:create-scanner "\\[((id|club)\\d+)\\|([^\\]]*?)\\]") "vk linking regex")
|
|
|
|
|
|
(defun %vk-post-text (post)
|
|
|
- (alexandria:when-let (reposts (aget "copy_history" post))
|
|
|
- (setf post (car (last reposts))))
|
|
|
- (values
|
|
|
- (cl-ppcre:regex-replace-all +vk-link-scanner+
|
|
|
- (aget "text" post)
|
|
|
- "[\\3](https://vk.com/\\1)")
|
|
|
- (%vk-find-picture (aget "attachments" post))))
|
|
|
-
|
|
|
-(defun %format-wall-post (domain post)
|
|
|
- (multiple-value-bind (text preview) (%vk-post-text post)
|
|
|
+ (let* ((history (aget "copy_history" post))
|
|
|
+ (reposts (loop for p in history
|
|
|
+ collect (let* ((owner (aget "owner_id" p))
|
|
|
+ (type (if (> owner 0) "id" "club"))
|
|
|
+ (id (abs owner)))
|
|
|
+ (format nil "[~A](https://vk.com/~A~A)"
|
|
|
+ (vk-get-name owner) type id)))))
|
|
|
+ (when history
|
|
|
+ (setf post (car (last history))))
|
|
|
(values
|
|
|
- (format nil "~@[[✅](~A)~] [~A](https://vk.com/~A?w=wall~A_~A)~@[ @ ~A~]~%~A"
|
|
|
- preview domain domain (aget "from_id" post) (aget "id" post)
|
|
|
- (format-ts (local-time:unix-to-timestamp (aget "date" post)))
|
|
|
+ (cl-ppcre:regex-replace-all +vk-link-scanner+
|
|
|
+ (aget "text" post)
|
|
|
+ "[\\3](https://vk.com/\\1)")
|
|
|
+ (%vk-find-picture (aget "attachments" post))
|
|
|
+ reposts)))
|
|
|
+
|
|
|
+(defun %format-wall-post (domain name post)
|
|
|
+ (multiple-value-bind (text preview reposts) (%vk-post-text post)
|
|
|
+ (values
|
|
|
+ (format nil "~@[[✅](~A)~] [~A](https://vk.com/~A?w=wall~A_~A)~@[ ~{↩ ~A~}~]~@[ @ ~A~]~%~A"
|
|
|
+ preview name domain (aget "from_id" post) (aget "id" post)
|
|
|
+ reposts (format-ts (local-time:unix-to-timestamp (aget "date" post)))
|
|
|
text)
|
|
|
(if preview 0 1))))
|
|
|
|
|
|
@@ -524,14 +532,17 @@
|
|
|
(handler-case
|
|
|
(let ((new-posts
|
|
|
(remove last-id (reverse (aget "items" (vk-wall-get :domain domain)))
|
|
|
- :test #'>= :key (lambda (p) (aget "id" p)))))
|
|
|
+ :test #'>= :key (lambda (p) (aget "id" p))))
|
|
|
+ name)
|
|
|
(setf period (adjust-period period (length new-posts)))
|
|
|
+ (when new-posts
|
|
|
+ (setf name (vk-get-name domain)))
|
|
|
(dolist (post new-posts)
|
|
|
- (dolist (chat-id (db-vk-get-domain-chats domain))
|
|
|
- (ignore-errors
|
|
|
- (multiple-value-bind (text disable) (%format-wall-post domain post)
|
|
|
- (telegram-send-message chat-id
|
|
|
- text
|
|
|
+ (multiple-value-bind (text disable)
|
|
|
+ (%format-wall-post domain name post)
|
|
|
+ (dolist (chat-id (db-vk-get-domain-chats domain))
|
|
|
+ (ignore-errors
|
|
|
+ (telegram-send-message chat-id text
|
|
|
:parse-mode "Markdown"
|
|
|
:disable-web-preview disable))))
|
|
|
(setf last-id (max last-id (aget "id" post)))))
|