Sfoglia il codice sorgente

[chat-cron] tz fixes

Innocenty Enikeew 8 anni fa
parent
commit
cbdd5e8f5b
5 ha cambiato i file con 9 aggiunte e 9 eliminazioni
  1. 1 1
      chat-cron.lisp
  2. 1 1
      chatikbot.lisp
  3. 1 1
      common.lisp
  4. 1 2
      plugins/ledger.lisp
  5. 5 4
      utils.lisp

+ 1 - 1
chat-cron.lisp

@@ -34,7 +34,7 @@
        for (type chat-id schedule-text args last-run) in (db-select "select type, chat_id, schedule, args, last_run from chat_crons")
        for schedule = (apply #'clon:make-typed-cron-schedule (read-from-string schedule-text))
        for next-time = (clon:next-time schedule :allow-now-p (not last-run) :now (or last-run now))
-       when (and next-time (<= (same-gmt-time-in-chat next-time chat-id) now))
+       when (and next-time (<= (same-time-in-chat next-time chat-id) now))
        do (unwind-protect
                (progn
                  (log:info :chat-cron type chat-id schedule now next-time last-run)

+ 1 - 1
chatikbot.lisp

@@ -69,6 +69,7 @@
   (plugins-db-init)
   (setf *plugins* (flatten (db-select "select name from plugins")))
   (dolist (plugin *plugins*)
+    (log:info "Loading" plugin)
     (handler-case
         (load (merge-pathnames (format nil "plugins/~A.lisp" plugin)
                                (asdf:component-pathname
@@ -90,7 +91,6 @@
          :if-exists :supersede
          :if-does-not-exist :create)))
 
-
 (defun cleanup ()
   ;; Clear prev threads
   (mapc #'trivial-timers:unschedule-timer (trivial-timers:list-all-timers))

+ 1 - 1
common.lisp

@@ -60,7 +60,7 @@
            :symbol-append
            :get-chat-location
            :get-chat-timezone
-           :same-gmt-time-in-chat
+           :same-time-in-chat
            :telegram-get-me
            :telegram-send-message
            :telegram-forward-message

+ 1 - 2
plugins/ledger.lisp

@@ -6,7 +6,6 @@
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (ql:quickload '(:pta-ledger :legit)))
 
-(defsetting *ledger/default-timezone* -3 "Default timezone for time display. GMT+3")
 (defvar *ledger/chat-journals* (make-hash-table))
 
 (defvar *git-repo-locks* (make-hash-table :test #'equal))
@@ -83,7 +82,7 @@
 (defun ledger/format-time (universal-time)
   (when universal-time
     (multiple-value-bind (sec min hour day month year dow dst-p tz)
-        (decode-universal-time universal-time *ledger/default-timezone*)
+        (decode-universal-time universal-time)
       (declare (ignore dow dst-p tz))
       (format nil "~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D"
               year month day hour min sec))))

+ 5 - 4
utils.lisp

@@ -49,7 +49,7 @@
            :symbol-append
            :get-chat-location
            :get-chat-timezone
-           :same-gmt-time-in-chat
+           :same-time-in-chat
            :message-id
            :from-id
            :chat-id
@@ -408,9 +408,10 @@ is replaced with replacement."
           (round (- 7.5 (aget "latitude" chat-loc)) 15))) ;; Nautical time
       *chat-default-timezone*))
 
-(defun same-gmt-time-in-chat (ut chat-id)
-  (let ((tz (get-chat-timezone chat-id)))
-    (+ ut (* tz +hour+))))
+(defun same-time-in-chat (ut chat-id)
+  (let ((chat-tz (get-chat-timezone chat-id))
+        (current-tz (nth-value 8 (get-decoded-time))))
+    (+ ut (* (- chat-tz current-tz) +hour+))))
 
 ;; Fix bug in local-time (following symlinks in /usr/share/zoneinfo/
 ;; leads to bad cutoff)