summaryrefslogtreecommitdiff
path: root/src/inline-bots.lisp
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-10-23 10:17:00 +0300
committerGravatar Uko Kokņevičs2025-10-23 10:32:36 +0300
commitfec434a4e2d0ff65510581e461d87a945d25759a (patch)
tree676891233e6121f8801f4751d3e2d1ca7ad4e09c /src/inline-bots.lisp
parentUse alexandria's make-keyword & symbolicate (diff)
downloadukkoclot-fec434a4e2d0ff65510581e461d87a945d25759a.tar.gz
ukkoclot-fec434a4e2d0ff65510581e461d87a945d25759a.tar.xz
ukkoclot-fec434a4e2d0ff65510581e461d87a945d25759a.zip
Use serapeum's -> & defsubst
Diffstat (limited to 'src/inline-bots.lisp')
-rw-r--r--src/inline-bots.lisp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp
index 4361adb..f4d8a8d 100644
--- a/src/inline-bots.lisp
+++ b/src/inline-bots.lisp
@@ -6,6 +6,7 @@
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 :serapeum :->)
9 (:import-from :state) 10 (:import-from :state)
10 (:local-nicknames (:db :ukkoclot/src/db)) 11 (:local-nicknames (:db :ukkoclot/src/db))
11 (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) 12 (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot))
@@ -13,27 +14,30 @@
13 14
14(enable-f-strings) 15(enable-f-strings)
15 16
17(-> blacklist-inline-bot (integer) (values &optional))
16(defun blacklist-inline-bot (inline-bot-id) 18(defun blacklist-inline-bot (inline-bot-id)
17 "Blacklist the given bot. 19 "Blacklist the given bot.
18 20
19No more messages about deleting its messages will be sent." 21No more messages about deleting its messages will be sent."
20 (db:set-inline-bot-type (state:db) inline-bot-id :blacklisted)) 22 (db:set-inline-bot-type (state:db) inline-bot-id db:blacklisted))
21 23
24(-> whitelist-inline-bot (integer) (values &optional))
22(defun whitelist-inline-bot (inline-bot-id) 25(defun whitelist-inline-bot (inline-bot-id)
23 "Whitelist the given bot. 26 "Whitelist the given bot.
24 27
25Its messages will no longer be deleted." 28Its messages will no longer be deleted."
26 (db:set-inline-bot-type (state:db) inline-bot-id :whitelisted)) 29 (db:set-inline-bot-type (state:db) inline-bot-id db:whitelisted))
27 30
31(-> on-inline-bot (message user) boolean)
28(defun on-inline-bot (msg via) 32(defun on-inline-bot (msg via)
29 (let ((ty (db:get-inline-bot-type (state:db) (user-id via)))) 33 (let ((ty (db:get-inline-bot-type (state:db) (user-id via))))
30 (or (eql ty :whitelisted) 34 (or (eql ty db:whitelisted)
31 (prog1 nil 35 (prog1 nil
32 (log:info "Deleting an unallowed inline bot message from ~A ~A" 36 (log:info "Deleting an unallowed inline bot message from ~A ~A"
33 (user-username via) 37 (user-username via)
34 (user-id via)) 38 (user-id via))
35 (try-delete-message msg) 39 (try-delete-message msg)
36 (unless (eql ty :blacklisted) 40 (unless (eql ty db:blacklisted)
37 ;; Not explicitly blacklisted, notify dev group 41 ;; Not explicitly blacklisted, notify dev group
38 (let ((whitelist (make-inline-keyboard-button :text "Whitelist" 42 (let ((whitelist (make-inline-keyboard-button :text "Whitelist"
39 :callback-data #f"bwl:{(user-id via)}")) 43 :callback-data #f"bwl:{(user-id via)}"))