From 6ebe4bb09da11cf80850855d7f7b5bc71f8338f2 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Thu, 23 Oct 2025 11:03:08 +0300 Subject: Deal with some deletion errors --- src/main.lisp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/main.lisp') 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 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/src/main + (:documentation "Main package of Ukkoclot") (:nicknames :ukkoclot) (:use :c2cl :iterate :ukkoclot/src/inline-bots :ukkoclot/src/tg) (:import-from :alexandria :when-let) @@ -24,6 +25,7 @@ (-> main () (values &optional)) (defun main () + "Entry point in ukkoclot." (unwind-protect (progn (conf:load-config #P"config.lisp") @@ -32,6 +34,7 @@ (log:info "Quitting!"))) (defmacro reporty ((evt) &body body) + "Catches all errors and reports them to developer group if `*in-prod*' is true." `(cond (*in-prod* (handler-case (progn ,@body) ; lint:suppress redundant-progn @@ -40,6 +43,7 @@ (-> main-with-config () (values &optional)) (defun main-with-config () + "Call after `conf:*config*' has been initialised." (unwind-protect (with-db (db (conf:db-path)) (setf *state* (make-state db)) @@ -49,6 +53,7 @@ (-> wrapped-main () (values &optional)) (defun wrapped-main () + "Call after `*state*' has been initalised." (when *in-prod* (send-message :chat-id (conf:dev-group) :text "Initializing...")) (set-my-name :name (conf:bot-name)) @@ -80,8 +85,11 @@ (let ((bot-id (read-from-string data t nil :start 4))) (blacklist-inline-bot bot-id)) (when-let (msg (callback-query-message cb)) - (delete-message :chat-id (message-chat-id msg) - :message-id (message-id msg))) + (handler-case + (delete-message :chat-id (message-chat-id msg) + :message-id (message-id msg)) + (error (e) + (reply-message msg #f"BTW couldn't delete this jsyk {e}")))) (answer-callback-query :callback-query-id (callback-query-id cb) :text "OK")) ((and data @@ -91,8 +99,11 @@ (let ((bot-id (read-from-string data t nil :start 4))) (whitelist-inline-bot bot-id)) (when-let (msg (callback-query-message cb)) - (delete-message :chat-id (message-chat-id msg) - :message-id (message-id msg))) + (handler-case + (delete-message :chat-id (message-chat-id msg) + :message-id (message-id msg)) + (error (e) + (reply-message msg #f"BTW couldn't delete this jsyk {e}")))) (answer-callback-query :callback-query-id (callback-query-id cb) :text "OK")) (t -- cgit v1.2.3