summaryrefslogtreecommitdiff
path: root/src/state.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.lisp')
-rw-r--r--src/state.lisp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/state.lisp b/src/state.lisp
index 98e2048..597f0a8 100644
--- a/src/state.lisp
+++ b/src/state.lisp
@@ -1,13 +1,15 @@
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/state 3(defpackage :ukkoclot/state
4 (:use :c2cl :ukkoclot/config) 4 (:documentation "Holds the global state")
5 (:use :c2cl)
6 (:import-from :com.dieggsy.f-string :enable-f-strings)
7 (:import-from :conf :bot-token)
5 (:export 8 (:export
6 #:bot 9 #:bot
7 #:make-bot 10 #:make-bot
8 #:bot-p 11 #:bot-p
9 #:copy-bot 12 #:copy-bot
10 #:bot-config
11 #:bot-db 13 #:bot-db
12 #:bot-base-uri 14 #:bot-base-uri
13 #:bot-power-on 15 #:bot-power-on
@@ -15,16 +17,15 @@
15 #:bot-id%)) 17 #:bot-id%))
16(in-package :ukkoclot/state) 18(in-package :ukkoclot/state)
17 19
20(enable-f-strings)
21
18(defstruct (bot (:constructor make-bot%)) 22(defstruct (bot (:constructor make-bot%))
19 (config (error "No value given for config") :read-only t)
20 (db (error "No value given for DB") :read-only t) 23 (db (error "No value given for DB") :read-only t)
21 (base-uri (error "No value given for base-uri") :read-only t) 24 (base-uri (error "No value given for base-uri") :read-only t)
22 (power-on t :type boolean) 25 (power-on t :type boolean)
23 (username% nil :type (or string null)) 26 (username% nil :type (or string null))
24 (id% nil :type (or integer null))) 27 (id% nil :type (or integer null)))
25 28
26(defun make-bot (config db) 29(defun make-bot (db)
27 (let ((base-uri (concatenate 'string 30 (let ((base-uri #f"https://api.telegram.org/bot{(bot-token)}/"))
28 "https://api.telegram.org/bot" 31 (make-bot% :db db :base-uri base-uri)))
29 (config-bot-token config) "/")))
30 (make-bot% :config config :db db :base-uri base-uri)))