diff options
| author | 2025-10-12 22:19:41 +0300 | |
|---|---|---|
| committer | 2025-10-12 22:19:41 +0300 | |
| commit | 116c700741c7d43b68a926ac8a4acc2672d66e26 (patch) | |
| tree | 920f939329a0b7f359bb730119eae851674dc765 /src | |
| parent | Introduce enums and a pretty parse-mode type (diff) | |
| download | ukkoclot-116c700741c7d43b68a926ac8a4acc2672d66e26.tar.gz ukkoclot-116c700741c7d43b68a926ac8a4acc2672d66e26.tar.xz ukkoclot-116c700741c7d43b68a926ac8a4acc2672d66e26.zip | |
Introduce chat-type enum
Diffstat (limited to 'src')
| -rw-r--r-- | src/enum.lisp | 3 | ||||
| -rw-r--r-- | src/main.lisp | 1 | ||||
| -rw-r--r-- | src/tg-types.lisp | 1 | ||||
| -rw-r--r-- | src/tg-types/chat-type.lisp | 12 | ||||
| -rw-r--r-- | src/tg-types/chat.lisp | 4 |
5 files changed, 17 insertions, 4 deletions
diff --git a/src/enum.lisp b/src/enum.lisp index c678ec7..9f31b1a 100644 --- a/src/enum.lisp +++ b/src/enum.lisp | |||
| @@ -50,10 +50,11 @@ | |||
| 50 | (defmacro define-enum (name &body field-specs) | 50 | (defmacro define-enum (name &body field-specs) |
| 51 | (let ((fields (parse-field-specs field-specs))) | 51 | (let ((fields (parse-field-specs field-specs))) |
| 52 | `(progn | 52 | `(progn |
| 53 | ,@(iter (for field in fields) | ||
| 54 | (collect (emit-defconst field))) | ||
| 53 | ,(emit-deftype name fields) | 55 | ,(emit-deftype name fields) |
| 54 | ,(emit-parse-value name fields) | 56 | ,(emit-parse-value name fields) |
| 55 | ,@(iter (for field in fields) | 57 | ,@(iter (for field in fields) |
| 56 | (collect `(progn | 58 | (collect `(progn |
| 57 | ,(emit-defconst field) | ||
| 58 | ,(emit-fixup-method field) | 59 | ,(emit-fixup-method field) |
| 59 | ,(emit-jzon-write-method field))))))) | 60 | ,(emit-jzon-write-method field))))))) |
diff --git a/src/main.lisp b/src/main.lisp index 4b05ee2..4db0425 100644 --- a/src/main.lisp +++ b/src/main.lisp | |||
| @@ -102,7 +102,6 @@ | |||
| 102 | (on-new-member bot msg new-chat-member))))) | 102 | (on-new-member bot msg new-chat-member))))) |
| 103 | 103 | ||
| 104 | (defun on-new-member (bot msg new-member) | 104 | (defun on-new-member (bot msg new-member) |
| 105 | ;; TODO: Rule 10 have fun and enjoy your time on user entry | ||
| 106 | (if (= (user-id new-member) (bot-id bot)) | 105 | (if (= (user-id new-member) (bot-id bot)) |
| 107 | (reply-animation bot msg #P"blob/rule-11.mp4" | 106 | (reply-animation bot msg #P"blob/rule-11.mp4" |
| 108 | :allow-sending-without-reply t) | 107 | :allow-sending-without-reply t) |
diff --git a/src/tg-types.lisp b/src/tg-types.lisp index ec14363..46d68b9 100644 --- a/src/tg-types.lisp +++ b/src/tg-types.lisp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | :ukkoclot/tg-types/bot-name | 7 | :ukkoclot/tg-types/bot-name |
| 8 | :ukkoclot/tg-types/callback-query | 8 | :ukkoclot/tg-types/callback-query |
| 9 | :ukkoclot/tg-types/chat | 9 | :ukkoclot/tg-types/chat |
| 10 | :ukkoclot/tg-types/chat-type | ||
| 10 | :ukkoclot/tg-types/chat-administrator-rights | 11 | :ukkoclot/tg-types/chat-administrator-rights |
| 11 | :ukkoclot/tg-types/force-reply | 12 | :ukkoclot/tg-types/force-reply |
| 12 | :ukkoclot/tg-types/inline-keyboard-button | 13 | :ukkoclot/tg-types/inline-keyboard-button |
diff --git a/src/tg-types/chat-type.lisp b/src/tg-types/chat-type.lisp new file mode 100644 index 0000000..dc9147a --- /dev/null +++ b/src/tg-types/chat-type.lisp | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | ;; SPDX-License-Identifier: EUPL-1.2 | ||
| 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> | ||
| 3 | (defpackage :ukkoclot/tg-types/chat-type | ||
| 4 | (:use :c2cl :ukkoclot/enum) | ||
| 5 | (:export :channel :chat-type :group :private :supergroup)) | ||
| 6 | (in-package :ukkoclot/tg-types/chat-type) | ||
| 7 | |||
| 8 | (define-enum chat-type | ||
| 9 | (private "private") | ||
| 10 | (group "group") | ||
| 11 | (supergroup "supergroup") | ||
| 12 | (channel "channel")) | ||
diff --git a/src/tg-types/chat.lisp b/src/tg-types/chat.lisp index 3ad42ef..d4af5a1 100644 --- a/src/tg-types/chat.lisp +++ b/src/tg-types/chat.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 | (defpackage :ukkoclot/tg-types/chat | 3 | (defpackage :ukkoclot/tg-types/chat |
| 4 | (:use :c2cl :ukkoclot/tg-types/macros) | 4 | (:use :c2cl :ukkoclot/tg-types/chat-type :ukkoclot/tg-types/macros) |
| 5 | (:export | 5 | (:export |
| 6 | #:chat | 6 | #:chat |
| 7 | #:make-chat | 7 | #:make-chat |
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | (define-tg-type chat | 20 | (define-tg-type chat |
| 21 | (id integer) | 21 | (id integer) |
| 22 | (type string nil) ;TODO: member of keywords | 22 | (type chat-type) |
| 23 | (title (or string null) nil) | 23 | (title (or string null) nil) |
| 24 | (username (or string null) nil) | 24 | (username (or string null) nil) |
| 25 | (first-name (or string null) nil) | 25 | (first-name (or string null) nil) |