diff options
Diffstat (limited to 'src/inline-bots.lisp')
| -rw-r--r-- | src/inline-bots.lisp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp index 94ed478..6001cb2 100644 --- a/src/inline-bots.lisp +++ b/src/inline-bots.lisp | |||
| @@ -1,7 +1,9 @@ | |||
| 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/inline-bots | 3 | (defpackage :ukkoclot/inline-bots |
| 4 | (:documentation "This package deals with removing unwanted inline bot usage") | ||
| 4 | (:use :c2cl :ukkoclot/config :ukkoclot/tg) | 5 | (:use :c2cl :ukkoclot/config :ukkoclot/tg) |
| 6 | (:import-from :com.dieggsy.f-string :enable-f-strings) | ||
| 5 | (:import-from :log) | 7 | (:import-from :log) |
| 6 | (:import-from :ukkoclot/tg :send-message :try-delete-message) | 8 | (:import-from :ukkoclot/tg :send-message :try-delete-message) |
| 7 | (:import-from :ukkoclot/state :bot-config :bot-db) | 9 | (:import-from :ukkoclot/state :bot-config :bot-db) |
| @@ -9,10 +11,18 @@ | |||
| 9 | (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) | 11 | (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) |
| 10 | (in-package :ukkoclot/inline-bots) | 12 | (in-package :ukkoclot/inline-bots) |
| 11 | 13 | ||
| 14 | (enable-f-strings) | ||
| 15 | |||
| 12 | (defun blacklist-inline-bot (bot inline-bot-id) | 16 | (defun blacklist-inline-bot (bot inline-bot-id) |
| 17 | "Blacklist the given bot. | ||
| 18 | |||
| 19 | No more messages about deleting its messages will be sent." | ||
| 13 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :blacklisted)) | 20 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :blacklisted)) |
| 14 | 21 | ||
| 15 | (defun whitelist-inline-bot (bot inline-bot-id) | 22 | (defun whitelist-inline-bot (bot inline-bot-id) |
| 23 | "Whitelist the given bot. | ||
| 24 | |||
| 25 | Its messages will no longer be deleted." | ||
| 16 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :whitelisted)) | 26 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :whitelisted)) |
| 17 | 27 | ||
| 18 | (defun on-inline-bot (bot msg via) | 28 | (defun on-inline-bot (bot msg via) |
| @@ -26,17 +36,16 @@ | |||
| 26 | (unless (eql ty :blacklisted) | 36 | (unless (eql ty :blacklisted) |
| 27 | ;; Not explicitly blacklisted, notify dev group | 37 | ;; Not explicitly blacklisted, notify dev group |
| 28 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" | 38 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" |
| 29 | :callback-data (format nil "bwl:~A" (user-id via)))) | 39 | :callback-data #f"bwl:{(user-id via)}")) |
| 30 | (blacklist (make-inline-keyboard-button :text "Blacklist" | 40 | (blacklist (make-inline-keyboard-button :text "Blacklist" |
| 31 | :callback-data (format nil "bbl:~A" (user-id via))))) | 41 | :callback-data #f"bbl:{(user-id via)}"))) |
| 32 | (send-message bot | 42 | (send-message |
| 33 | :chat-id (config-dev-group (bot-config bot)) | 43 | bot |
| 34 | :text (format nil "Deleted a message sent via inline bot @~A <code>~A</code>" | 44 | :chat-id (config-dev-group (bot-config bot)) |
| 35 | (user-username via) | 45 | :text #f"Deleted a message sent via inline bot @{(user-username via)} <code>{(user-id via)}</code>" |
| 36 | (user-id via)) | 46 | :parse-mode html |
| 37 | :parse-mode html | 47 | :reply-markup (make-inline-keyboard-markup |
| 38 | :reply-markup (make-inline-keyboard-markup | 48 | :inline-keyboard |
| 39 | :inline-keyboard | 49 | (make-array '(1 2) |
| 40 | (make-array '(1 2) | 50 | :initial-contents |
| 41 | :initial-contents | 51 | (list (list whitelist blacklist))))))))))) |
| 42 | (list (list whitelist blacklist))))))))))) | ||