diff options
Diffstat (limited to 'src/inline-bots.lisp')
| -rw-r--r-- | src/inline-bots.lisp | 18 |
1 files changed, 8 insertions, 10 deletions
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 @@ | |||
| 6 | (:import-from :com.dieggsy.f-string :enable-f-strings) | 6 | (:import-from :com.dieggsy.f-string :enable-f-strings) |
| 7 | (:import-from :conf) | 7 | (:import-from :conf) |
| 8 | (:import-from :log) | 8 | (:import-from :log) |
| 9 | (:import-from :ukkoclot/src/tg :send-message :try-delete-message) | 9 | (:import-from :state) |
| 10 | (:import-from :ukkoclot/src/state :bot-db) | ||
| 11 | (:local-nicknames (:db :ukkoclot/src/db)) | 10 | (:local-nicknames (:db :ukkoclot/src/db)) |
| 12 | (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) | 11 | (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) |
| 13 | (in-package :ukkoclot/src/inline-bots) | 12 | (in-package :ukkoclot/src/inline-bots) |
| 14 | 13 | ||
| 15 | (enable-f-strings) | 14 | (enable-f-strings) |
| 16 | 15 | ||
| 17 | (defun blacklist-inline-bot (bot inline-bot-id) | 16 | (defun blacklist-inline-bot (inline-bot-id) |
| 18 | "Blacklist the given bot. | 17 | "Blacklist the given bot. |
| 19 | 18 | ||
| 20 | No more messages about deleting its messages will be sent." | 19 | No more messages about deleting its messages will be sent." |
| 21 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :blacklisted)) | 20 | (db:set-inline-bot-type (state:db) inline-bot-id :blacklisted)) |
| 22 | 21 | ||
| 23 | (defun whitelist-inline-bot (bot inline-bot-id) | 22 | (defun whitelist-inline-bot (inline-bot-id) |
| 24 | "Whitelist the given bot. | 23 | "Whitelist the given bot. |
| 25 | 24 | ||
| 26 | Its messages will no longer be deleted." | 25 | Its messages will no longer be deleted." |
| 27 | (db:set-inline-bot-type (bot-db bot) inline-bot-id :whitelisted)) | 26 | (db:set-inline-bot-type (state:db) inline-bot-id :whitelisted)) |
| 28 | 27 | ||
| 29 | (defun on-inline-bot (bot msg via) | 28 | (defun on-inline-bot (msg via) |
| 30 | (let ((ty (db:get-inline-bot-type (bot-db bot) (user-id via)))) | 29 | (let ((ty (db:get-inline-bot-type (state:db) (user-id via)))) |
| 31 | (or (eql ty :whitelisted) | 30 | (or (eql ty :whitelisted) |
| 32 | (prog1 nil | 31 | (prog1 nil |
| 33 | (log:info "Deleting an unallowed inline bot message from ~A ~A" | 32 | (log:info "Deleting an unallowed inline bot message from ~A ~A" |
| 34 | (user-username via) | 33 | (user-username via) |
| 35 | (user-id via)) | 34 | (user-id via)) |
| 36 | (try-delete-message bot msg) | 35 | (try-delete-message msg) |
| 37 | (unless (eql ty :blacklisted) | 36 | (unless (eql ty :blacklisted) |
| 38 | ;; Not explicitly blacklisted, notify dev group | 37 | ;; Not explicitly blacklisted, notify dev group |
| 39 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" | 38 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" |
| @@ -41,7 +40,6 @@ Its messages will no longer be deleted." | |||
| 41 | (blacklist (make-inline-keyboard-button :text "Blacklist" | 40 | (blacklist (make-inline-keyboard-button :text "Blacklist" |
| 42 | :callback-data #f"bbl:{(user-id via)}"))) | 41 | :callback-data #f"bbl:{(user-id via)}"))) |
| 43 | (send-message | 42 | (send-message |
| 44 | bot | ||
| 45 | :chat-id (conf:dev-group) | 43 | :chat-id (conf:dev-group) |
| 46 | :text #f"Deleted a message sent via inline bot @{(user-username via)} <code>{(user-id via)}</code>" | 44 | :text #f"Deleted a message sent via inline bot @{(user-username via)} <code>{(user-id via)}</code>" |
| 47 | :parse-mode html | 45 | :parse-mode html |