Innokenty Enikev vor 10 Jahren
Ursprung
Commit
661e9ad0ef
2 geänderte Dateien mit 13 neuen und 11 gelöschten Zeilen
  1. 1 1
      chatikbot.lisp
  2. 12 10
      finance.lisp

+ 1 - 1
chatikbot.lisp

@@ -204,7 +204,7 @@
              (gbp (or (null args) (find "gbp" args :test #'equal)))
              (brent (or (null args) (find "brent" args :test #'equal)))
              (rates (rest (peek-circular *per-minute-rates*))))
-        (if (or usd eur gbp)
+        (if (or usd eur gbp brent)
           (telegram-send-photo chat-id
                                (make-chart *per-minute-rates*
                                            :usd usd :eur eur

+ 12 - 10
finance.lisp

@@ -24,20 +24,22 @@
 
 (defun get-brent ()
   (handler-case
-      (read-from-string
-       (aget "last" (first (aget "quotes"
-                                 (yason:parse
-                                  (flexi-streams:octets-to-string
-                                   (drakma:http-request +brent-url+
-                                                        :force-binary t
-                                                        :decode-content t)
-                                   :external-format :utf-8)
-                                  :object-as :alist)))))
+      (let ((last (read-from-string
+                   (aget "last" (first (aget "quotes"
+                                             (yason:parse
+                                              (flexi-streams:octets-to-string
+                                               (drakma:http-request +brent-url+
+                                                                    :force-binary t
+                                                                    :decode-content t)
+                                               :external-format :utf-8)
+                                              :object-as :alist)))))))
+        (when (numberp last)
+          last))
     (error (e) (log:error e))))
 
 (defun get-serie (series name)
   (loop for (time . rates) in series
-     when (aget name rates)
+     when (numberp (aget name rates))
      collect (list time (aget name rates))))
 
 (defun make-chart (series &key (usd t) (eur t) (gbp t) (brent t))