diff options
| author | 2025-10-09 21:58:43 +0300 | |
|---|---|---|
| committer | 2025-10-09 21:58:43 +0300 | |
| commit | 4da3ad1f569832845b58c3ce35149633a2bb665c (patch) | |
| tree | 5a09a0de66df7ec2e77f0fc9cc68ccbabc190934 /src/inline-bots.lisp | |
| download | ukkoclot-4da3ad1f569832845b58c3ce35149633a2bb665c.tar.gz ukkoclot-4da3ad1f569832845b58c3ce35149633a2bb665c.tar.xz ukkoclot-4da3ad1f569832845b58c3ce35149633a2bb665c.zip | |
Initial commit
Diffstat (limited to 'src/inline-bots.lisp')
| -rw-r--r-- | src/inline-bots.lisp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp new file mode 100644 index 0000000..5945084 --- /dev/null +++ b/src/inline-bots.lisp | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | ;; SPDX-License-Identifier: EUPL-1.2 | ||
| 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> | ||
| 3 | (defpackage :ukkoclot/inline-bots | ||
| 4 | (:use :c2cl :ukkoclot/bot :ukkoclot/config :ukkoclot/log :ukkoclot/tg-types) | ||
| 5 | (:local-nicknames (:db :ukkoclot/db)) | ||
| 6 | (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) | ||
| 7 | (in-package :ukkoclot/inline-bots) | ||
| 8 | |||
| 9 | (defun blacklist-inline-bot (bot inline-bot-id) | ||
| 10 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :blacklisted)) | ||
| 11 | |||
| 12 | (defun whitelist-inline-bot (bot inline-bot-id) | ||
| 13 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :whitelisted)) | ||
| 14 | |||
| 15 | (defun on-inline-bot (bot msg via) | ||
| 16 | (let ((ty (db:get-inline-bot-type (bot-db bot) (user-id via)))) | ||
| 17 | (if (eq ty :whitelisted) | ||
| 18 | t | ||
| 19 | (progn | ||
| 20 | (log-info "Deleting an unallowed inline bot message from ~A ~A" | ||
| 21 | (user-username via) | ||
| 22 | (user-id via)) | ||
| 23 | (delete-message bot | ||
| 24 | :chat-id (message-chat-id msg) | ||
| 25 | :message-id (message-id msg)) | ||
| 26 | (unless (eq ty :blacklisted) | ||
| 27 | ;; Not explicitly blacklisted, notify dev group | ||
| 28 | (send-message bot | ||
| 29 | :chat-id (config-dev-group (bot-config bot)) | ||
| 30 | :text (format nil "Deleted a message sent via inline bot @~A <code>~A</code>" | ||
| 31 | (user-username via) | ||
| 32 | (user-id via)) | ||
| 33 | :parse-mode "HTML" | ||
| 34 | :reply-markup (make-inline-keyboard-markup | ||
| 35 | :inline-keyboard | ||
| 36 | #(#((make-inline-keyboard-button | ||
| 37 | :text "Whitelist" | ||
| 38 | :callback-data (format nil "bwl:~A" (user-id via))) | ||
| 39 | (make-inline-keyboard-button | ||
| 40 | :text "Blacklist" | ||
| 41 | :callback-data (format nil "bbl:~A" (user-id via)))))))) | ||
| 42 | nil)))) | ||