From a802a63364721a2da95b75bc8ab19abfa4888373 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sat, 18 Oct 2025 08:19:45 +0300 Subject: Bunch more tiny improvements --- src/main.lisp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/main.lisp') diff --git a/src/main.lisp b/src/main.lisp index 94148a7..28c3801 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -6,6 +6,7 @@ (:import-from :alexandria :when-let) (:import-from :com.dieggsy.f-string :enable-f-strings) (:import-from :log) + (:import-from :serapeum :drop) (:import-from :ukkoclot/db :with-db) (:import-from :ukkoclot/serializing :fixup-value) (:import-from :ukkoclot/state :make-bot :bot-config :bot-power-on) @@ -21,10 +22,11 @@ (defvar *in-prod* t) (defmacro reporty ((evt) &body body) - `(if *in-prod* - (handler-case (progn ,@body) - (error (err) (report-error bot ,evt err))) - (progn ,@body))) + `(cond + (*in-prod* + (handler-case (progn ,@body) ; lint:suppress redundant-progn + (error (err) (report-error bot ,evt err)))) + (t ,@body))) (defun main () (log:config :debug) @@ -38,11 +40,10 @@ (defun main-with-config (config) (unwind-protect - (progn - (with-db (db (config-db-path config)) - (let ((bot (make-bot config db))) - ;; TODO: Catch fatal errors & report them - (wrapped-main bot config)))) + (with-db (db (config-db-path config)) + (let ((bot (make-bot config db))) + ;; TODO: Catch fatal errors & report them + (wrapped-main bot config))) (log:info "We're done!"))) (defun wrapped-main (bot config) @@ -161,7 +162,7 @@ (reply-message bot msg ">:3" :parse-mode html)) ((starts-with-ignore-case text "big ") - (let ((the-text (subseq text 4))) + (let ((the-text (drop 4 text))) (unless (is-tg-whitespace-str the-text) (reply-message bot msg (concatenate 'string @@ -190,12 +191,12 @@ "dio cane")) ((starts-with-ignore-case text "say ") - (let ((the-text (subseq text 4))) + (let ((the-text (drop 4 text))) (unless (is-tg-whitespace-str the-text) (reply-message bot msg the-text)))) ((starts-with-ignore-case text "tiny ") - (let ((the-text (subseq text 5))) + (let ((the-text (drop 5 text))) (unless (is-tg-whitespace-str the-text) (reply-message bot msg (map 'string #'(lambda (ch) @@ -227,13 +228,15 @@ (write-string "GIR" s)) (if (char= (elt text 3) #\t) (write-char #\l s) - (write-char #\L s)))))))) + (write-char #\L s))))) + + (t nil)))) (defun simplify-cmd (bot cmd) (let ((at-idx (position #\@ cmd))) (if (null at-idx) - (subseq cmd 1) - (let ((username (subseq cmd (1+ at-idx))) + (drop 1 cmd) + (let ((username (drop (1+ at-idx) cmd)) (my-username (bot-username bot))) (if (equal username my-username) (subseq cmd 1 at-idx) -- cgit v1.2.3