From 6c4a545b30c601047091ac9439741ba52a3334d2 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 19 Oct 2025 08:50:52 +0300 Subject: Make state be a global special variable --- src/inline-bots.lisp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/inline-bots.lisp') diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp index 4f6a679..4361adb 100644 --- a/src/inline-bots.lisp +++ b/src/inline-bots.lisp @@ -6,34 +6,33 @@ (:import-from :com.dieggsy.f-string :enable-f-strings) (:import-from :conf) (:import-from :log) - (:import-from :ukkoclot/src/tg :send-message :try-delete-message) - (:import-from :ukkoclot/src/state :bot-db) + (:import-from :state) (:local-nicknames (:db :ukkoclot/src/db)) (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) (in-package :ukkoclot/src/inline-bots) (enable-f-strings) -(defun blacklist-inline-bot (bot inline-bot-id) +(defun blacklist-inline-bot (inline-bot-id) "Blacklist the given bot. No more messages about deleting its messages will be sent." - (db:set-inline-bot-type (bot-db bot) inline-bot-id :blacklisted)) + (db:set-inline-bot-type (state:db) inline-bot-id :blacklisted)) -(defun whitelist-inline-bot (bot inline-bot-id) +(defun whitelist-inline-bot (inline-bot-id) "Whitelist the given bot. Its messages will no longer be deleted." - (db:set-inline-bot-type (bot-db bot) inline-bot-id :whitelisted)) + (db:set-inline-bot-type (state:db) inline-bot-id :whitelisted)) -(defun on-inline-bot (bot msg via) - (let ((ty (db:get-inline-bot-type (bot-db bot) (user-id via)))) +(defun on-inline-bot (msg via) + (let ((ty (db:get-inline-bot-type (state:db) (user-id via)))) (or (eql ty :whitelisted) (prog1 nil (log:info "Deleting an unallowed inline bot message from ~A ~A" (user-username via) (user-id via)) - (try-delete-message bot msg) + (try-delete-message msg) (unless (eql ty :blacklisted) ;; Not explicitly blacklisted, notify dev group (let ((whitelist (make-inline-keyboard-button :text "Whitelist" @@ -41,7 +40,6 @@ Its messages will no longer be deleted." (blacklist (make-inline-keyboard-button :text "Blacklist" :callback-data #f"bbl:{(user-id via)}"))) (send-message - bot :chat-id (conf:dev-group) :text #f"Deleted a message sent via inline bot @{(user-username via)} {(user-id via)}" :parse-mode html -- cgit v1.2.3