summaryrefslogtreecommitdiff
path: root/src/bot/impl.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bot/impl.lisp')
-rw-r--r--src/bot/impl.lisp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bot/impl.lisp b/src/bot/impl.lisp
index 85f4496..652e2f7 100644
--- a/src/bot/impl.lisp
+++ b/src/bot/impl.lisp
@@ -1,10 +1,11 @@
1;; SPDX-License-Identifier: EUPL-1.2 1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> 2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/bot/impl 3(defpackage :ukkoclot/bot/impl
4 (:use :c2cl :iterate :ukkoclot/config :ukkoclot/log) 4 (:use :c2cl :iterate :ukkoclot/config)
5 (:import-from :anaphora :aand :acond :it) 5 (:import-from :anaphora :aand :acond :it)
6 (:import-from :cl+ssl) 6 (:import-from :cl+ssl)
7 (:import-from :dex) 7 (:import-from :dex)
8 (:import-from :log)
8 (:import-from :ukkoclot/strings :lisp->snake-case) 9 (:import-from :ukkoclot/strings :lisp->snake-case)
9 (:local-nicknames 10 (:local-nicknames
10 (:jzon :com.inuoe.jzon)) 11 (:jzon :com.inuoe.jzon))
@@ -17,7 +18,7 @@
17(defgeneric parse-value (type json) 18(defgeneric parse-value (type json)
18 (:documentation "Parse value of TYPE from the parsed JSON") 19 (:documentation "Parse value of TYPE from the parsed JSON")
19 (:method (type json) 20 (:method (type json)
20 (log-error "I don't know how to parse simple type ~A!" type) 21 (log:error "I don't know how to parse simple type ~A!" type)
21 (error "I don't know how to parse simple type ~A!" type)) 22 (error "I don't know how to parse simple type ~A!" type))
22 (:method ((type (eql 'boolean)) json) 23 (:method ((type (eql 'boolean)) json)
23 (check-type json boolean) 24 (check-type json boolean)
@@ -100,9 +101,9 @@
100 ((gethash "ok" hash) (parse-value type (gethash "result" hash))) 101 ((gethash "ok" hash) (parse-value type (gethash "result" hash)))
101 ((aand (gethash "parameters" hash) 102 ((aand (gethash "parameters" hash)
102 (gethash "retry_after" it)) 103 (gethash "retry_after" it))
103 (log-info "Should sleep for ~A seconds" it) 104 (log:info "Should sleep for ~A seconds" it)
104 (sleep it) 105 (sleep it)
105 (log-info "Good morning!") 106 (log:info "Good morning!")
106 (do-call% bot method uri type args-encoded)) 107 (do-call% bot method uri type args-encoded))
107 (t (error "TG error ~A: ~A ~:A" 108 (t (error "TG error ~A: ~A ~:A"
108 (gethash "error_code" hash) 109 (gethash "error_code" hash)
@@ -112,5 +113,5 @@
112(defun do-call (bot method path type args) 113(defun do-call (bot method path type args)
113 (let ((uri (concatenate 'string (bot-base-uri bot) path)) 114 (let ((uri (concatenate 'string (bot-base-uri bot) path))
114 (args-encoded (fixup-args args))) 115 (args-encoded (fixup-args args)))
115 (log-debug "~A .../~A ~S" method path args-encoded) 116 (log:debug "~A .../~A ~S" method path args-encoded)
116 (do-call% bot method uri type args-encoded))) 117 (do-call% bot method uri type args-encoded)))