diff options
| author | 2025-10-18 03:06:09 +0300 | |
|---|---|---|
| committer | 2025-10-18 03:53:48 +0300 | |
| commit | ec7de1aa1ad2bc14b3b1572ea4cc5024a6c662ae (patch) | |
| tree | 5dcc03e76b14f1bb522f16ea98e975a7ef5bbb88 | |
| parent | Add "tiny ..." trigger (diff) | |
| download | ukkoclot-ec7de1aa1ad2bc14b3b1572ea4cc5024a6c662ae.tar.gz ukkoclot-ec7de1aa1ad2bc14b3b1572ea4cc5024a6c662ae.tar.xz ukkoclot-ec7de1aa1ad2bc14b3b1572ea4cc5024a6c662ae.zip | |
Add ocicl lint
| -rw-r--r-- | .ocicl-lint.conf | 4 | ||||
| -rw-r--r-- | .pre-commit-config.yaml | 8 | ||||
| -rw-r--r-- | REUSE.toml | 2 | ||||
| -rw-r--r-- | config.default.lisp | 1 | ||||
| -rw-r--r-- | src/db.lisp | 13 | ||||
| -rw-r--r-- | src/inline-bots.lisp | 12 | ||||
| -rw-r--r-- | src/main.lisp | 21 | ||||
| -rw-r--r-- | src/strings.lisp | 3 | ||||
| -rw-r--r-- | src/tg.lisp | 6 | ||||
| -rw-r--r-- | src/tg/message-entity.lisp | 6 | ||||
| -rw-r--r-- | src/tg/message.lisp | 2 | ||||
| -rw-r--r-- | src/tg/method-macros.lisp | 10 | ||||
| -rw-r--r-- | src/tg/type-macros.lisp | 13 | ||||
| -rw-r--r-- | src/tg/update.lisp | 2 | ||||
| -rw-r--r-- | ukkoclot.asd | 3 |
15 files changed, 63 insertions, 43 deletions
diff --git a/.ocicl-lint.conf b/.ocicl-lint.conf new file mode 100644 index 0000000..c161d92 --- /dev/null +++ b/.ocicl-lint.conf | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | # minus-one: I don't like 1- | ||
| 2 | # missing-docistring: I'm lazy | ||
| 3 | suppress-rules = minus-one, missing-docstring | ||
| 4 | suggest-libraries = alexandria, uiop, serapeum | ||
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea14b31..f30fd61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml | |||
| @@ -1,6 +1,14 @@ | |||
| 1 | # See https://pre-commit.com for more information | 1 | # See https://pre-commit.com for more information |
| 2 | # See https://pre-commit.com/hooks.html for more hooks | 2 | # See https://pre-commit.com/hooks.html for more hooks |
| 3 | repos: | 3 | repos: |
| 4 | - repo: local | ||
| 5 | hooks: | ||
| 6 | - id: ocicl-lint | ||
| 7 | name: ocicl-lint | ||
| 8 | language: system | ||
| 9 | entry: ocicl lint | ||
| 10 | pass_filenames: true | ||
| 11 | files: \.(lisp|asd)$ | ||
| 4 | - repo: https://github.com/fsfe/reuse-tool | 12 | - repo: https://github.com/fsfe/reuse-tool |
| 5 | rev: v6.1.2 | 13 | rev: v6.1.2 |
| 6 | hooks: | 14 | hooks: |
| @@ -3,7 +3,7 @@ version = 1 | |||
| 3 | 3 | ||
| 4 | [[annotations]] | 4 | [[annotations]] |
| 5 | label = "Miscellaneous little shits I put under CC0" | 5 | label = "Miscellaneous little shits I put under CC0" |
| 6 | path = [".gitignore", ".pre-commit-config.yaml", "config.default.lisp"] | 6 | path = [".gitignore", ".ocicl-lint.conf", ".pre-commit-config.yaml", "config.default.lisp"] |
| 7 | SPDX-License-Identifier = "CC0-1.0" | 7 | SPDX-License-Identifier = "CC0-1.0" |
| 8 | SPDX-FileCopyrightText = " 2025 Uko Kokņevičs <perkontevs@gmail.com>" | 8 | SPDX-FileCopyrightText = " 2025 Uko Kokņevičs <perkontevs@gmail.com>" |
| 9 | 9 | ||
diff --git a/config.default.lisp b/config.default.lisp index ac519ae..4162c9a 100644 --- a/config.default.lisp +++ b/config.default.lisp | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | ;; lint:suppress in-package spdx-license-identifier | ||
| 1 | ;; Copy this file to config.lisp and modify it there | 2 | ;; Copy this file to config.lisp and modify it there |
| 2 | (:bot-name "Ukko's Clot" | 3 | (:bot-name "Ukko's Clot" |
| 3 | :bot-token "123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi" | 4 | :bot-token "123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi" |
diff --git a/src/db.lisp b/src/db.lisp index 5d08e6a..8fab0db 100644 --- a/src/db.lisp +++ b/src/db.lisp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | (:export :get-inline-bot-type :set-inline-bot-type :with-db)) | 6 | (:export :get-inline-bot-type :set-inline-bot-type :with-db)) |
| 7 | (in-package :ukkoclot/db) | 7 | (in-package :ukkoclot/db) |
| 8 | 8 | ||
| 9 | (defparameter +target-version+ 1 | 9 | (defconstant +target-version+ 1 |
| 10 | "Intended DB version") | 10 | "Intended DB version") |
| 11 | 11 | ||
| 12 | (defmacro with-db ((name path) &body body) | 12 | (defmacro with-db ((name path) &body body) |
| @@ -20,7 +20,10 @@ | |||
| 20 | (integer->inline-bot-type type-int)))) | 20 | (integer->inline-bot-type type-int)))) |
| 21 | 21 | ||
| 22 | (defun set-inline-bot-type (db id type) | 22 | (defun set-inline-bot-type (db id type) |
| 23 | (execute-non-query db "INSERT OR REPLACE INTO inline_bots (id, type) VALUES (?, ?)" id (inline-bot-type->integer type))) | 23 | (execute-non-query db |
| 24 | "INSERT OR REPLACE INTO inline_bots (id, type) VALUES (?, ?)" | ||
| 25 | id | ||
| 26 | (inline-bot-type->integer type))) | ||
| 24 | 27 | ||
| 25 | (defun inline-bot-type->integer (type) | 28 | (defun inline-bot-type->integer (type) |
| 26 | (case type | 29 | (case type |
| @@ -66,8 +69,7 @@ | |||
| 66 | (execute-non-query db " | 69 | (execute-non-query db " |
| 67 | CREATE TABLE inline_bots_enum ( | 70 | CREATE TABLE inline_bots_enum ( |
| 68 | id INTEGER PRIMARY KEY, | 71 | id INTEGER PRIMARY KEY, |
| 69 | value TEXT UNIQUE | 72 | value TEXT UNIQUE)") |
| 70 | )") | ||
| 71 | (execute-non-query db " | 73 | (execute-non-query db " |
| 72 | INSERT INTO inline_bots_enum(id, value) | 74 | INSERT INTO inline_bots_enum(id, value) |
| 73 | VALUES (?, 'blacklisted'), (?, 'whitelisted')" | 75 | VALUES (?, 'blacklisted'), (?, 'whitelisted')" |
| @@ -78,6 +80,5 @@ VALUES (?, 'blacklisted'), (?, 'whitelisted')" | |||
| 78 | (execute-non-query db " | 80 | (execute-non-query db " |
| 79 | CREATE TABLE inline_bots ( | 81 | CREATE TABLE inline_bots ( |
| 80 | id INTEGER PRIMARY KEY, | 82 | id INTEGER PRIMARY KEY, |
| 81 | type INTEGER REFERENCES inline_bots_enum(id) | 83 | type INTEGER REFERENCES inline_bots_enum(id))")) |
| 82 | )")) | ||
| 83 | (t (error "Unreachable upgrade step reached ~A" new-version)))) | 84 | (t (error "Unreachable upgrade step reached ~A" new-version)))) |
diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp index caf210a..94ed478 100644 --- a/src/inline-bots.lisp +++ b/src/inline-bots.lisp | |||
| @@ -17,14 +17,13 @@ | |||
| 17 | 17 | ||
| 18 | (defun on-inline-bot (bot msg via) | 18 | (defun on-inline-bot (bot msg via) |
| 19 | (let ((ty (db:get-inline-bot-type (bot-db bot) (user-id via)))) | 19 | (let ((ty (db:get-inline-bot-type (bot-db bot) (user-id via)))) |
| 20 | (if (eq ty :whitelisted) | 20 | (or (eql ty :whitelisted) |
| 21 | t | 21 | (prog1 nil |
| 22 | (progn | ||
| 23 | (log:info "Deleting an unallowed inline bot message from ~A ~A" | 22 | (log:info "Deleting an unallowed inline bot message from ~A ~A" |
| 24 | (user-username via) | 23 | (user-username via) |
| 25 | (user-id via)) | 24 | (user-id via)) |
| 26 | (try-delete-message bot msg) | 25 | (try-delete-message bot msg) |
| 27 | (unless (eq ty :blacklisted) | 26 | (unless (eql ty :blacklisted) |
| 28 | ;; Not explicitly blacklisted, notify dev group | 27 | ;; Not explicitly blacklisted, notify dev group |
| 29 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" | 28 | (let ((whitelist (make-inline-keyboard-button :text "Whitelist" |
| 30 | :callback-data (format nil "bwl:~A" (user-id via)))) | 29 | :callback-data (format nil "bwl:~A" (user-id via)))) |
| @@ -38,5 +37,6 @@ | |||
| 38 | :parse-mode html | 37 | :parse-mode html |
| 39 | :reply-markup (make-inline-keyboard-markup | 38 | :reply-markup (make-inline-keyboard-markup |
| 40 | :inline-keyboard | 39 | :inline-keyboard |
| 41 | (make-array '(1 2) :initial-contents (list (list whitelist blacklist))))))) | 40 | (make-array '(1 2) |
| 42 | nil)))) | 41 | :initial-contents |
| 42 | (list (list whitelist blacklist))))))))))) | ||
diff --git a/src/main.lisp b/src/main.lisp index 2e01411..ba3e343 100644 --- a/src/main.lisp +++ b/src/main.lisp | |||
| @@ -9,7 +9,8 @@ | |||
| 9 | (:import-from :ukkoclot/db :with-db) | 9 | (:import-from :ukkoclot/db :with-db) |
| 10 | (:import-from :ukkoclot/serializing :fixup-value) | 10 | (:import-from :ukkoclot/serializing :fixup-value) |
| 11 | (:import-from :ukkoclot/state :make-bot :bot-config :bot-power-on) | 11 | (:import-from :ukkoclot/state :make-bot :bot-config :bot-power-on) |
| 12 | (:import-from :ukkoclot/strings :escape-xml :is-tg-whitespace :is-tg-whitespace-str :starts-with :starts-with-ignore-case) | 12 | (:import-from :ukkoclot/strings |
| 13 | :escape-xml :is-tg-whitespace :is-tg-whitespace-str :starts-with :starts-with-ignore-case) | ||
| 13 | (:local-nicknames | 14 | (:local-nicknames |
| 14 | (:jzon :com.inuoe.jzon)) | 15 | (:jzon :com.inuoe.jzon)) |
| 15 | (:export :main)) | 16 | (:export :main)) |
| @@ -26,7 +27,9 @@ | |||
| 26 | (defun start-swank (port) | 27 | (defun start-swank (port) |
| 27 | (log:info "Starting a SWANK server on port ~A..." port) | 28 | (log:info "Starting a SWANK server on port ~A..." port) |
| 28 | (swank:create-server :port port :dont-close t) | 29 | (swank:create-server :port port :dont-close t) |
| 29 | (log:info "SWANK started. You can connect to it by forwarding ports via SSH: `ssh -L~A:127.0.0.1:~A username@server.com'" port port) | 30 | (log:info |
| 31 | "SWANK started. You can connect to it by forwarding ports via SSH: `ssh -L~A:127.0.0.1:~A username@server.com'" | ||
| 32 | port port) | ||
| 30 | (log:info "And then afterwards M-x slime-connect giving localhost and ~A" port)) | 33 | (log:info "And then afterwards M-x slime-connect giving localhost and ~A" port)) |
| 31 | 34 | ||
| 32 | (defun stop-swank (port) | 35 | (defun stop-swank (port) |
| @@ -214,9 +217,10 @@ | |||
| 214 | (reply-message bot msg "OwO")) | 217 | (reply-message bot msg "OwO")) |
| 215 | 218 | ||
| 216 | ((string-equal text "waow") | 219 | ((string-equal text "waow") |
| 217 | (reply-message bot | 220 | (reply-message |
| 218 | (or (message-reply-to-message msg) msg) | 221 | bot |
| 219 | "BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED")) | 222 | (or (message-reply-to-message msg) msg) |
| 223 | "BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED BASED")) | ||
| 220 | 224 | ||
| 221 | ((string-equal text "what") | 225 | ((string-equal text "what") |
| 222 | (reply-message bot msg | 226 | (reply-message bot msg |
| @@ -232,8 +236,7 @@ | |||
| 232 | (write-string "GIR" s)) | 236 | (write-string "GIR" s)) |
| 233 | (if (char= (elt text 3) #\t) | 237 | (if (char= (elt text 3) #\t) |
| 234 | (write-char #\l s) | 238 | (write-char #\l s) |
| 235 | (write-char #\L s))))) | 239 | (write-char #\L s)))))))) |
| 236 | ))) | ||
| 237 | 240 | ||
| 238 | (defun simplify-cmd (bot cmd) | 241 | (defun simplify-cmd (bot cmd) |
| 239 | (let ((at-idx (position #\@ cmd))) | 242 | (let ((at-idx (position #\@ cmd))) |
| @@ -273,9 +276,7 @@ Send time: ...")) | |||
| 273 | (message-from msg) | 276 | (message-from msg) |
| 274 | (= (user-id (message-from msg)) (config-owner (bot-config bot)))) | 277 | (= (user-id (message-from msg)) (config-owner (bot-config bot)))) |
| 275 | (setf (bot-power-on bot) nil) | 278 | (setf (bot-power-on bot) nil) |
| 276 | (reply-message bot msg "Initialising shutdown..." :allow-sending-without-reply t)) | 279 | (reply-message bot msg "Initialising shutdown..." :allow-sending-without-reply t))))) |
| 277 | |||
| 278 | ))) | ||
| 279 | 280 | ||
| 280 | (defun report-error (bot evt err) | 281 | (defun report-error (bot evt err) |
| 281 | (log:error "While handling ~A: ~A" evt err) | 282 | (log:error "While handling ~A: ~A" evt err) |
diff --git a/src/strings.lisp b/src/strings.lisp index 635762c..f08010e 100644 --- a/src/strings.lisp +++ b/src/strings.lisp | |||
| @@ -42,8 +42,7 @@ | |||
| 42 | (string= gc "Zl") ; Separator, line | 42 | (string= gc "Zl") ; Separator, line |
| 43 | (string= gc "Zp") ; Separator, paragraph | 43 | (string= gc "Zp") ; Separator, paragraph |
| 44 | (string= gc "Cc") ; Other, control | 44 | (string= gc "Cc") ; Other, control |
| 45 | (= (char-code ch) #x2800) ; BRAILLE PATTERN BLANK | 45 | (= (char-code ch) #x2800)))) ; BRAILLE PATTERN BLANK |
| 46 | ))) | ||
| 47 | 46 | ||
| 48 | (defun is-tg-whitespace-str (str) | 47 | (defun is-tg-whitespace-str (str) |
| 49 | (iter (for ch in-string str) | 48 | (iter (for ch in-string str) |
diff --git a/src/tg.lisp b/src/tg.lisp index 1ee7da0..05b6e90 100644 --- a/src/tg.lisp +++ b/src/tg.lisp | |||
| @@ -1,7 +1,7 @@ | |||
| 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 | (uiop:define-package :ukkoclot/tg | 3 | (uiop:define-package :ukkoclot/tg |
| 4 | (:use) | 4 | (:use :c2cl) |
| 5 | (:use-reexport | 5 | (:use-reexport |
| 6 | :ukkoclot/tg/animation | 6 | :ukkoclot/tg/animation |
| 7 | :ukkoclot/tg/answer-callback-query | 7 | :ukkoclot/tg/answer-callback-query |
| @@ -45,5 +45,5 @@ | |||
| 45 | :ukkoclot/tg/suggested-post-price | 45 | :ukkoclot/tg/suggested-post-price |
| 46 | :ukkoclot/tg/update | 46 | :ukkoclot/tg/update |
| 47 | :ukkoclot/tg/user | 47 | :ukkoclot/tg/user |
| 48 | :ukkoclot/tg/web-app-info | 48 | :ukkoclot/tg/web-app-info)) |
| 49 | )) | 49 | (in-package :ukkoclot/tg) |
diff --git a/src/tg/message-entity.lisp b/src/tg/message-entity.lisp index 3413763..c7e6ba1 100644 --- a/src/tg/message-entity.lisp +++ b/src/tg/message-entity.lisp | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | (defun message-entity-extract (entity text) | 38 | (defun message-entity-extract (entity text) |
| 39 | (with-slots (length offset) entity | 39 | (with-slots (length offset) entity |
| 40 | (if (= length 0) | 40 | (if (zerop length) |
| 41 | "" | 41 | "" |
| 42 | (let* ((start (iterate | 42 | (let* ((start (iterate |
| 43 | (with curr-idx16 = 0) | 43 | (with curr-idx16 = 0) |
| @@ -46,7 +46,7 @@ | |||
| 46 | (when (or (= curr-idx16 offset) | 46 | (when (or (= curr-idx16 offset) |
| 47 | (> (+ curr-idx16 curr-width) offset)) | 47 | (> (+ curr-idx16 curr-width) offset)) |
| 48 | (return curr-idx32)) | 48 | (return curr-idx32)) |
| 49 | (setq curr-idx16 (+ curr-idx16 curr-width)) | 49 | (incf curr-idx16 curr-width) |
| 50 | (finally (return (length text))))) | 50 | (finally (return (length text))))) |
| 51 | (end (iterate | 51 | (end (iterate |
| 52 | (with curr-len16 = 0) | 52 | (with curr-len16 = 0) |
| @@ -54,6 +54,6 @@ | |||
| 54 | (for curr-width = (utf16-width ch)) | 54 | (for curr-width = (utf16-width ch)) |
| 55 | (when (>= curr-len16 length) | 55 | (when (>= curr-len16 length) |
| 56 | (return curr-idx32)) | 56 | (return curr-idx32)) |
| 57 | (setq curr-len16 (+ curr-len16 curr-width)) | 57 | (incf curr-len16 curr-width) |
| 58 | (finally (return (length text)))))) | 58 | (finally (return (length text)))))) |
| 59 | (subseq text start end))))) | 59 | (subseq text start end))))) |
diff --git a/src/tg/message.lisp b/src/tg/message.lisp index 4707c57..e7043bc 100644 --- a/src/tg/message.lisp +++ b/src/tg/message.lisp | |||
| @@ -160,7 +160,7 @@ | |||
| 160 | ;; (video-chat-participants-invited (or video-chat-participants-invited null) nil) | 160 | ;; (video-chat-participants-invited (or video-chat-participants-invited null) nil) |
| 161 | ;; (web-app-data (or web-app-data null) nil) | 161 | ;; (web-app-data (or web-app-data null) nil) |
| 162 | ;; (reply-markup (or inline-keyboard-markup null) nil) | 162 | ;; (reply-markup (or inline-keyboard-markup null) nil) |
| 163 | ) | 163 | ) ; lint:suppress closing-parens-same-line whitespace-before-close-paren |
| 164 | 164 | ||
| 165 | (defun message-id (msg) | 165 | (defun message-id (msg) |
| 166 | (message-message-id msg)) | 166 | (message-message-id msg)) |
diff --git a/src/tg/method-macros.lisp b/src/tg/method-macros.lisp index 3599328..e614db9 100644 --- a/src/tg/method-macros.lisp +++ b/src/tg/method-macros.lisp | |||
| @@ -2,6 +2,7 @@ | |||
| 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/tg/method-macros | 3 | (defpackage :ukkoclot/tg/method-macros |
| 4 | (:use :c2cl :iterate) | 4 | (:use :c2cl :iterate) |
| 5 | (:import-from :serapeum :take) | ||
| 5 | (:import-from :ukkoclot/state :bot) | 6 | (:import-from :ukkoclot/state :bot) |
| 6 | (:import-from :ukkoclot/strings :ends-with :lisp->camel-case) | 7 | (:import-from :ukkoclot/strings :ends-with :lisp->camel-case) |
| 7 | (:import-from :ukkoclot/transport :do-call) | 8 | (:import-from :ukkoclot/transport :do-call) |
| @@ -13,7 +14,10 @@ | |||
| 13 | 14 | ||
| 14 | (defparameter +unique+ (gensym)) | 15 | (defparameter +unique+ (gensym)) |
| 15 | 16 | ||
| 16 | (defun make-param (name type &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) | 17 | ;; TODO: Fix optional-and-key ! |
| 18 | (defun make-param (name type ; lint:suppress avoid-optional-and-key | ||
| 19 | &optional (default +unique+) | ||
| 20 | &key (skip-if-default (not (eq default +unique+)))) | ||
| 17 | (let ((default (if (eq default +unique+) | 21 | (let ((default (if (eq default +unique+) |
| 18 | `(error ,(format nil "No value given for ~A" name)) | 22 | `(error ,(format nil "No value given for ~A" name)) |
| 19 | default))) | 23 | default))) |
| @@ -29,7 +33,7 @@ | |||
| 29 | (defun path-from-name (name) | 33 | (defun path-from-name (name) |
| 30 | (let ((str (lisp->camel-case (symbol-name name)))) | 34 | (let ((str (lisp->camel-case (symbol-name name)))) |
| 31 | (if (ends-with str "%") | 35 | (if (ends-with str "%") |
| 32 | (subseq str 0 (- (length str) 1)) | 36 | (take (- (length str) 1) str) |
| 33 | str))) | 37 | str))) |
| 34 | 38 | ||
| 35 | (defun emit-append-to-args (param args) | 39 | (defun emit-append-to-args (param args) |
| @@ -46,7 +50,7 @@ | |||
| 46 | (let ((revparams (reverse params)) | 50 | (let ((revparams (reverse params)) |
| 47 | (args (gensym "ARGS")) | 51 | (args (gensym "ARGS")) |
| 48 | (bot (gensym "BOT"))) | 52 | (bot (gensym "BOT"))) |
| 49 | `(defun ,name (,bot &key ,@(iter (for param in params) | 53 | `(defun ,name (,bot &key ,@(iter (for param in params) ; lint:suppress lambda-list-invalid |
| 50 | (collect (emit-defun-arg param)))) | 54 | (collect (emit-defun-arg param)))) |
| 51 | (let (,args) | 55 | (let (,args) |
| 52 | ,@(iter (for param in revparams) | 56 | ,@(iter (for param in revparams) |
diff --git a/src/tg/type-macros.lisp b/src/tg/type-macros.lisp index 552c908..b9d649c 100644 --- a/src/tg/type-macros.lisp +++ b/src/tg/type-macros.lisp | |||
| @@ -15,7 +15,10 @@ | |||
| 15 | 15 | ||
| 16 | (defparameter +unique+ (gensym)) | 16 | (defparameter +unique+ (gensym)) |
| 17 | 17 | ||
| 18 | (defun make-field (name type &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) | 18 | ;; TODO: Fix optional-and-key ! |
| 19 | (defun make-field (name type ; lint:suppress avoid-optional-and-key | ||
| 20 | &optional (default +unique+) | ||
| 21 | &key (skip-if-default (not (eq default +unique+)))) | ||
| 19 | (let ((default (if (eq default +unique+) | 22 | (let ((default (if (eq default +unique+) |
| 20 | `(error ,(format nil "No value given for ~A" name)) | 23 | `(error ,(format nil "No value given for ~A" name)) |
| 21 | default))) | 24 | default))) |
| @@ -70,7 +73,7 @@ | |||
| 70 | ,@(emit-collect-nondefault-fields | 73 | ,@(emit-collect-nondefault-fields |
| 71 | name fields obj | 74 | name fields obj |
| 72 | (lambda (field value) | 75 | (lambda (field value) |
| 73 | `(setf ,result (cons ,(emit-coerced-field field value) ,result)))) | 76 | `(push ,(emit-coerced-field field value) ,result))) |
| 74 | ,result)))) | 77 | ,result)))) |
| 75 | 78 | ||
| 76 | (defun emit-let-gethash (field source) | 79 | (defun emit-let-gethash (field source) |
| @@ -81,8 +84,8 @@ | |||
| 81 | (let ((type-sym (gensym "TYPE-SYM")) | 84 | (let ((type-sym (gensym "TYPE-SYM")) |
| 82 | (source (gensym "SOURCE"))) | 85 | (source (gensym "SOURCE"))) |
| 83 | `(defmethod parse-value ((,type-sym (eql ',name)) ,source) | 86 | `(defmethod parse-value ((,type-sym (eql ',name)) ,source) |
| 84 | (let ,(iter (for field in fields) | 87 | (let (,@(iter (for field in fields) |
| 85 | (collect (emit-let-gethash field source))) | 88 | (collect (emit-let-gethash field source)))) |
| 86 | (,(type-constructor name) | 89 | (,(type-constructor name) |
| 87 | ,@(iter (for field in fields) | 90 | ,@(iter (for field in fields) |
| 88 | (appending (emit-constructor-args field)))))))) | 91 | (appending (emit-constructor-args field)))))))) |
| @@ -92,7 +95,7 @@ | |||
| 92 | (stream (gensym "STREAM")) | 95 | (stream (gensym "STREAM")) |
| 93 | (depth (gensym "DEPTH")) | 96 | (depth (gensym "DEPTH")) |
| 94 | (pprint-args (gensym "PPRINT-ARGS"))) | 97 | (pprint-args (gensym "PPRINT-ARGS"))) |
| 95 | `(defun ,printer-name (,obj ,stream ,depth) | 98 | `(defun ,printer-name (,obj ,stream ,depth) ; lint:suppress lambda-list-invalid |
| 96 | (declare (ignore ,depth)) | 99 | (declare (ignore ,depth)) |
| 97 | (let (,pprint-args) | 100 | (let (,pprint-args) |
| 98 | ,@(emit-collect-nondefault-fields | 101 | ,@(emit-collect-nondefault-fields |
diff --git a/src/tg/update.lisp b/src/tg/update.lisp index 1c4ae46..90535ed 100644 --- a/src/tg/update.lisp +++ b/src/tg/update.lisp | |||
| @@ -49,4 +49,4 @@ | |||
| 49 | ;; (chat-join-request (or chat-join-request null) nil) | 49 | ;; (chat-join-request (or chat-join-request null) nil) |
| 50 | ;; (chat-boost (or chat-boost-updated null) nil) | 50 | ;; (chat-boost (or chat-boost-updated null) nil) |
| 51 | ;; (removed-chat-boost (or chat-boost-removed) nil) | 51 | ;; (removed-chat-boost (or chat-boost-removed) nil) |
| 52 | ) | 52 | ) ; lint:suppress closing-parens-same-line whitespace-before-close-paren |
diff --git a/ukkoclot.asd b/ukkoclot.asd index 9a9a85c..d03f1ce 100644 --- a/ukkoclot.asd +++ b/ukkoclot.asd | |||
| @@ -11,9 +11,8 @@ | |||
| 11 | :description "ukkoclot: Ukko's shitty telegram bot" | 11 | :description "ukkoclot: Ukko's shitty telegram bot" |
| 12 | :long-description #.(uiop:read-file-string (uiop:subpathname *load-pathname* "README.md")) | 12 | :long-description #.(uiop:read-file-string (uiop:subpathname *load-pathname* "README.md")) |
| 13 | :pathname "src" | 13 | :pathname "src" |
| 14 | :depends-on (:ukkoclot/main) | 14 | :depends-on (:ukkoclot/main)) |
| 15 | ;; TODO: :in-order-to ((test-op (test-op ukkoclot-test))) | 15 | ;; TODO: :in-order-to ((test-op (test-op ukkoclot-test))) |
| 16 | ) | ||
| 17 | 16 | ||
| 18 | (register-system-packages :closer-mop '(:c2cl)) | 17 | (register-system-packages :closer-mop '(:c2cl)) |
| 19 | (register-system-packages :dexador '(:dex)) | 18 | (register-system-packages :dexador '(:dex)) |