summaryrefslogtreecommitdiff
path: root/src/state.lisp
blob: 6348ee30efa8b2997f3ea3ef3605a19bdacdf057 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;; SPDX-License-Identifier: EUPL-1.2
;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
(defpackage :ukkoclot/src/state
  (:documentation "Holds the global state")
  (:use :c2cl)
  (:import-from :com.dieggsy.f-string :enable-f-strings)
  (:import-from :conf :bot-token)
  (:export
   #:bot
   #:make-bot
   #:bot-p
   #:copy-bot
   #:bot-db
   #:bot-base-uri
   #:bot-power-on
   #:bot-username%
   #:bot-id%))
(in-package :ukkoclot/src/state)

(enable-f-strings)

(defstruct (bot (:constructor make-bot%))
  (db (error "No value given for DB") :read-only t)
  (base-uri (error "No value given for base-uri") :read-only t)
  (power-on t :type boolean)
  (username% nil :type (or string null))
  (id% nil :type (or integer null)))

(defun make-bot (db)
  (let ((base-uri #f"https://api.telegram.org/bot{(bot-token)}/"))
    (make-bot% :db db :base-uri base-uri)))