소스 검색

[nalunch] fix same balance and strip comments

Innocenty Enikeew 8 년 전
부모
커밋
77833586c5
2개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 2
      plugins/nalunch.lisp
  2. 6 1
      utils.lisp

+ 2 - 2
plugins/nalunch.lisp

@@ -56,7 +56,6 @@
                                   collect (list (cons :time (format nil "~A ~A" date time))
                                   collect (list (cons :time (format nil "~A ~A" date time))
                                                 (cons :price price)
                                                 (cons :price price)
                                                 (cons :place place))))))
                                                 (cons :place place))))))
-
         (list (cons :balance balance)
         (list (cons :balance balance)
               (cons :recent recent))))))
               (cons :recent recent))))))
 
 
@@ -106,7 +105,8 @@
                  (old (gethash chat-id *nalunch/last-results*))
                  (old (gethash chat-id *nalunch/last-results*))
                  (new (nalunch/recent (car login-pass) (cdr login-pass) cookie-jar)))
                  (new (nalunch/recent (car login-pass) (cdr login-pass) cookie-jar)))
             (when new
             (when new
-              (when (and old (not (equal old new)))
+              (when (and old (not (equal (aget :balance old)
+                                         (aget :balance new))))
                 (send-response chat-id (%nalunch/format new t)))
                 (send-response chat-id (%nalunch/format new t)))
               (setf (gethash chat-id *nalunch/last-results*) new
               (setf (gethash chat-id *nalunch/last-results*) new
                     (gethash chat-id *nalunch/jars*) cookie-jar)))
                     (gethash chat-id *nalunch/jars*) cookie-jar)))

+ 6 - 1
utils.lisp

@@ -173,6 +173,7 @@ is replaced with replacement."
       (push (cons :user-agent user-agent) headers)
       (push (cons :user-agent user-agent) headers)
       (remf args :user-agent))
       (remf args :user-agent))
     (remf args :parameters)
     (remf args :parameters)
+    (remf args :headers)
     (apply #'dex:request uri :headers headers args)))
     (apply #'dex:request uri :headers headers args)))
 
 
 ;; XML processing
 ;; XML processing
@@ -218,7 +219,11 @@ is replaced with replacement."
 
 
 (defun select-text (selector node)
 (defun select-text (selector node)
   (ignore-errors
   (ignore-errors
-    (string-trim '(#\Newline #\Space #\Return) (plump:text (elt (clss:select selector node) 0)))))
+    (plump:text (plump:strip
+                 (let ((node (elt (clss:select selector node) 0)))
+                   (plump:traverse node #'(lambda (n) (setf (plump:text n) ""))
+                                   :test #'plump:comment-p)
+                   node)))))
 
 
 ;; JSON processing
 ;; JSON processing
 (defun json-request (url &rest args &key method parameters content headers basic-auth cookie-jar keep-alive use-connection-pool timeout ssl-key-file ssl-cert-file ssl-key-password stream verbose proxy insecure ca-path user-agent (object-as :alist))
 (defun json-request (url &rest args &key method parameters content headers basic-auth cookie-jar keep-alive use-connection-pool timeout ssl-key-file ssl-cert-file ssl-key-password stream verbose proxy insecure ca-path user-agent (object-as :alist))