1
0
Innocenty Enikeew 8 лет назад
Родитель
Сommit
6272689d09
2 измененных файлов с 7 добавлено и 3 удалено
  1. 2 2
      crypto.lisp
  2. 5 1
      utils.lisp

+ 2 - 2
crypto.lisp

@@ -21,7 +21,7 @@
   (when (find #\: data)
   (when (find #\: data)
     (error "Bad data."))
     (error "Bad data."))
   (let* ((message (format nil "~A:~A:~A:~A"
   (let* ((message (format nil "~A:~A:~A:~A"
-                          (base64:integer-to-base64-string chat-id)
+                          chat-id
                           (base64:integer-to-base64-string
                           (base64:integer-to-base64-string
                            (+ ttl (local-time:timestamp-to-universal (local-time:now))))
                            (+ ttl (local-time:timestamp-to-universal (local-time:now))))
                           section data))
                           section data))
@@ -35,7 +35,7 @@
       (split-sequence:split-sequence #\$ raw-data :from-end t :count 2)
       (split-sequence:split-sequence #\$ raw-data :from-end t :count 2)
     (destructuring-bind (cid expire section data)
     (destructuring-bind (cid expire section data)
         (split-sequence:split-sequence #\: message :count 4)
         (split-sequence:split-sequence #\: message :count 4)
-      (unless (= chat-id (base64:base64-string-to-integer cid))
+      (unless (= chat-id (parse-integer cid))
         (error "Wrong chat id."))
         (error "Wrong chat id."))
       (unless (>= (base64:base64-string-to-integer expire)
       (unless (>= (base64:base64-string-to-integer expire)
                   (local-time:timestamp-to-universal (local-time:now)))
                   (local-time:timestamp-to-universal (local-time:now)))

+ 5 - 1
utils.lisp

@@ -75,7 +75,11 @@
 (defun run-hooks (event &rest arguments)
 (defun run-hooks (event &rest arguments)
   (let ((hooks (gethash event *hooks*)))
   (let ((hooks (gethash event *hooks*)))
     (labels ((try-handle (func)
     (labels ((try-handle (func)
-               (apply func arguments)))
+               (handler-case
+                   (apply func arguments)
+                 (error (e)
+                   (log:error "Error processing event ~A: ~A" event e)
+                   nil))))
       (unless (some #'try-handle hooks)
       (unless (some #'try-handle hooks)
         (log:info "unhandled" event arguments)))))
         (log:info "unhandled" event arguments)))))