summaryrefslogtreecommitdiff
path: root/src/main.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.lisp b/src/main.lisp
index 4cb8c19..13da5af 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -1,6 +1,7 @@
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/src/main 3(defpackage :ukkoclot/src/main
4 (:documentation "Main package of Ukkoclot")
4 (:nicknames :ukkoclot) 5 (:nicknames :ukkoclot)
5 (:use :c2cl :iterate :ukkoclot/src/inline-bots :ukkoclot/src/tg) 6 (:use :c2cl :iterate :ukkoclot/src/inline-bots :ukkoclot/src/tg)
6 (:import-from :alexandria :when-let) 7 (:import-from :alexandria :when-let)
@@ -24,6 +25,7 @@
24 25
25(-> main () (values &optional)) 26(-> main () (values &optional))
26(defun main () 27(defun main ()
28 "Entry point in ukkoclot."
27 (unwind-protect 29 (unwind-protect
28 (progn 30 (progn
29 (conf:load-config #P"config.lisp") 31 (conf:load-config #P"config.lisp")
@@ -32,6 +34,7 @@
32 (log:info "Quitting!"))) 34 (log:info "Quitting!")))
33 35
34(defmacro reporty ((evt) &body body) 36(defmacro reporty ((evt) &body body)
37 "Catches all errors and reports them to developer group if `*in-prod*' is true."
35 `(cond 38 `(cond
36 (*in-prod* 39 (*in-prod*
37 (handler-case (progn ,@body) ; lint:suppress redundant-progn 40 (handler-case (progn ,@body) ; lint:suppress redundant-progn
@@ -40,6 +43,7 @@
40 43
41(-> main-with-config () (values &optional)) 44(-> main-with-config () (values &optional))
42(defun main-with-config () 45(defun main-with-config ()
46 "Call after `conf:*config*' has been initialised."
43 (unwind-protect 47 (unwind-protect
44 (with-db (db (conf:db-path)) 48 (with-db (db (conf:db-path))
45 (setf *state* (make-state db)) 49 (setf *state* (make-state db))
@@ -49,6 +53,7 @@
49 53
50(-> wrapped-main () (values &optional)) 54(-> wrapped-main () (values &optional))
51(defun wrapped-main () 55(defun wrapped-main ()
56 "Call after `*state*' has been initalised."
52 (when *in-prod* 57 (when *in-prod*
53 (send-message :chat-id (conf:dev-group) :text "Initializing...")) 58 (send-message :chat-id (conf:dev-group) :text "Initializing..."))
54 (set-my-name :name (conf:bot-name)) 59 (set-my-name :name (conf:bot-name))
@@ -80,8 +85,11 @@
80 (let ((bot-id (read-from-string data t nil :start 4))) 85 (let ((bot-id (read-from-string data t nil :start 4)))
81 (blacklist-inline-bot bot-id)) 86 (blacklist-inline-bot bot-id))
82 (when-let (msg (callback-query-message cb)) 87 (when-let (msg (callback-query-message cb))
83 (delete-message :chat-id (message-chat-id msg) 88 (handler-case
84 :message-id (message-id msg))) 89 (delete-message :chat-id (message-chat-id msg)
90 :message-id (message-id msg))
91 (error (e)
92 (reply-message msg #f"BTW couldn't delete this jsyk {e}"))))
85 (answer-callback-query :callback-query-id (callback-query-id cb) 93 (answer-callback-query :callback-query-id (callback-query-id cb)
86 :text "OK")) 94 :text "OK"))
87 ((and data 95 ((and data
@@ -91,8 +99,11 @@
91 (let ((bot-id (read-from-string data t nil :start 4))) 99 (let ((bot-id (read-from-string data t nil :start 4)))
92 (whitelist-inline-bot bot-id)) 100 (whitelist-inline-bot bot-id))
93 (when-let (msg (callback-query-message cb)) 101 (when-let (msg (callback-query-message cb))
94 (delete-message :chat-id (message-chat-id msg) 102 (handler-case
95 :message-id (message-id msg))) 103 (delete-message :chat-id (message-chat-id msg)
104 :message-id (message-id msg))
105 (error (e)
106 (reply-message msg #f"BTW couldn't delete this jsyk {e}"))))
96 (answer-callback-query :callback-query-id (callback-query-id cb) 107 (answer-callback-query :callback-query-id (callback-query-id cb)
97 :text "OK")) 108 :text "OK"))
98 (t 109 (t