From 116c700741c7d43b68a926ac8a4acc2672d66e26 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 12 Oct 2025 22:19:41 +0300 Subject: Introduce chat-type enum --- src/enum.lisp | 3 ++- src/main.lisp | 1 - src/tg-types.lisp | 1 + src/tg-types/chat-type.lisp | 12 ++++++++++++ src/tg-types/chat.lisp | 4 ++-- 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/tg-types/chat-type.lisp 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 @@ (defmacro define-enum (name &body field-specs) (let ((fields (parse-field-specs field-specs))) `(progn + ,@(iter (for field in fields) + (collect (emit-defconst field))) ,(emit-deftype name fields) ,(emit-parse-value name fields) ,@(iter (for field in fields) (collect `(progn - ,(emit-defconst field) ,(emit-fixup-method field) ,(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 @@ (on-new-member bot msg new-chat-member))))) (defun on-new-member (bot msg new-member) - ;; TODO: Rule 10 have fun and enjoy your time on user entry (if (= (user-id new-member) (bot-id bot)) (reply-animation bot msg #P"blob/rule-11.mp4" :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 @@ :ukkoclot/tg-types/bot-name :ukkoclot/tg-types/callback-query :ukkoclot/tg-types/chat + :ukkoclot/tg-types/chat-type :ukkoclot/tg-types/chat-administrator-rights :ukkoclot/tg-types/force-reply :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 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg-types/chat-type + (:use :c2cl :ukkoclot/enum) + (:export :channel :chat-type :group :private :supergroup)) +(in-package :ukkoclot/tg-types/chat-type) + +(define-enum chat-type + (private "private") + (group "group") + (supergroup "supergroup") + (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 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/tg-types/chat - (:use :c2cl :ukkoclot/tg-types/macros) + (:use :c2cl :ukkoclot/tg-types/chat-type :ukkoclot/tg-types/macros) (:export #:chat #:make-chat @@ -19,7 +19,7 @@ (define-tg-type chat (id integer) - (type string nil) ;TODO: member of keywords + (type chat-type) (title (or string null) nil) (username (or string null) nil) (first-name (or string null) nil) -- cgit v1.2.3