|
@@ -7,22 +7,25 @@
|
|
|
(defvar *telegram-timeout* 30 "Default Telegram timeout")
|
|
(defvar *telegram-timeout* 30 "Default Telegram timeout")
|
|
|
|
|
|
|
|
(defun %telegram-api-call (method &optional args)
|
|
(defun %telegram-api-call (method &optional args)
|
|
|
- (let* ((params (loop for (k . v) in args when v
|
|
|
|
|
- collect (cons
|
|
|
|
|
- (princ-to-string k)
|
|
|
|
|
- (if (pathnamep v) v
|
|
|
|
|
- (princ-to-string v)))))
|
|
|
|
|
- (timeout (+ 5 (or (aget "timeout" args)
|
|
|
|
|
- *telegram-timeout*)))
|
|
|
|
|
- (response
|
|
|
|
|
- (json-request (format nil +telegram-api-format+
|
|
|
|
|
- *telegram-token* method)
|
|
|
|
|
- :method :post
|
|
|
|
|
- :content params
|
|
|
|
|
- :timeout timeout)))
|
|
|
|
|
- (unless (aget "ok" response)
|
|
|
|
|
- (error (aget "description" response)))
|
|
|
|
|
- (aget "result" response)))
|
|
|
|
|
|
|
+ (handler-case
|
|
|
|
|
+ (let* ((params (loop for (k . v) in args when v
|
|
|
|
|
+ collect (cons
|
|
|
|
|
+ (princ-to-string k)
|
|
|
|
|
+ (if (pathnamep v) v
|
|
|
|
|
+ (princ-to-string v)))))
|
|
|
|
|
+ (timeout (+ 5 (or (aget "timeout" args)
|
|
|
|
|
+ *telegram-timeout*)))
|
|
|
|
|
+ (response
|
|
|
|
|
+ (json-request (format nil +telegram-api-format+
|
|
|
|
|
+ *telegram-token* method)
|
|
|
|
|
+ :method :post
|
|
|
|
|
+ :content params
|
|
|
|
|
+ :timeout timeout)))
|
|
|
|
|
+ (unless (aget "ok" response)
|
|
|
|
|
+ (error (aget "description" response)))
|
|
|
|
|
+ (aget "result" response))
|
|
|
|
|
+ (dex:http-request-forbidden (e)
|
|
|
|
|
+ (log:info "Forbidden" e))))
|
|
|
|
|
|
|
|
(defun telegram-get-updates (&key offset limit timeout)
|
|
(defun telegram-get-updates (&key offset limit timeout)
|
|
|
(%telegram-api-call
|
|
(%telegram-api-call
|