From 5a941f218b918ca3b301d661942f0911c5153a12 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Mon, 13 Oct 2025 00:05:43 +0300 Subject: Rename tg-types to just tg --- src/bot/advanced.lisp | 2 +- src/bot/methods.lisp | 2 +- src/inline-bots.lisp | 2 +- src/main.lisp | 2 +- src/tg-types.lisp | 40 ------ src/tg-types/animation.lisp | 30 ----- src/tg-types/bot-name.lisp | 14 -- src/tg-types/business-bot-rights.lisp | 40 ------ src/tg-types/business-connection.lisp | 28 ---- src/tg-types/callback-query.lisp | 29 ---- src/tg-types/chat-administrator-rights.lisp | 44 ------ src/tg-types/chat-type.lisp | 12 -- src/tg-types/chat.lisp | 28 ---- src/tg-types/force-reply.lisp | 18 --- src/tg-types/inline-keyboard-button.lisp | 30 ----- src/tg-types/inline-keyboard-markup.lisp | 14 -- src/tg-types/keyboard-button-poll-type.lisp | 14 -- src/tg-types/keyboard-button-request-chat.lisp | 32 ----- src/tg-types/keyboard-button-request-users.lisp | 24 ---- src/tg-types/keyboard-button.lisp | 32 ----- src/tg-types/link-preview-options.lisp | 22 --- src/tg-types/macros.lisp | 142 ------------------- src/tg-types/message-entity-type.lisp | 47 ------- src/tg-types/message-entity.lisp | 59 -------- src/tg-types/message-reaction-updated.lisp | 31 ----- src/tg-types/message.lisp | 172 ------------------------ src/tg-types/parse-mode.lisp | 11 -- src/tg-types/photo-size.lisp | 22 --- src/tg-types/reaction-type-custom-emoji.lisp | 20 --- src/tg-types/reaction-type-emoji.lisp | 20 --- src/tg-types/reaction-type-paid.lisp | 18 --- src/tg-types/reaction-type.lisp | 14 -- src/tg-types/reply-keyboard-markup.lisp | 24 ---- src/tg-types/reply-keyboard-remove.lisp | 16 --- src/tg-types/reply-parameters.lisp | 29 ---- src/tg-types/suggested-post-parameters.lisp | 16 --- src/tg-types/suggested-post-price.lisp | 16 --- src/tg-types/update.lisp | 52 ------- src/tg-types/user.lisp | 59 -------- src/tg-types/web-app-info.lisp | 14 -- src/tg.lisp | 40 ++++++ src/tg/animation.lisp | 30 +++++ src/tg/bot-name.lisp | 14 ++ src/tg/business-bot-rights.lisp | 40 ++++++ src/tg/business-connection.lisp | 28 ++++ src/tg/callback-query.lisp | 29 ++++ src/tg/chat-administrator-rights.lisp | 44 ++++++ src/tg/chat-type.lisp | 12 ++ src/tg/chat.lisp | 28 ++++ src/tg/force-reply.lisp | 18 +++ src/tg/inline-keyboard-button.lisp | 30 +++++ src/tg/inline-keyboard-markup.lisp | 14 ++ src/tg/keyboard-button-poll-type.lisp | 14 ++ src/tg/keyboard-button-request-chat.lisp | 32 +++++ src/tg/keyboard-button-request-users.lisp | 24 ++++ src/tg/keyboard-button.lisp | 32 +++++ src/tg/link-preview-options.lisp | 22 +++ src/tg/macros.lisp | 142 +++++++++++++++++++ src/tg/message-entity-type.lisp | 47 +++++++ src/tg/message-entity.lisp | 59 ++++++++ src/tg/message-reaction-updated.lisp | 31 +++++ src/tg/message.lisp | 172 ++++++++++++++++++++++++ src/tg/parse-mode.lisp | 11 ++ src/tg/photo-size.lisp | 22 +++ src/tg/reaction-type-custom-emoji.lisp | 20 +++ src/tg/reaction-type-emoji.lisp | 20 +++ src/tg/reaction-type-paid.lisp | 18 +++ src/tg/reaction-type.lisp | 14 ++ src/tg/reply-keyboard-markup.lisp | 24 ++++ src/tg/reply-keyboard-remove.lisp | 16 +++ src/tg/reply-parameters.lisp | 29 ++++ src/tg/suggested-post-parameters.lisp | 16 +++ src/tg/suggested-post-price.lisp | 16 +++ src/tg/update.lisp | 52 +++++++ src/tg/user.lisp | 59 ++++++++ src/tg/web-app-info.lisp | 14 ++ 76 files changed, 1237 insertions(+), 1237 deletions(-) delete mode 100644 src/tg-types.lisp delete mode 100644 src/tg-types/animation.lisp delete mode 100644 src/tg-types/bot-name.lisp delete mode 100644 src/tg-types/business-bot-rights.lisp delete mode 100644 src/tg-types/business-connection.lisp delete mode 100644 src/tg-types/callback-query.lisp delete mode 100644 src/tg-types/chat-administrator-rights.lisp delete mode 100644 src/tg-types/chat-type.lisp delete mode 100644 src/tg-types/chat.lisp delete mode 100644 src/tg-types/force-reply.lisp delete mode 100644 src/tg-types/inline-keyboard-button.lisp delete mode 100644 src/tg-types/inline-keyboard-markup.lisp delete mode 100644 src/tg-types/keyboard-button-poll-type.lisp delete mode 100644 src/tg-types/keyboard-button-request-chat.lisp delete mode 100644 src/tg-types/keyboard-button-request-users.lisp delete mode 100644 src/tg-types/keyboard-button.lisp delete mode 100644 src/tg-types/link-preview-options.lisp delete mode 100644 src/tg-types/macros.lisp delete mode 100644 src/tg-types/message-entity-type.lisp delete mode 100644 src/tg-types/message-entity.lisp delete mode 100644 src/tg-types/message-reaction-updated.lisp delete mode 100644 src/tg-types/message.lisp delete mode 100644 src/tg-types/parse-mode.lisp delete mode 100644 src/tg-types/photo-size.lisp delete mode 100644 src/tg-types/reaction-type-custom-emoji.lisp delete mode 100644 src/tg-types/reaction-type-emoji.lisp delete mode 100644 src/tg-types/reaction-type-paid.lisp delete mode 100644 src/tg-types/reaction-type.lisp delete mode 100644 src/tg-types/reply-keyboard-markup.lisp delete mode 100644 src/tg-types/reply-keyboard-remove.lisp delete mode 100644 src/tg-types/reply-parameters.lisp delete mode 100644 src/tg-types/suggested-post-parameters.lisp delete mode 100644 src/tg-types/suggested-post-price.lisp delete mode 100644 src/tg-types/update.lisp delete mode 100644 src/tg-types/user.lisp delete mode 100644 src/tg-types/web-app-info.lisp create mode 100644 src/tg.lisp create mode 100644 src/tg/animation.lisp create mode 100644 src/tg/bot-name.lisp create mode 100644 src/tg/business-bot-rights.lisp create mode 100644 src/tg/business-connection.lisp create mode 100644 src/tg/callback-query.lisp create mode 100644 src/tg/chat-administrator-rights.lisp create mode 100644 src/tg/chat-type.lisp create mode 100644 src/tg/chat.lisp create mode 100644 src/tg/force-reply.lisp create mode 100644 src/tg/inline-keyboard-button.lisp create mode 100644 src/tg/inline-keyboard-markup.lisp create mode 100644 src/tg/keyboard-button-poll-type.lisp create mode 100644 src/tg/keyboard-button-request-chat.lisp create mode 100644 src/tg/keyboard-button-request-users.lisp create mode 100644 src/tg/keyboard-button.lisp create mode 100644 src/tg/link-preview-options.lisp create mode 100644 src/tg/macros.lisp create mode 100644 src/tg/message-entity-type.lisp create mode 100644 src/tg/message-entity.lisp create mode 100644 src/tg/message-reaction-updated.lisp create mode 100644 src/tg/message.lisp create mode 100644 src/tg/parse-mode.lisp create mode 100644 src/tg/photo-size.lisp create mode 100644 src/tg/reaction-type-custom-emoji.lisp create mode 100644 src/tg/reaction-type-emoji.lisp create mode 100644 src/tg/reaction-type-paid.lisp create mode 100644 src/tg/reaction-type.lisp create mode 100644 src/tg/reply-keyboard-markup.lisp create mode 100644 src/tg/reply-keyboard-remove.lisp create mode 100644 src/tg/reply-parameters.lisp create mode 100644 src/tg/suggested-post-parameters.lisp create mode 100644 src/tg/suggested-post-price.lisp create mode 100644 src/tg/update.lisp create mode 100644 src/tg/user.lisp create mode 100644 src/tg/web-app-info.lisp (limited to 'src') diff --git a/src/bot/advanced.lisp b/src/bot/advanced.lisp index 241b04d..635bdb0 100644 --- a/src/bot/advanced.lisp +++ b/src/bot/advanced.lisp @@ -1,7 +1,7 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/bot/advanced - (:use :c2cl :ukkoclot/bot/impl :ukkoclot/bot/methods :ukkoclot/tg-types) + (:use :c2cl :ukkoclot/bot/impl :ukkoclot/bot/methods :ukkoclot/tg) (:export :bot-id :bot-username :reply-animation :reply-message :try-delete-message)) (in-package :ukkoclot/bot/advanced) diff --git a/src/bot/methods.lisp b/src/bot/methods.lisp index 984646a..6ef507c 100644 --- a/src/bot/methods.lisp +++ b/src/bot/methods.lisp @@ -1,7 +1,7 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/bot/methods - (:use :c2cl :ukkoclot/bot/impl :ukkoclot/tg-types :ukkoclot/tg-types/macros) + (:use :c2cl :ukkoclot/bot/impl :ukkoclot/tg :ukkoclot/tg/macros) (:export :answer-callback-query :delete-message :send-animation :edit-message-text :get-me :get-updates :send-message :set-my-name)) (in-package :ukkoclot/bot/methods) diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp index 3c6b7c4..08568d2 100644 --- a/src/inline-bots.lisp +++ b/src/inline-bots.lisp @@ -1,7 +1,7 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/inline-bots - (:use :c2cl :ukkoclot/bot :ukkoclot/config :ukkoclot/tg-types) + (:use :c2cl :ukkoclot/bot :ukkoclot/config :ukkoclot/tg) (:import-from :log) (:local-nicknames (:db :ukkoclot/db)) (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) diff --git a/src/main.lisp b/src/main.lisp index f90bfb3..862526b 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -2,7 +2,7 @@ ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/main (:nicknames :ukkoclot) - (:use :c2cl :ukkoclot/bot :ukkoclot/config :ukkoclot/inline-bots :ukkoclot/tg-types) + (:use :c2cl :ukkoclot/bot :ukkoclot/config :ukkoclot/inline-bots :ukkoclot/tg) (:import-from :anaphora :acond :awhen :it) (:import-from :log) (:import-from :ukkoclot/bot :make-bot :bot-power-on :fixup-value) diff --git a/src/tg-types.lisp b/src/tg-types.lisp deleted file mode 100644 index 24d4923..0000000 --- a/src/tg-types.lisp +++ /dev/null @@ -1,40 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(uiop:define-package :ukkoclot/tg-types - (:use) - (:use-reexport - :ukkoclot/tg-types/animation - :ukkoclot/tg-types/bot-name - :ukkoclot/tg-types/business-bot-rights - :ukkoclot/tg-types/business-connection - :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 - :ukkoclot/tg-types/inline-keyboard-markup - :ukkoclot/tg-types/keyboard-button - :ukkoclot/tg-types/keyboard-button-poll-type - :ukkoclot/tg-types/keyboard-button-request-chat - :ukkoclot/tg-types/keyboard-button-request-users - :ukkoclot/tg-types/link-preview-options - :ukkoclot/tg-types/message - :ukkoclot/tg-types/message-entity - :ukkoclot/tg-types/message-entity-type - :ukkoclot/tg-types/message-reaction-updated - :ukkoclot/tg-types/parse-mode - :ukkoclot/tg-types/photo-size - :ukkoclot/tg-types/reaction-type - :ukkoclot/tg-types/reaction-type-custom-emoji - :ukkoclot/tg-types/reaction-type-emoji - :ukkoclot/tg-types/reaction-type-paid - :ukkoclot/tg-types/reply-keyboard-markup - :ukkoclot/tg-types/reply-keyboard-remove - :ukkoclot/tg-types/reply-parameters - :ukkoclot/tg-types/suggested-post-parameters - :ukkoclot/tg-types/suggested-post-price - :ukkoclot/tg-types/update - :ukkoclot/tg-types/user - :ukkoclot/tg-types/web-app-info - )) diff --git a/src/tg-types/animation.lisp b/src/tg-types/animation.lisp deleted file mode 100644 index 421dcc7..0000000 --- a/src/tg-types/animation.lisp +++ /dev/null @@ -1,30 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/animation - (:use :c2cl :ukkoclot/tg-types/macros :ukkoclot/tg-types/photo-size) - (:export - #:animation - #:make-animation - #:animation-p - #:copy-animation - #:animation-file-id - #:animation-file-unique-id - #:animation-width - #:animation-height - #:animation-duration - #:animation-thumbnail - #:animation-file-name - #:animation-mime-type - #:animation-file-size)) -(in-package :ukkoclot/tg-types/animation) - -(define-tg-type animation - (file-id string) - (file-unique-id string) - (width integer) - (height integer) - (duration integer) - (thumbnail (or photo-size null) nil) - (file-name (or string null) nil) - (mime-type (or string null) nil) - (file-size (or integer null) nil)) diff --git a/src/tg-types/bot-name.lisp b/src/tg-types/bot-name.lisp deleted file mode 100644 index b42765c..0000000 --- a/src/tg-types/bot-name.lisp +++ /dev/null @@ -1,14 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/bot-name - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:bot-name - #:make-bot-name - #:bot-name-p - #:copy-bot-name - #:bot-name-name)) -(in-package :ukkoclot/tg-types/bot-name) - -(define-tg-type bot-name - (name string)) diff --git a/src/tg-types/business-bot-rights.lisp b/src/tg-types/business-bot-rights.lisp deleted file mode 100644 index 7a65dcd..0000000 --- a/src/tg-types/business-bot-rights.lisp +++ /dev/null @@ -1,40 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/business-bot-rights - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:business-bot-rights - #:make-business-bot-rights - #:business-bot-rights-p - #:copy-business-bot-rights - #:business-bot-rights-can-reply - #:business-bot-rights-can-read-messages - #:business-bot-rights-can-delete-sent-messages - #:business-bot-rights-can-delete-all-messages - #:business-bot-rights-can-edit-name - #:business-bot-rights-can-edit-bio - #:business-bot-rights-can-edit-profile-photo - #:business-bot-rights-can-edit-username - #:business-bot-rights-can-change-gift-settings - #:business-bot-rights-can-view-gifts-and-stars - #:business-bot-rights-can-convert-gifts-to-stars - #:business-bot-rights-can-transfer-and-upgrade-gifts - #:business-bot-rights-can-transfer-stars - #:business-bot-rights-can-manage-stories)) -(in-package :ukkoclot/tg-types/business-bot-rights) - -(define-tg-type business-bot-rights - (can-reply boolean nil) - (can-read-messages boolean nil) - (can-delete-sent-messages boolean nil) - (can-delete-all-messages boolean nil) - (can-edit-name boolean nil) - (can-edit-bio boolean nil) - (can-edit-profile-photo boolean nil) - (can-edit-username boolean nil) - (can-change-gift-settings boolean nil) - (can-view-gifts-and-stars boolean nil) - (can-convert-gifts-to-stars boolean nil) - (can-transfer-and-upgrade-gifts boolean nil) - (can-transfer-stars boolean nil) - (can-manage-stories boolean nil)) diff --git a/src/tg-types/business-connection.lisp b/src/tg-types/business-connection.lisp deleted file mode 100644 index 04fe7c4..0000000 --- a/src/tg-types/business-connection.lisp +++ /dev/null @@ -1,28 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/business-connection - (:use - :c2cl - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/business-bot-rights - :ukkoclot/tg-types/user) - (:export - #:business-connection - #:make-business-connection - #:business-connection-p - #:copy-business-connection - #:business-connection-id - #:business-connection-user - #:business-connection-user-chat-id - #:business-connection-date - #:business-connection-rights - #:business-connection-is-enabled)) -(in-package :ukkoclot/tg-types/business-connection) - -(define-tg-type business-connection - (id string) - (user user) - (user-chat-id integer) - (date integer) - (rights (or business-bot-rights null) nil) - (is-enabled boolean)) diff --git a/src/tg-types/callback-query.lisp b/src/tg-types/callback-query.lisp deleted file mode 100644 index 875ff25..0000000 --- a/src/tg-types/callback-query.lisp +++ /dev/null @@ -1,29 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/callback-query - (:use :c2cl :ukkoclot/tg-types/macros) - (:use - :ukkoclot/tg-types/message - :ukkoclot/tg-types/user) - (:export - #:callback-query - #:make-callback-query - #:callback-query-p - #:copy-callback-query - #:callback-query-id - #:callback-query-from - #:callback-query-message - #:callback-query-inline-message-id - #:callback-query-chat-instance - #:callback-query-data - #:callback-query-game-short-name)) -(in-package :ukkoclot/tg-types/callback-query) - -(define-tg-type callback-query - (id string) - (from user) - (message (or message null) nil) - (inline-message-id (or string null) nil) - (chat-instance string) - (data (or string null) nil) - (game-short-name (or string null) nil)) diff --git a/src/tg-types/chat-administrator-rights.lisp b/src/tg-types/chat-administrator-rights.lisp deleted file mode 100644 index 37c1ce0..0000000 --- a/src/tg-types/chat-administrator-rights.lisp +++ /dev/null @@ -1,44 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/chat-administrator-rights - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:chat-administrator-rights - #:make-chat-administrator-rights - #:chat-administrator-rights-p - #:copy-chat-administrator-rights - #:chat-administrator-rights-is-anonymous - #:chat-administrator-rights-can-manage-chat - #:chat-administrator-rights-can-delete-messages - #:chat-administrator-rights-can-manage-video-chats - #:chat-administrator-rights-can-restrict-members - #:chat-administrator-rights-can-promote-members - #:chat-administrator-rights-can-change-info - #:chat-administrator-rights-can-invite-users - #:chat-administrator-rights-can-post-stories - #:chat-administrator-rights-can-edit-stories - #:chat-administrator-rights-can-delete-stories - #:chat-administrator-rights-can-post-messages - #:chat-administrator-rights-can-edit-messages - #:chat-administrator-rights-can-pin-messages - #:chat-administrator-rights-can-manage-topics - #:chat-administrator-rights-can-manage-direct-messages)) -(in-package :ukkoclot/tg-types/chat-administrator-rights) - -(define-tg-type chat-administrator-rights - (is-anonymous boolean) - (can-manage-chat boolean) - (can-delete-messages boolean) - (can-manage-video-chats boolean) - (can-restrict-members boolean) - (can-promote-members boolean) - (can-change-info boolean) - (can-invite-users boolean) - (can-post-stories boolean) - (can-edit-stories boolean) - (can-delete-stories boolean) - (can-post-messages boolean nil) - (can-edit-messages boolean nil) - (can-pin-messages boolean nil) - (can-manage-topics boolean nil) - (can-manage-direct-messages boolean nil)) diff --git a/src/tg-types/chat-type.lisp b/src/tg-types/chat-type.lisp deleted file mode 100644 index dc9147a..0000000 --- a/src/tg-types/chat-type.lisp +++ /dev/null @@ -1,12 +0,0 @@ -;; 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 deleted file mode 100644 index d4af5a1..0000000 --- a/src/tg-types/chat.lisp +++ /dev/null @@ -1,28 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/chat - (:use :c2cl :ukkoclot/tg-types/chat-type :ukkoclot/tg-types/macros) - (:export - #:chat - #:make-chat - #:chat-p - #:copy-chat - #:chat-id - #:chat-type - #:chat-title - #:chat-username - #:chat-first-name - #:chat-last-name - #:chat-is-forum - #:chat-is-direct-messages)) -(in-package :ukkoclot/tg-types/chat) - -(define-tg-type chat - (id integer) - (type chat-type) - (title (or string null) nil) - (username (or string null) nil) - (first-name (or string null) nil) - (last-name (or string null) nil) - (is-forum boolean nil) - (is-direct-messages boolean nil)) diff --git a/src/tg-types/force-reply.lisp b/src/tg-types/force-reply.lisp deleted file mode 100644 index 5dc49fb..0000000 --- a/src/tg-types/force-reply.lisp +++ /dev/null @@ -1,18 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/force-reply - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:force-reply - #:make-force-reply - #:force-reply-p - #:copy-force-reply - #:force-reply-force-reply - #:force-reply-input-field-placeholder - #:force-reply-selective)) -(in-package :ukkoclot/tg-types/force-reply) - -(define-tg-type force-reply - (force-reply boolean t :skip-if-default nil) - (input-field-placeholder (or string null) nil) - (selective boolean nil)) diff --git a/src/tg-types/inline-keyboard-button.lisp b/src/tg-types/inline-keyboard-button.lisp deleted file mode 100644 index e3b3533..0000000 --- a/src/tg-types/inline-keyboard-button.lisp +++ /dev/null @@ -1,30 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/inline-keyboard-button - (:use :c2cl :ukkoclot/tg-types/macros :ukkoclot/tg-types/web-app-info) - (:export - #:inline-keyboard-button - #:make-inline-keyboard-button - #:inline-keyboard-button-p - #:copy-inline-keyboard-button - #:inline-keyboard-button-text - #:inline-keyboard-button-url - #:inline-keyboard-button-callback-data - #:inline-keyboard-button-web-app - #:inline-keyboard-button-switch-inline-query - #:inline-keyboard-button-switch-inline-query-current-chat - #:inline-keyboard-button-pay)) -(in-package :ukkoclot/tg-types/inline-keyboard-button) - -(define-tg-type inline-keyboard-button - (text string) - (url (or string null) nil) - (callback-data string) - (web-app (or web-app-info null) nil) - ;; TODO: (login-url (or login-url null) nil) - (switch-inline-query (or string null) nil) - (switch-inline-query-current-chat (or string null) nil) - ;; TODO: (switch-inline-query-chosen-chat (or switch-inline-query-chosen-chat null) nil) - ;; TODO: (copy-text (or copy-text-button null) nil) - ;; TODO: (callback-game (or callback-game null) nil) - (pay boolean nil)) diff --git a/src/tg-types/inline-keyboard-markup.lisp b/src/tg-types/inline-keyboard-markup.lisp deleted file mode 100644 index bb7b9c1..0000000 --- a/src/tg-types/inline-keyboard-markup.lisp +++ /dev/null @@ -1,14 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/inline-keyboard-markup - (:use :c2cl :ukkoclot/tg-types/inline-keyboard-button :ukkoclot/tg-types/macros) - (:export - #:inline-keyboard-markup - #:make-inline-keyboard-markup - #:inline-keyboard-markup-p - #:copy-inline-keyboard-markup - #:inline-keyboard-markup-inline-keyboard)) -(in-package :ukkoclot/tg-types/inline-keyboard-markup) - -(define-tg-type inline-keyboard-markup - (inline-keyboard (array (array inline-keyboard-button)))) diff --git a/src/tg-types/keyboard-button-poll-type.lisp b/src/tg-types/keyboard-button-poll-type.lisp deleted file mode 100644 index fdd7b92..0000000 --- a/src/tg-types/keyboard-button-poll-type.lisp +++ /dev/null @@ -1,14 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/keyboard-button-poll-type - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:keyboard-button-poll-type - #:make-keyboard-button-poll-type - #:keyboard-button-poll-type-p - #:copy-keyboard-button-poll-type - #:keyboard-button-poll-type-type)) -(in-package :ukkoclot/tg-types/keyboard-button-poll-type) - -(define-tg-type keyboard-button-poll-type - (type (or string null) nil)) ;(member "quiz" "regular") or null diff --git a/src/tg-types/keyboard-button-request-chat.lisp b/src/tg-types/keyboard-button-request-chat.lisp deleted file mode 100644 index aab8512..0000000 --- a/src/tg-types/keyboard-button-request-chat.lisp +++ /dev/null @@ -1,32 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/keyboard-button-request-chat - (:use :c2cl :ukkoclot/tg-types/chat-administrator-rights :ukkoclot/tg-types/macros) - (:export - #:keyboard-button-request-chat - #:make-keyboard-button-request-chat - #:keyboard-button-request-chat-p - #:copy-keyboard-button-request-chat - #:keyboard-button-request-chat-request-id - #:keyboard-button-request-chat-chat-is-channel - #:keyboard-button-request-chat-chat-is-created - #:keyboard-button-request-chat-user-administrator-rights - #:keyboard-button-request-chat-bot-administrator-rights - #:keyboard-button-request-chat-bot-is-member - #:keyboard-button-request-chat-request-title - #:keyboard-button-request-chat-request-username - #:keyboard-button-request-chat-request-photo)) -(in-package :ukkoclot/tg-types/keyboard-button-request-chat) - -(define-tg-type keyboard-button-request-chat - (request-id integer) - (chat-is-channel boolean) - ;; TODO: (chat-is-forum ternary nil) - ;; TODO: (chat-has-username ternary nil) - (chat-is-created boolean nil) - (user-administrator-rights (or chat-administrator-rights null) nil) - (bot-administrator-rights (or chat-administrator-rights null) nil) - (bot-is-member boolean nil) - (request-title boolean nil) - (request-username boolean nil) - (request-photo boolean nil)) diff --git a/src/tg-types/keyboard-button-request-users.lisp b/src/tg-types/keyboard-button-request-users.lisp deleted file mode 100644 index 9b20c3d..0000000 --- a/src/tg-types/keyboard-button-request-users.lisp +++ /dev/null @@ -1,24 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/keyboard-button-request-users - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:keyboard-button-request-users - #:make-keyboard-button-request-users - #:keyboard-button-request-users-p - #:copy-keyboard-button-request-users - #:keyboard-button-request-users-request-id - #:keyboard-button-request-users-max-quantity - #:keyboard-button-request-users-request-name - #:keyboard-button-request-users-request-username - #:keyboard-button-request-users-request-photo)) -(in-package :ukkoclot/tg-types/keyboard-button-request-users) - -(define-tg-type keyboard-button-request-users - (request-id integer) - ;; TODO: (user-is-bot ternary nil) - ;; TODO: (user-is-premium ternary nil) - (max-quantity integer 1) - (request-name boolean nil) - (request-username boolean nil) - (request-photo boolean nil)) diff --git a/src/tg-types/keyboard-button.lisp b/src/tg-types/keyboard-button.lisp deleted file mode 100644 index fac64e6..0000000 --- a/src/tg-types/keyboard-button.lisp +++ /dev/null @@ -1,32 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/keyboard-button - (:use - :c2cl - :ukkoclot/tg-types/keyboard-button-poll-type - :ukkoclot/tg-types/keyboard-button-request-chat - :ukkoclot/tg-types/keyboard-button-request-users - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/web-app-info) - (:export - #:keyboard-button - #:make-keyboard-button - #:keyboard-button-p - #:copy-keyboard-button - #:keyboard-button-text - #:keyboard-button-request-users - #:keyboard-button-request-chat - #:keyboard-button-request-contact - #:keyboard-button-request-location - #:keyboard-button-request-poll - #:keyboard-button-web-app)) -(in-package :ukkoclot/tg-types/keyboard-button) - -(define-tg-type keyboard-button - (text string) - (request-users (or keyboard-button-request-users null) nil) - (request-chat (or keyboard-button-request-chat null) nil) - (request-contact boolean nil) - (request-location boolean nil) - (request-poll (or keyboard-button-poll-type null) nil) - (web-app (or web-app-info null) nil)) diff --git a/src/tg-types/link-preview-options.lisp b/src/tg-types/link-preview-options.lisp deleted file mode 100644 index 450a9ea..0000000 --- a/src/tg-types/link-preview-options.lisp +++ /dev/null @@ -1,22 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/link-preview-options - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:link-preview-options - #:make-link-preview-options - #:link-preview-options-p - #:copy-link-preview-options - #:link-preview-options-is-disabled - #:link-preview-options-url - #:link-preview-options-prefer-small-media - #:link-preview-options-prefer-large-media - #:link-preview-options-show-above-text)) -(in-package :ukkoclot/tg-types/link-preview-options) - -(define-tg-type link-preview-options - (is-disabled boolean nil) - (url (or string null) nil) - (prefer-small-media boolean nil) - (prefer-large-media boolean nil) - (show-above-text boolean nil)) diff --git a/src/tg-types/macros.lisp b/src/tg-types/macros.lisp deleted file mode 100644 index a8a3d96..0000000 --- a/src/tg-types/macros.lisp +++ /dev/null @@ -1,142 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/macros - (:use :c2cl) - (:import-from :ukkoclot/bot/impl :bot :do-call :parse-value) - (:import-from :ukkoclot/hash-tables :gethash-lazy) - (:import-from :ukkoclot/strings :lisp->snake-case) - (:local-nicknames - (:jzon :com.inuoe.jzon)) - (:export :define-tg-method :define-tg-type)) -(in-package :ukkoclot/tg-types/macros) - -(eval-when (:compile-toplevel :load-toplevel :execute) - (defstruct (field (:constructor make-field%)) name type default skip-if-default) - - (defparameter +unique+ (gensym)) - - (defun make-field (name type &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) - (let ((default (if (eq default +unique+) - (list 'error (format nil "No value given for ~A" name)) - default))) - (make-field% :name name - :type type - :default default - :skip-if-default skip-if-default))) - - (defun parse-field-specs (field-specs) - (loop for field-spec in field-specs - collect (apply #'make-field field-spec))) - - (defun field-hash-key (field) - (string-downcase (lisp->snake-case (symbol-name (field-name field))))) - - (defun field-accessor (struc-name field) - (intern (concatenate 'string (symbol-name struc-name) "-" (symbol-name (field-name field))))) - - (defun field->coerced-field-spec (field struc-name obj-name) - `(list ,(string-downcase (lisp->snake-case (symbol-name (field-name field)))) - (,(field-accessor struc-name field) ,obj-name) - ',(field-type field))) - - (defun field->defun-spec (field) - (list (field-name field) (field-default field))) - - (defun field->format-arg (field name struc) - `(',(field-name field) (,(field-accessor name field) ,struc))) - - (defun field->ftype-spec (field) - (list (intern (symbol-name (field-name field)) :keyword) (field-type field))) - - (defun field->gethash-spec (field hash-table-sym) - (let ((hash-key (field-hash-key field))) - (list 'gethash-lazy hash-key hash-table-sym (field-default field)))) - - (defun field->sethash-spec (field name struc hash-table-sym) - (let ((hash-key (field-hash-key field)) - (skip-if-default (field-skip-if-default field)) - (default (field-default field))) - (if skip-if-default - (let ((tmpsym (gensym "TMP"))) - `(let ((,tmpsym (,(field-accessor name field) ,struc))) - (unless (equal ,tmpsym ,default) - (setf (gethash ,hash-key ,hash-table-sym) ,tmpsym)))) - `(setf (gethash ,hash-key ,hash-table-sym) (,(field-accessor name field) ,struc))))) - - (defun field->let-gethash-spec (field hash-table-sym) - `(,(field-name field) - (parse-value ',(field-type field) ,(field->gethash-spec field hash-table-sym)))) - - (defun field->make-spec (field) - (list (intern (symbol-name (field-name field)) :keyword) - (field-name field))) - - (defun field->struct-spec (field) - (list (field-name field) (field-default field) :type (field-type field)))) - -;; TODO: Automatically derive path from name -;; TODO: Automatically derive mapfn from type -(defmacro define-tg-method ( - (name type path &optional (method :POST)) - &body field-specs) - (let* ((fields (parse-field-specs field-specs)) - (revfields (reverse fields)) - (args (gensym "ARGS")) - (bot (gensym "BOT-"))) - `(progn - (declaim (ftype (function (bot &key ,@(loop for field in fields - collect (field->ftype-spec field))) - ,type) - ,name)) - (defun ,name (,bot &key ,@(loop for field in fields collect (field->defun-spec field))) - (let (,args) - ,@(loop for field in revfields - collecting - (if (field-skip-if-default field) - `(unless (equal ,(field-name field) ,(field-default field)) - (setf ,args (acons ',(field-name field) ,(field-name field) ,args))) - `(setf ,args (acons ',(field-name field) ,(field-name field) ,args)))) - (do-call ,bot ,method ,path ',type ,args)))))) - -(defmacro define-tg-type (name &body field-specs) - (let* ((fields (parse-field-specs field-specs)) - (revfields (reverse fields)) - (make-name (intern (concatenate 'string "MAKE-" (symbol-name name)))) - (printer (gensym (concatenate 'string "PRINT-" (symbol-name name)))) - (hash (gensym "HASH-")) - (struc (gensym (symbol-name name))) - (stream (gensym "STREAM")) - (depth (gensym "DEPTH")) - (pprint-args (gensym "PPRINT-ARGS")) - (res (gensym "RES")) - (type (gensym "TYPE"))) - `(progn - (defstruct (,name (:print-function ,printer)) - ,@(loop for field in fields - collect (field->struct-spec field))) - (defun ,printer (,struc ,stream ,depth) - (declare (ignore ,depth)) - (let (,pprint-args) - ,@(loop for field in revfields - collecting - (if (field-skip-if-default field) - `(let ((value (,(field-accessor name field) ,struc))) - (unless (equal value ,(field-default field)) - (setf ,pprint-args (list* ',(field-name field) value ,pprint-args)))) - `(setf ,pprint-args (list* ',(field-name field) (,(field-accessor name field) ,struc) ,pprint-args)))) - (format ,stream "~A~<[~;~@{~_~1I~W = ~W~^, ~}~;]~:>" ',name ,pprint-args))) - (defmethod parse-value ((,type (eql ',name)) ,hash) - (let ,(loop for field in fields - collect (field->let-gethash-spec field hash)) - (,make-name ,@(loop for field in fields - append (field->make-spec field))))) - (defmethod jzon:coerced-fields ((,struc ,name)) - (let (,res) - ,@(loop for field in revfields - collecting - (if (field-skip-if-default field) - `(let ((value (,(field-accessor name field) ,struc))) - (unless (equal value ,(field-default field)) - (setf ,res (cons ,(field->coerced-field-spec field name struc) ,res)))) - `(setf ,res (cons ,(field->coerced-field-spec field name struc) ,res)))) - ,res))))) diff --git a/src/tg-types/message-entity-type.lisp b/src/tg-types/message-entity-type.lisp deleted file mode 100644 index f34c44a..0000000 --- a/src/tg-types/message-entity-type.lisp +++ /dev/null @@ -1,47 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/message-entity-type - (:use :c2cl :ukkoclot/enum) - (:export - :message-entity-type - :mention - :hashtag - :cashtag - :bot-command - :url-entity - :email - :phone-number - :bold - :italic - :underline - :strikethrough - :spoiler - :blockquote - :expandable-blockquote - :code - :pre - :text-link - :text-mention - :custom-emoji)) -(in-package :ukkoclot/tg-types/message-entity-type) - -(define-enum message-entity-type - (mention "mention") - (hashtag "hashtag") - (cashtag "cashtag") - (bot-command "bot_command") - (url-entity "url") - (email "email") - (phone-number "phone_number") - (bold "bold") - (italic "italic") - (underline "underline") - (strikethrough "strikethrough") - (spoiler "spoiler") - (blockquote "blockquote") - (expandable-blockquote "expandable_blockquote") - (code "code") - (pre "pre") - (text-link "text_link") - (text-mention "text_mention") - (custom-emoji "custom_emoji")) diff --git a/src/tg-types/message-entity.lisp b/src/tg-types/message-entity.lisp deleted file mode 100644 index 1eb96cb..0000000 --- a/src/tg-types/message-entity.lisp +++ /dev/null @@ -1,59 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/message-entity - (:use :c2cl :iterate :ukkoclot/tg-types/macros :ukkoclot/tg-types/message-entity-type :ukkoclot/tg-types/user) - (:export - #:message-entity - #:make-message-entity - #:message-entity-p - #:copy-message-entity - #:message-entity-type - #:message-entity-offset - #:message-entity-length - #:message-entity-url - #:message-entity-user - #:message-entity-language - #:message-entity-custom-emoji-id - - #:message-entity-extract)) -(in-package :ukkoclot/tg-types/message-entity) - -(define-tg-type message-entity - (type message-entity-type) - (offset integer) - (length integer) - (url (or string null) nil) - (user (or user null) nil) - (language (or string null) nil) - (custom-emoji-id (or string null) nil)) - -(unless (= char-code-limit #x110000) - (error "Some UTF-16 fuckery assumes that system chars are UTF-32")) - -(defun utf16-width (ch) - (if (< (char-code ch) #x10000) - 1 - 2)) - -(defun message-entity-extract (entity text) - (with-slots (length offset) entity - (if (= length 0) - "" - (let* ((start (iterate - (with curr-idx16 = 0) - (for ch in-string text with-index curr-idx32) - (for curr-width = (utf16-width ch)) - (when (or (= curr-idx16 offset) - (> (+ curr-idx16 curr-width) offset)) - (return curr-idx32)) - (setq curr-idx16 (+ curr-idx16 curr-width)) - (finally (return (length text))))) - (end (iterate - (with curr-len16 = 0) - (for ch in-string text from start with-index curr-idx32) - (for curr-width = (utf16-width ch)) - (when (>= curr-len16 length) - (return curr-idx32)) - (setq curr-len16 (+ curr-len16 curr-width)) - (finally (return (length text)))))) - (subseq text start end))))) diff --git a/src/tg-types/message-reaction-updated.lisp b/src/tg-types/message-reaction-updated.lisp deleted file mode 100644 index 38d506f..0000000 --- a/src/tg-types/message-reaction-updated.lisp +++ /dev/null @@ -1,31 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/message-reaction-updated - (:use - :c2cl - :ukkoclot/tg-types/chat - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/reaction-type - :ukkoclot/tg-types/user) - (:export - #:message-reaction-updated - #:make-message-reaction-updated - #:message-reaction-updated-p - #:copy-message-reaction-updated - #:message-reaction-updated-chat - #:message-reaction-updated-message-id - #:message-reaction-updated-user - #:message-reaction-updated-actor-chat - #:message-reaction-updated-date - #:message-reaction-updated-old-reaction - #:message-reaction-updated-new-reaction)) -(in-package :ukkoclot/tg-types/message-reaction-updated) - -(define-tg-type message-reaction-updated - (chat chat) - (message-id integer) - (user (or user null) nil) - (actor-chat (or chat null) nil) - (date integer) - (old-reaction (array reaction-type)) - (new-reaction (array reaction-type))) diff --git a/src/tg-types/message.lisp b/src/tg-types/message.lisp deleted file mode 100644 index c402af2..0000000 --- a/src/tg-types/message.lisp +++ /dev/null @@ -1,172 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/message - (:use - :c2cl - :ukkoclot/tg-types/animation - :ukkoclot/tg-types/chat - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/message-entity - :ukkoclot/tg-types/photo-size - :ukkoclot/tg-types/user) - (:export - #:message-chat-id - #:message-thread-id - #:message-id - - #:message - #:make-message - #:message-p - #:copy-message - #:message-message-id - #:message-message-thread-id - #:message-from - #:message-sender-boost-count - #:message-sender-business-bot - #:message-date - #:message-business-connection-id - #:message-chat - #:message-is-topic-message - #:message-is-automatic-forward - #:message-reply-to-message - #:message-reply-to-checklist-task-id - #:message-via-bot - #:message-edit-date - #:message-has-protected-content - #:message-is-from-offline - #:message-is-paid-post - #:message-media-group-id - #:message-author-signature - #:message-paid-star-count - #:message-text - #:message-entities - #:message-effect-id - #:message-animation - #:message-photo - #:message-caption - #:message-show-caption-above-media - #:message-has-media-spoiler - #:message-new-chat-members - #:message-new-chat-title - #:message-new-chat-photo - #:message-delete-chat-photo - #:message-group-chat-created - #:message-supergroup-chat-created - #:message-channel-chat-created - #:message-migrate-to-chat-id - #:message-migrate-from-chat-id - #:message-pinned-message - #:message-connected-website)) -(in-package :ukkoclot/tg-types/message) - -;; If this is a MaybeInaccessibleMessage date will be 0 if this is inaccessible -(define-tg-type message - (message-id integer) - (message-thread-id (or integer null) nil) - ;; (direct-messages-topic (or direct-messages-topic null) nil) - (from (or user null) nil) - ;; (sender-chat (or chat null) nil) - (sender-boost-count (or integer null) nil) - (sender-business-bot (or user null) nil) - (date integer) - (business-connection-id (or string null) nil) - (chat chat nil) - ;; (forward-origin (or message-origin null) nil) - (is-topic-message boolean nil) - (is-automatic-forward boolean nil) - (reply-to-message (or message null) nil) - ;; (external-reply (or external-reply-info null) nil) - ;; (quote (or text-quote null) nil) - ;; (reply-to-story (or story null) nil) - (reply-to-checklist-task-id (or integer null) nil) - (via-bot (or user null) nil) - (edit-date (or integer null) nil) - (has-protected-content boolean nil) - (is-from-offline boolean nil) - (is-paid-post boolean nil) - (media-group-id (or string null) nil) - (author-signature (or string null) nil) - (paid-star-count (or string null) nil) - (text (or string null) nil) - (entities (or (array message-entity) null) nil) - ;; (link-preview-options (or link-preview-options null) nil) - ;; (suggested-post-info (or suggested-post-info null) nil) - (effect-id (or string null) nil) - (animation (or animation null) nil) - ;; (audio (or audio null) nil) - ;; (document (or document null) nil) - ;; (paid-media (or paid-media-info null) nil) - (photo (or (array photo-size) null) nil) - ;; (sticker (or sticker null) nil) - ;; (story (or story null) nil) - ;; (video (or video null) nil) - ;; (video-note (or video-note null) nil) - ;; (voice (or voice null) nil) - (caption (or string null) nil) - ;; (caption-entities (or (array message-entity) null) nil) - (show-caption-above-media boolean nil) - (has-media-spoiler boolean nil) - ;; (contact (or contact null) nil) - ;; (dice (or dice null) nil) - ;; (game (or game null) nil) - ;; (poll (or poll null) nil) - ;; (venue (or venue null) nil) - ;; (location (or location null) nil) - (new-chat-members (or (array user) null) nil) - ;; (left-chat-member (or user null) nil) - (new-chat-title (or string null) nil) - (new-chat-photo (or (array photo-size) null) nil) - (delete-chat-photo boolean nil) - (group-chat-created boolean nil) - (supergroup-chat-created boolean nil) - (channel-chat-created boolean nil) - ;; (message-auto-delete-timer-changed (orp message-auto-delete-timer-changed null) nil) - (migrate-to-chat-id (or integer null) nil) - (migrate-from-chat-id (or integer null) nil) - (pinned-message (or message null) nil) - ;; (invoice (or invoice null) nil) - ;; (successful-payment (or successful-payment null) nil) - ;; (refunded-payment (or refunded-payment null) nil) - ;; (users-shared (or users-shared null) nil) - ;; (chat-shared (or chat-shared null) nil) - ;; (gift (or gift-info null) nil) - ;; (unique-gift (or unique-gift-info null) nil) - (connected-website (or string null) nil) - ;; (write-access-allowed (or write-access-allowed null) nil) - ;; (passport-data (or passport-data null) nil) - ;; (proximity-alert-triggered (or proximity-alert-triggered null) nil) - ;; (boost-added (or chat-boost-added null) nil) - ;; (chat-background-set (or chat-background null) nil) - ;; (checklist-tasks-added (or checklist-tasks-added null) nil) - ;; (direct-message-price-changed (or direct-message-price-changed null) nil) - ;; (forum-topic-created (or forum-topic-created null) nil) - ;; (forum-topic-edited (or forum-topic-edited null) nil) - ;; (forum-topic-closed (or forum-topic-closed null) nil) - ;; (forum-topic-reopened (or forum-topic-reopened null) nil) - ;; (general-forum-topic-hidden (or general-forum-topic-hidden null) nil) - ;; (general-forum-topic-unhidden (or general-forum-topic-unhidden null) nil) - ;; (giveaway-created (or giveaway-created null) nil) - ;; (giveaway-winners (or giveaway-winners null) nil) - ;; (giveaway-completed (or giveaway-completed null) nil) - ;; (paid-message-price-changed (or paid-message-price-changed null) nil) - ;; (suggested-post-approved (or suggested-post-approved null) nil) - ;; (suggested-post-approval-failed (or suggested-post-approval-failed null) nil) - ;; (suggested-post-declined (or suggested-post-declined null) nil) - ;; (suggested-post-paid (or suggested-post-paid null) nil) - ;; (suggested-post-refunded (or suggested-post-refunded null) nil) - ;; (video-chat-scheduled (or video-chat-scheduled null) nil) - ;; (video-chat-started (or video-chat-started null) nil) - ;; (video-chat-ended (or video-chat-ended null) nil) - ;; (video-chat-participants-invited (or video-chat-participants-invited null) nil) - ;; (web-app-data (or web-app-data null) nil) - ;; (reply-markup (or inline-keyboard-markup null) nil) - ) - -(defun message-id (msg) - (message-message-id msg)) - -(defun message-chat-id (msg) - (chat-id (message-chat msg))) - -(defun message-thread-id (msg) - (message-message-thread-id msg)) diff --git a/src/tg-types/parse-mode.lisp b/src/tg-types/parse-mode.lisp deleted file mode 100644 index 80c24aa..0000000 --- a/src/tg-types/parse-mode.lisp +++ /dev/null @@ -1,11 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/parse-mode - (:use :c2cl :ukkoclot/enum) - (:export :html :markdown-legacy :markdown :parse-mode)) -(in-package :ukkoclot/tg-types/parse-mode) - -(define-enum parse-mode - (markdown-legacy "Markdown") - (markdown "MarkdownV2") - (html "HTML")) diff --git a/src/tg-types/photo-size.lisp b/src/tg-types/photo-size.lisp deleted file mode 100644 index 2c8906d..0000000 --- a/src/tg-types/photo-size.lisp +++ /dev/null @@ -1,22 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/photo-size - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:photo-size - #:make-photo-size - #:photo-size-p - #:copy-photo-size - #:photo-size-file-id - #:photo-size-file-unique-id - #:photo-size-width - #:photo-size-height - #:photo-size-file-size)) -(in-package :ukkoclot/tg-types/photo-size) - -(define-tg-type photo-size - (file-id string) - (file-unique-id string) - (width integer) - (height integer) - (file-size (or integer null) nil)) diff --git a/src/tg-types/reaction-type-custom-emoji.lisp b/src/tg-types/reaction-type-custom-emoji.lisp deleted file mode 100644 index 353e78f..0000000 --- a/src/tg-types/reaction-type-custom-emoji.lisp +++ /dev/null @@ -1,20 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reaction-type-custom-emoji - (:use :c2cl :ukkoclot/enum :ukkoclot/tg-types/macros) - (:export - #:custom-emoji-type - #:reaction-type-custom-emoji-type - #:reaction-type-custom-emoji - #:make-reaction-type-custom-emoji - #:reaction-type-custom-emoji-p - #:copy-reaction-type-custom-emoji - #:reaction-type-custom-emoji-custom-emoji-id)) -(in-package :ukkoclot/tg-types/reaction-type-custom-emoji) - -(define-enum reaction-type-custom-emoji-type - (custom-emoji-type "custom_emoji")) - -(define-tg-type reaction-type-custom-emoji - (type reaction-type-custom-emoji-type) - (custom-emoji-id string)) diff --git a/src/tg-types/reaction-type-emoji.lisp b/src/tg-types/reaction-type-emoji.lisp deleted file mode 100644 index c7aeebb..0000000 --- a/src/tg-types/reaction-type-emoji.lisp +++ /dev/null @@ -1,20 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reaction-type-emoji - (:use :c2cl :ukkoclot/enum :ukkoclot/tg-types/macros) - (:export - #:reaction-type-emoji-type - #:emoji-type - #:reaction-type-emoji - #:make-reaction-type-emoji - #:reaction-type-emoji-p - #:copy-reaction-type-emoji - #:reaction-type-emoji-emoji)) -(in-package :ukkoclot/tg-types/reaction-type-emoji) - -(define-enum reaction-type-emoji-type - (emoji-type "emoji")) - -(define-tg-type reaction-type-emoji - (type reaction-type-emoji-type) - (emoji string)) diff --git a/src/tg-types/reaction-type-paid.lisp b/src/tg-types/reaction-type-paid.lisp deleted file mode 100644 index 260ddf7..0000000 --- a/src/tg-types/reaction-type-paid.lisp +++ /dev/null @@ -1,18 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reaction-type-paid - (:use :c2cl :ukkoclot/enum :ukkoclot/tg-types/macros) - (:export - #:reaction-type-paid-type - #:paid-type - #:reaction-type-paid - #:make-reaction-type-paid - #:reaction-type-paid-p - #:copy-reaction-type-paid)) -(in-package :ukkoclot/tg-types/reaction-type-paid) - -(define-enum reaction-type-paid-type - (paid-type "paid")) - -(define-tg-type reaction-type-paid - (type reaction-type-paid-type)) diff --git a/src/tg-types/reaction-type.lisp b/src/tg-types/reaction-type.lisp deleted file mode 100644 index 4eb0d0b..0000000 --- a/src/tg-types/reaction-type.lisp +++ /dev/null @@ -1,14 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reaction-type - (:use - :c2cl - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/reaction-type-custom-emoji - :ukkoclot/tg-types/reaction-type-emoji - :ukkoclot/tg-types/reaction-type-paid) - (:export :reaction-type)) -(in-package :ukkoclot/tg-types/reaction-type) - -(deftype reaction-type () - '(or reaction-type-emoji reaction-type-custom-emoji reaction-type-paid)) diff --git a/src/tg-types/reply-keyboard-markup.lisp b/src/tg-types/reply-keyboard-markup.lisp deleted file mode 100644 index f4b5d45..0000000 --- a/src/tg-types/reply-keyboard-markup.lisp +++ /dev/null @@ -1,24 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reply-keyboard-markup - (:use :c2cl :ukkoclot/tg-types/keyboard-button :ukkoclot/tg-types/macros) - (:export - #:reply-keyboard-markup - #:make-reply-keyboard-markup - #:reply-keyboard-markup-p - #:copy-reply-keyboard-markup - #:reply-keyboard-markup-keyboard - #:reply-keyboard-markup-is-persistent - #:reply-keyboard-markup-resize-keyboard - #:reply-keyboard-markup-one-time-keyboard - #:reply-keyboard-markup-input-field-placeholder - #:reply-keyboard-markup-selective)) -(in-package :ukkoclot/tg-types/reply-keyboard-markup) - -(define-tg-type reply-keyboard-markup - (keyboard (array (array keyboard-button))) - (is-persistent boolean nil) - (resize-keyboard boolean nil) - (one-time-keyboard boolean nil) - (input-field-placeholder (or string null) nil) - (selective boolean nil)) diff --git a/src/tg-types/reply-keyboard-remove.lisp b/src/tg-types/reply-keyboard-remove.lisp deleted file mode 100644 index 9925d82..0000000 --- a/src/tg-types/reply-keyboard-remove.lisp +++ /dev/null @@ -1,16 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reply-keyboard-remove - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:reply-keyboard-remove - #:make-reply-keyboard-remove - #:reply-keyboard-remove-p - #:copy-reply-keyboard-remove - #:reply-keyboard-remove-remove-keyboard - #:reply-keyboard-remove-selective)) -(in-package :ukkoclot/tg-types/reply-keyboard-remove) - -(define-tg-type reply-keyboard-remove - (remove-keyboard boolean t :skip-if-default nil) - (selective boolean nil)) diff --git a/src/tg-types/reply-parameters.lisp b/src/tg-types/reply-parameters.lisp deleted file mode 100644 index ac38db7..0000000 --- a/src/tg-types/reply-parameters.lisp +++ /dev/null @@ -1,29 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/reply-parameters - (:use :c2cl :ukkoclot/tg-types/macros :ukkoclot/tg-types/message-entity) - (:export - #:reply-parameters - #:make-reply-parameters - #:reply-parameters-p - #:copy-reply-parameters - #:reply-parameters-message-id - #:reply-parameters-chat-id - #:reply-parameters-allow-sending-without-reply - #:reply-parameters-quote - #:reply-parameters-quote-parse-mode - #:reply-parameters-quote-entities - #:reply-parameters-quote-position - #:reply-parameters-checklist-task-id)) -(in-package :ukkoclot/tg-types/reply-parameters) - -(define-tg-type reply-parameters - (message-id integer) - (chat-id (or integer string null) nil) - ;; TODO: This should be a ternary true, false, default - (allow-sending-without-reply boolean nil) - (quote (or string null) nil) - (quote-parse-mode (or string null) nil) - (quote-entities (or (array message-entity) null) nil) - (quote-position (or integer null) nil) - (checklist-task-id (or integer null) nil)) diff --git a/src/tg-types/suggested-post-parameters.lisp b/src/tg-types/suggested-post-parameters.lisp deleted file mode 100644 index bf781fc..0000000 --- a/src/tg-types/suggested-post-parameters.lisp +++ /dev/null @@ -1,16 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/suggested-post-parameters - (:use :c2cl :ukkoclot/tg-types/macros :ukkoclot/tg-types/suggested-post-price) - (:export - #:suggested-post-parameters - #:make-suggested-post-parameters - #:suggested-post-parameters-p - #:copy-suggested-post-parameters - #:suggested-post-parameters-price - #:suggested-post-parameters-send-date)) -(in-package :ukkoclot/tg-types/suggested-post-parameters) - -(define-tg-type suggested-post-parameters - (price (or suggested-post-price null) nil) - (send-date (or integer null) nil)) diff --git a/src/tg-types/suggested-post-price.lisp b/src/tg-types/suggested-post-price.lisp deleted file mode 100644 index e5b6cb3..0000000 --- a/src/tg-types/suggested-post-price.lisp +++ /dev/null @@ -1,16 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/suggested-post-price - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:suggested-post-price - #:make-suggested-post-price - #:suggested-post-price-p - #:copy-suggested-post-price - #:suggested-post-price-currency - #:suggested-post-price-amount)) -(in-package :ukkoclot/tg-types/suggested-post-price) - -(define-tg-type suggested-post-price - (currency string) ;(member "XTR" "TON") - (amount integer)) diff --git a/src/tg-types/update.lisp b/src/tg-types/update.lisp deleted file mode 100644 index be4cb32..0000000 --- a/src/tg-types/update.lisp +++ /dev/null @@ -1,52 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/update - (:use - :c2cl - :ukkoclot/tg-types/macros - :ukkoclot/tg-types/business-connection - :ukkoclot/tg-types/callback-query - :ukkoclot/tg-types/message - :ukkoclot/tg-types/message-reaction-updated) - (:export - #:update - #:make-update - #:update-p - #:copy-update - #:update-update-id - #:update-message - #:update-edited-message - #:update-channel-post - #:update-edited-channel-post - #:update-business-connection - #:update-business-message - #:update-edited-business-message - #:update-message-reaction - #:update-callback-query)) -(in-package :ukkoclot/tg-types/update) - -(define-tg-type update - (update-id integer) - (message (or message null) nil) - (edited-message (or message null) nil) - (channel-post (or message null) nil) - (edited-channel-post (or message null) nil) - (business-connection (or business-connection null) nil) - (business-message (or message null) nil) - (edited-business-message (or message null) nil) - ;; (deleted-business-messages (or business-messages-deleted null) nil) - (message-reaction (or message-reaction-updated null) nil) - ;; (message-reaction-count (or message-reaction-count-updated null) nil) - ;; (inline-query (or inline-query null) nil) - ;; (chosen-inline-result (or chosen-inline-result null) nil) - (callback-query (or callback-query null) nil) - ;; (shipping-query (or shipping-query null) nil) - ;; (pre-checkout-query (or pre-checkout-query null) nil) - ;; (poll (or poll null) nil) - ;; (poll-answer (or poll-answer null) nil) - ;; (my-chat-member (or chat-member-updated null) nil) - ;; (chat-member (or chat-member-updated null) nil) - ;; (chat-join-request (or chat-join-request null) nil) - ;; (chat-boost (or chat-boost-updated null) nil) - ;; (removed-chat-boost (or chat-boost-removed) nil) - ) diff --git a/src/tg-types/user.lisp b/src/tg-types/user.lisp deleted file mode 100644 index b5be417..0000000 --- a/src/tg-types/user.lisp +++ /dev/null @@ -1,59 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/user - (:use :c2cl :ukkoclot/tg-types/macros) - (:import-from :ukkoclot/strings :escape-xml) - (:export - #:user - #:make-user - #:user-p - #:copy-user - #:user-id - #:user-is-bot - #:user-first-name - #:user-last-name - #:user-username - #:user-language-code - #:user-is-premium - #:user-added-to-attachment-menu - #:user-can-join-groups - #:user-can-read-all-group-messages - #:user-supports-inline-queries - #:user-can-connect-to-business - - #:user-format-name)) -(in-package :ukkoclot/tg-types/user) - -(define-tg-type user - (id integer) - (is-bot boolean) - (first-name string) - (last-name (or string null) nil) - (username (or string null) nil) - (language-code (or string null) nil) - (is-premium boolean nil) - (added-to-attachment-menu boolean nil) - (can-join-groups boolean nil) - (can-read-all-group-messages boolean nil) - (supports-inline-queries boolean nil) - (can-connect-to-business boolean nil)) - -(defun user-format-name% (user out) - (format out "" (user-id user)) - (escape-xml (user-first-name user) out) - (when (user-last-name user) - (write-char #\Space out) - (escape-xml (user-last-name user) out)) - (write-string "" out) - - (when (user-username user) - (write-string " @" out) - (escape-xml (user-username user) out)) - - (format out " [~A]" (user-id user))) - -(defun user-format-name (user &optional out) - (if out - (user-format-name% user out) - (with-output-to-string (stream) - (user-format-name% user stream)))) diff --git a/src/tg-types/web-app-info.lisp b/src/tg-types/web-app-info.lisp deleted file mode 100644 index e239830..0000000 --- a/src/tg-types/web-app-info.lisp +++ /dev/null @@ -1,14 +0,0 @@ -;; SPDX-License-Identifier: EUPL-1.2 -;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs -(defpackage :ukkoclot/tg-types/web-app-info - (:use :c2cl :ukkoclot/tg-types/macros) - (:export - #:web-app-info - #:make-web-app-info - #:web-app-info-p - #:copy-web-app-info - #:web-app-info-url)) -(in-package :ukkoclot/tg-types/web-app-info) - -(define-tg-type web-app-info - (url string)) diff --git a/src/tg.lisp b/src/tg.lisp new file mode 100644 index 0000000..e12f04a --- /dev/null +++ b/src/tg.lisp @@ -0,0 +1,40 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(uiop:define-package :ukkoclot/tg + (:use) + (:use-reexport + :ukkoclot/tg/animation + :ukkoclot/tg/bot-name + :ukkoclot/tg/business-bot-rights + :ukkoclot/tg/business-connection + :ukkoclot/tg/callback-query + :ukkoclot/tg/chat + :ukkoclot/tg/chat-type + :ukkoclot/tg/chat-administrator-rights + :ukkoclot/tg/force-reply + :ukkoclot/tg/inline-keyboard-button + :ukkoclot/tg/inline-keyboard-markup + :ukkoclot/tg/keyboard-button + :ukkoclot/tg/keyboard-button-poll-type + :ukkoclot/tg/keyboard-button-request-chat + :ukkoclot/tg/keyboard-button-request-users + :ukkoclot/tg/link-preview-options + :ukkoclot/tg/message + :ukkoclot/tg/message-entity + :ukkoclot/tg/message-entity-type + :ukkoclot/tg/message-reaction-updated + :ukkoclot/tg/parse-mode + :ukkoclot/tg/photo-size + :ukkoclot/tg/reaction-type + :ukkoclot/tg/reaction-type-custom-emoji + :ukkoclot/tg/reaction-type-emoji + :ukkoclot/tg/reaction-type-paid + :ukkoclot/tg/reply-keyboard-markup + :ukkoclot/tg/reply-keyboard-remove + :ukkoclot/tg/reply-parameters + :ukkoclot/tg/suggested-post-parameters + :ukkoclot/tg/suggested-post-price + :ukkoclot/tg/update + :ukkoclot/tg/user + :ukkoclot/tg/web-app-info + )) diff --git a/src/tg/animation.lisp b/src/tg/animation.lisp new file mode 100644 index 0000000..d17db94 --- /dev/null +++ b/src/tg/animation.lisp @@ -0,0 +1,30 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/animation + (:use :c2cl :ukkoclot/tg/macros :ukkoclot/tg/photo-size) + (:export + #:animation + #:make-animation + #:animation-p + #:copy-animation + #:animation-file-id + #:animation-file-unique-id + #:animation-width + #:animation-height + #:animation-duration + #:animation-thumbnail + #:animation-file-name + #:animation-mime-type + #:animation-file-size)) +(in-package :ukkoclot/tg/animation) + +(define-tg-type animation + (file-id string) + (file-unique-id string) + (width integer) + (height integer) + (duration integer) + (thumbnail (or photo-size null) nil) + (file-name (or string null) nil) + (mime-type (or string null) nil) + (file-size (or integer null) nil)) diff --git a/src/tg/bot-name.lisp b/src/tg/bot-name.lisp new file mode 100644 index 0000000..933ce8c --- /dev/null +++ b/src/tg/bot-name.lisp @@ -0,0 +1,14 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/bot-name + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:bot-name + #:make-bot-name + #:bot-name-p + #:copy-bot-name + #:bot-name-name)) +(in-package :ukkoclot/tg/bot-name) + +(define-tg-type bot-name + (name string)) diff --git a/src/tg/business-bot-rights.lisp b/src/tg/business-bot-rights.lisp new file mode 100644 index 0000000..f5a44c0 --- /dev/null +++ b/src/tg/business-bot-rights.lisp @@ -0,0 +1,40 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/business-bot-rights + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:business-bot-rights + #:make-business-bot-rights + #:business-bot-rights-p + #:copy-business-bot-rights + #:business-bot-rights-can-reply + #:business-bot-rights-can-read-messages + #:business-bot-rights-can-delete-sent-messages + #:business-bot-rights-can-delete-all-messages + #:business-bot-rights-can-edit-name + #:business-bot-rights-can-edit-bio + #:business-bot-rights-can-edit-profile-photo + #:business-bot-rights-can-edit-username + #:business-bot-rights-can-change-gift-settings + #:business-bot-rights-can-view-gifts-and-stars + #:business-bot-rights-can-convert-gifts-to-stars + #:business-bot-rights-can-transfer-and-upgrade-gifts + #:business-bot-rights-can-transfer-stars + #:business-bot-rights-can-manage-stories)) +(in-package :ukkoclot/tg/business-bot-rights) + +(define-tg-type business-bot-rights + (can-reply boolean nil) + (can-read-messages boolean nil) + (can-delete-sent-messages boolean nil) + (can-delete-all-messages boolean nil) + (can-edit-name boolean nil) + (can-edit-bio boolean nil) + (can-edit-profile-photo boolean nil) + (can-edit-username boolean nil) + (can-change-gift-settings boolean nil) + (can-view-gifts-and-stars boolean nil) + (can-convert-gifts-to-stars boolean nil) + (can-transfer-and-upgrade-gifts boolean nil) + (can-transfer-stars boolean nil) + (can-manage-stories boolean nil)) diff --git a/src/tg/business-connection.lisp b/src/tg/business-connection.lisp new file mode 100644 index 0000000..74f6c9e --- /dev/null +++ b/src/tg/business-connection.lisp @@ -0,0 +1,28 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/business-connection + (:use + :c2cl + :ukkoclot/tg/macros + :ukkoclot/tg/business-bot-rights + :ukkoclot/tg/user) + (:export + #:business-connection + #:make-business-connection + #:business-connection-p + #:copy-business-connection + #:business-connection-id + #:business-connection-user + #:business-connection-user-chat-id + #:business-connection-date + #:business-connection-rights + #:business-connection-is-enabled)) +(in-package :ukkoclot/tg/business-connection) + +(define-tg-type business-connection + (id string) + (user user) + (user-chat-id integer) + (date integer) + (rights (or business-bot-rights null) nil) + (is-enabled boolean)) diff --git a/src/tg/callback-query.lisp b/src/tg/callback-query.lisp new file mode 100644 index 0000000..6b89755 --- /dev/null +++ b/src/tg/callback-query.lisp @@ -0,0 +1,29 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/callback-query + (:use :c2cl :ukkoclot/tg/macros) + (:use + :ukkoclot/tg/message + :ukkoclot/tg/user) + (:export + #:callback-query + #:make-callback-query + #:callback-query-p + #:copy-callback-query + #:callback-query-id + #:callback-query-from + #:callback-query-message + #:callback-query-inline-message-id + #:callback-query-chat-instance + #:callback-query-data + #:callback-query-game-short-name)) +(in-package :ukkoclot/tg/callback-query) + +(define-tg-type callback-query + (id string) + (from user) + (message (or message null) nil) + (inline-message-id (or string null) nil) + (chat-instance string) + (data (or string null) nil) + (game-short-name (or string null) nil)) diff --git a/src/tg/chat-administrator-rights.lisp b/src/tg/chat-administrator-rights.lisp new file mode 100644 index 0000000..2c37757 --- /dev/null +++ b/src/tg/chat-administrator-rights.lisp @@ -0,0 +1,44 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/chat-administrator-rights + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:chat-administrator-rights + #:make-chat-administrator-rights + #:chat-administrator-rights-p + #:copy-chat-administrator-rights + #:chat-administrator-rights-is-anonymous + #:chat-administrator-rights-can-manage-chat + #:chat-administrator-rights-can-delete-messages + #:chat-administrator-rights-can-manage-video-chats + #:chat-administrator-rights-can-restrict-members + #:chat-administrator-rights-can-promote-members + #:chat-administrator-rights-can-change-info + #:chat-administrator-rights-can-invite-users + #:chat-administrator-rights-can-post-stories + #:chat-administrator-rights-can-edit-stories + #:chat-administrator-rights-can-delete-stories + #:chat-administrator-rights-can-post-messages + #:chat-administrator-rights-can-edit-messages + #:chat-administrator-rights-can-pin-messages + #:chat-administrator-rights-can-manage-topics + #:chat-administrator-rights-can-manage-direct-messages)) +(in-package :ukkoclot/tg/chat-administrator-rights) + +(define-tg-type chat-administrator-rights + (is-anonymous boolean) + (can-manage-chat boolean) + (can-delete-messages boolean) + (can-manage-video-chats boolean) + (can-restrict-members boolean) + (can-promote-members boolean) + (can-change-info boolean) + (can-invite-users boolean) + (can-post-stories boolean) + (can-edit-stories boolean) + (can-delete-stories boolean) + (can-post-messages boolean nil) + (can-edit-messages boolean nil) + (can-pin-messages boolean nil) + (can-manage-topics boolean nil) + (can-manage-direct-messages boolean nil)) diff --git a/src/tg/chat-type.lisp b/src/tg/chat-type.lisp new file mode 100644 index 0000000..daf135a --- /dev/null +++ b/src/tg/chat-type.lisp @@ -0,0 +1,12 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/chat-type + (:use :c2cl :ukkoclot/enum) + (:export :channel :chat-type :group :private :supergroup)) +(in-package :ukkoclot/tg/chat-type) + +(define-enum chat-type + (private "private") + (group "group") + (supergroup "supergroup") + (channel "channel")) diff --git a/src/tg/chat.lisp b/src/tg/chat.lisp new file mode 100644 index 0000000..1fa3f7e --- /dev/null +++ b/src/tg/chat.lisp @@ -0,0 +1,28 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/chat + (:use :c2cl :ukkoclot/tg/chat-type :ukkoclot/tg/macros) + (:export + #:chat + #:make-chat + #:chat-p + #:copy-chat + #:chat-id + #:chat-type + #:chat-title + #:chat-username + #:chat-first-name + #:chat-last-name + #:chat-is-forum + #:chat-is-direct-messages)) +(in-package :ukkoclot/tg/chat) + +(define-tg-type chat + (id integer) + (type chat-type) + (title (or string null) nil) + (username (or string null) nil) + (first-name (or string null) nil) + (last-name (or string null) nil) + (is-forum boolean nil) + (is-direct-messages boolean nil)) diff --git a/src/tg/force-reply.lisp b/src/tg/force-reply.lisp new file mode 100644 index 0000000..816eb75 --- /dev/null +++ b/src/tg/force-reply.lisp @@ -0,0 +1,18 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/force-reply + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:force-reply + #:make-force-reply + #:force-reply-p + #:copy-force-reply + #:force-reply-force-reply + #:force-reply-input-field-placeholder + #:force-reply-selective)) +(in-package :ukkoclot/tg/force-reply) + +(define-tg-type force-reply + (force-reply boolean t :skip-if-default nil) + (input-field-placeholder (or string null) nil) + (selective boolean nil)) diff --git a/src/tg/inline-keyboard-button.lisp b/src/tg/inline-keyboard-button.lisp new file mode 100644 index 0000000..e403f2a --- /dev/null +++ b/src/tg/inline-keyboard-button.lisp @@ -0,0 +1,30 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/inline-keyboard-button + (:use :c2cl :ukkoclot/tg/macros :ukkoclot/tg/web-app-info) + (:export + #:inline-keyboard-button + #:make-inline-keyboard-button + #:inline-keyboard-button-p + #:copy-inline-keyboard-button + #:inline-keyboard-button-text + #:inline-keyboard-button-url + #:inline-keyboard-button-callback-data + #:inline-keyboard-button-web-app + #:inline-keyboard-button-switch-inline-query + #:inline-keyboard-button-switch-inline-query-current-chat + #:inline-keyboard-button-pay)) +(in-package :ukkoclot/tg/inline-keyboard-button) + +(define-tg-type inline-keyboard-button + (text string) + (url (or string null) nil) + (callback-data string) + (web-app (or web-app-info null) nil) + ;; TODO: (login-url (or login-url null) nil) + (switch-inline-query (or string null) nil) + (switch-inline-query-current-chat (or string null) nil) + ;; TODO: (switch-inline-query-chosen-chat (or switch-inline-query-chosen-chat null) nil) + ;; TODO: (copy-text (or copy-text-button null) nil) + ;; TODO: (callback-game (or callback-game null) nil) + (pay boolean nil)) diff --git a/src/tg/inline-keyboard-markup.lisp b/src/tg/inline-keyboard-markup.lisp new file mode 100644 index 0000000..023b87f --- /dev/null +++ b/src/tg/inline-keyboard-markup.lisp @@ -0,0 +1,14 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/inline-keyboard-markup + (:use :c2cl :ukkoclot/tg/inline-keyboard-button :ukkoclot/tg/macros) + (:export + #:inline-keyboard-markup + #:make-inline-keyboard-markup + #:inline-keyboard-markup-p + #:copy-inline-keyboard-markup + #:inline-keyboard-markup-inline-keyboard)) +(in-package :ukkoclot/tg/inline-keyboard-markup) + +(define-tg-type inline-keyboard-markup + (inline-keyboard (array (array inline-keyboard-button)))) diff --git a/src/tg/keyboard-button-poll-type.lisp b/src/tg/keyboard-button-poll-type.lisp new file mode 100644 index 0000000..7b5b063 --- /dev/null +++ b/src/tg/keyboard-button-poll-type.lisp @@ -0,0 +1,14 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/keyboard-button-poll-type + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:keyboard-button-poll-type + #:make-keyboard-button-poll-type + #:keyboard-button-poll-type-p + #:copy-keyboard-button-poll-type + #:keyboard-button-poll-type-type)) +(in-package :ukkoclot/tg/keyboard-button-poll-type) + +(define-tg-type keyboard-button-poll-type + (type (or string null) nil)) ;(member "quiz" "regular") or null diff --git a/src/tg/keyboard-button-request-chat.lisp b/src/tg/keyboard-button-request-chat.lisp new file mode 100644 index 0000000..07f0d27 --- /dev/null +++ b/src/tg/keyboard-button-request-chat.lisp @@ -0,0 +1,32 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/keyboard-button-request-chat + (:use :c2cl :ukkoclot/tg/chat-administrator-rights :ukkoclot/tg/macros) + (:export + #:keyboard-button-request-chat + #:make-keyboard-button-request-chat + #:keyboard-button-request-chat-p + #:copy-keyboard-button-request-chat + #:keyboard-button-request-chat-request-id + #:keyboard-button-request-chat-chat-is-channel + #:keyboard-button-request-chat-chat-is-created + #:keyboard-button-request-chat-user-administrator-rights + #:keyboard-button-request-chat-bot-administrator-rights + #:keyboard-button-request-chat-bot-is-member + #:keyboard-button-request-chat-request-title + #:keyboard-button-request-chat-request-username + #:keyboard-button-request-chat-request-photo)) +(in-package :ukkoclot/tg/keyboard-button-request-chat) + +(define-tg-type keyboard-button-request-chat + (request-id integer) + (chat-is-channel boolean) + ;; TODO: (chat-is-forum ternary nil) + ;; TODO: (chat-has-username ternary nil) + (chat-is-created boolean nil) + (user-administrator-rights (or chat-administrator-rights null) nil) + (bot-administrator-rights (or chat-administrator-rights null) nil) + (bot-is-member boolean nil) + (request-title boolean nil) + (request-username boolean nil) + (request-photo boolean nil)) diff --git a/src/tg/keyboard-button-request-users.lisp b/src/tg/keyboard-button-request-users.lisp new file mode 100644 index 0000000..82b9151 --- /dev/null +++ b/src/tg/keyboard-button-request-users.lisp @@ -0,0 +1,24 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/keyboard-button-request-users + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:keyboard-button-request-users + #:make-keyboard-button-request-users + #:keyboard-button-request-users-p + #:copy-keyboard-button-request-users + #:keyboard-button-request-users-request-id + #:keyboard-button-request-users-max-quantity + #:keyboard-button-request-users-request-name + #:keyboard-button-request-users-request-username + #:keyboard-button-request-users-request-photo)) +(in-package :ukkoclot/tg/keyboard-button-request-users) + +(define-tg-type keyboard-button-request-users + (request-id integer) + ;; TODO: (user-is-bot ternary nil) + ;; TODO: (user-is-premium ternary nil) + (max-quantity integer 1) + (request-name boolean nil) + (request-username boolean nil) + (request-photo boolean nil)) diff --git a/src/tg/keyboard-button.lisp b/src/tg/keyboard-button.lisp new file mode 100644 index 0000000..79c87d6 --- /dev/null +++ b/src/tg/keyboard-button.lisp @@ -0,0 +1,32 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/keyboard-button + (:use + :c2cl + :ukkoclot/tg/keyboard-button-poll-type + :ukkoclot/tg/keyboard-button-request-chat + :ukkoclot/tg/keyboard-button-request-users + :ukkoclot/tg/macros + :ukkoclot/tg/web-app-info) + (:export + #:keyboard-button + #:make-keyboard-button + #:keyboard-button-p + #:copy-keyboard-button + #:keyboard-button-text + #:keyboard-button-request-users + #:keyboard-button-request-chat + #:keyboard-button-request-contact + #:keyboard-button-request-location + #:keyboard-button-request-poll + #:keyboard-button-web-app)) +(in-package :ukkoclot/tg/keyboard-button) + +(define-tg-type keyboard-button + (text string) + (request-users (or keyboard-button-request-users null) nil) + (request-chat (or keyboard-button-request-chat null) nil) + (request-contact boolean nil) + (request-location boolean nil) + (request-poll (or keyboard-button-poll-type null) nil) + (web-app (or web-app-info null) nil)) diff --git a/src/tg/link-preview-options.lisp b/src/tg/link-preview-options.lisp new file mode 100644 index 0000000..7ed4859 --- /dev/null +++ b/src/tg/link-preview-options.lisp @@ -0,0 +1,22 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/link-preview-options + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:link-preview-options + #:make-link-preview-options + #:link-preview-options-p + #:copy-link-preview-options + #:link-preview-options-is-disabled + #:link-preview-options-url + #:link-preview-options-prefer-small-media + #:link-preview-options-prefer-large-media + #:link-preview-options-show-above-text)) +(in-package :ukkoclot/tg/link-preview-options) + +(define-tg-type link-preview-options + (is-disabled boolean nil) + (url (or string null) nil) + (prefer-small-media boolean nil) + (prefer-large-media boolean nil) + (show-above-text boolean nil)) diff --git a/src/tg/macros.lisp b/src/tg/macros.lisp new file mode 100644 index 0000000..92afd6e --- /dev/null +++ b/src/tg/macros.lisp @@ -0,0 +1,142 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/macros + (:use :c2cl) + (:import-from :ukkoclot/bot/impl :bot :do-call :parse-value) + (:import-from :ukkoclot/hash-tables :gethash-lazy) + (:import-from :ukkoclot/strings :lisp->snake-case) + (:local-nicknames + (:jzon :com.inuoe.jzon)) + (:export :define-tg-method :define-tg-type)) +(in-package :ukkoclot/tg/macros) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defstruct (field (:constructor make-field%)) name type default skip-if-default) + + (defparameter +unique+ (gensym)) + + (defun make-field (name type &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) + (let ((default (if (eq default +unique+) + (list 'error (format nil "No value given for ~A" name)) + default))) + (make-field% :name name + :type type + :default default + :skip-if-default skip-if-default))) + + (defun parse-field-specs (field-specs) + (loop for field-spec in field-specs + collect (apply #'make-field field-spec))) + + (defun field-hash-key (field) + (string-downcase (lisp->snake-case (symbol-name (field-name field))))) + + (defun field-accessor (struc-name field) + (intern (concatenate 'string (symbol-name struc-name) "-" (symbol-name (field-name field))))) + + (defun field->coerced-field-spec (field struc-name obj-name) + `(list ,(string-downcase (lisp->snake-case (symbol-name (field-name field)))) + (,(field-accessor struc-name field) ,obj-name) + ',(field-type field))) + + (defun field->defun-spec (field) + (list (field-name field) (field-default field))) + + (defun field->format-arg (field name struc) + `(',(field-name field) (,(field-accessor name field) ,struc))) + + (defun field->ftype-spec (field) + (list (intern (symbol-name (field-name field)) :keyword) (field-type field))) + + (defun field->gethash-spec (field hash-table-sym) + (let ((hash-key (field-hash-key field))) + (list 'gethash-lazy hash-key hash-table-sym (field-default field)))) + + (defun field->sethash-spec (field name struc hash-table-sym) + (let ((hash-key (field-hash-key field)) + (skip-if-default (field-skip-if-default field)) + (default (field-default field))) + (if skip-if-default + (let ((tmpsym (gensym "TMP"))) + `(let ((,tmpsym (,(field-accessor name field) ,struc))) + (unless (equal ,tmpsym ,default) + (setf (gethash ,hash-key ,hash-table-sym) ,tmpsym)))) + `(setf (gethash ,hash-key ,hash-table-sym) (,(field-accessor name field) ,struc))))) + + (defun field->let-gethash-spec (field hash-table-sym) + `(,(field-name field) + (parse-value ',(field-type field) ,(field->gethash-spec field hash-table-sym)))) + + (defun field->make-spec (field) + (list (intern (symbol-name (field-name field)) :keyword) + (field-name field))) + + (defun field->struct-spec (field) + (list (field-name field) (field-default field) :type (field-type field)))) + +;; TODO: Automatically derive path from name +;; TODO: Automatically derive mapfn from type +(defmacro define-tg-method ( + (name type path &optional (method :POST)) + &body field-specs) + (let* ((fields (parse-field-specs field-specs)) + (revfields (reverse fields)) + (args (gensym "ARGS")) + (bot (gensym "BOT-"))) + `(progn + (declaim (ftype (function (bot &key ,@(loop for field in fields + collect (field->ftype-spec field))) + ,type) + ,name)) + (defun ,name (,bot &key ,@(loop for field in fields collect (field->defun-spec field))) + (let (,args) + ,@(loop for field in revfields + collecting + (if (field-skip-if-default field) + `(unless (equal ,(field-name field) ,(field-default field)) + (setf ,args (acons ',(field-name field) ,(field-name field) ,args))) + `(setf ,args (acons ',(field-name field) ,(field-name field) ,args)))) + (do-call ,bot ,method ,path ',type ,args)))))) + +(defmacro define-tg-type (name &body field-specs) + (let* ((fields (parse-field-specs field-specs)) + (revfields (reverse fields)) + (make-name (intern (concatenate 'string "MAKE-" (symbol-name name)))) + (printer (gensym (concatenate 'string "PRINT-" (symbol-name name)))) + (hash (gensym "HASH-")) + (struc (gensym (symbol-name name))) + (stream (gensym "STREAM")) + (depth (gensym "DEPTH")) + (pprint-args (gensym "PPRINT-ARGS")) + (res (gensym "RES")) + (type (gensym "TYPE"))) + `(progn + (defstruct (,name (:print-function ,printer)) + ,@(loop for field in fields + collect (field->struct-spec field))) + (defun ,printer (,struc ,stream ,depth) + (declare (ignore ,depth)) + (let (,pprint-args) + ,@(loop for field in revfields + collecting + (if (field-skip-if-default field) + `(let ((value (,(field-accessor name field) ,struc))) + (unless (equal value ,(field-default field)) + (setf ,pprint-args (list* ',(field-name field) value ,pprint-args)))) + `(setf ,pprint-args (list* ',(field-name field) (,(field-accessor name field) ,struc) ,pprint-args)))) + (format ,stream "~A~<[~;~@{~_~1I~W = ~W~^, ~}~;]~:>" ',name ,pprint-args))) + (defmethod parse-value ((,type (eql ',name)) ,hash) + (let ,(loop for field in fields + collect (field->let-gethash-spec field hash)) + (,make-name ,@(loop for field in fields + append (field->make-spec field))))) + (defmethod jzon:coerced-fields ((,struc ,name)) + (let (,res) + ,@(loop for field in revfields + collecting + (if (field-skip-if-default field) + `(let ((value (,(field-accessor name field) ,struc))) + (unless (equal value ,(field-default field)) + (setf ,res (cons ,(field->coerced-field-spec field name struc) ,res)))) + `(setf ,res (cons ,(field->coerced-field-spec field name struc) ,res)))) + ,res))))) diff --git a/src/tg/message-entity-type.lisp b/src/tg/message-entity-type.lisp new file mode 100644 index 0000000..f904509 --- /dev/null +++ b/src/tg/message-entity-type.lisp @@ -0,0 +1,47 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/message-entity-type + (:use :c2cl :ukkoclot/enum) + (:export + :message-entity-type + :mention + :hashtag + :cashtag + :bot-command + :url-entity + :email + :phone-number + :bold + :italic + :underline + :strikethrough + :spoiler + :blockquote + :expandable-blockquote + :code + :pre + :text-link + :text-mention + :custom-emoji)) +(in-package :ukkoclot/tg/message-entity-type) + +(define-enum message-entity-type + (mention "mention") + (hashtag "hashtag") + (cashtag "cashtag") + (bot-command "bot_command") + (url-entity "url") + (email "email") + (phone-number "phone_number") + (bold "bold") + (italic "italic") + (underline "underline") + (strikethrough "strikethrough") + (spoiler "spoiler") + (blockquote "blockquote") + (expandable-blockquote "expandable_blockquote") + (code "code") + (pre "pre") + (text-link "text_link") + (text-mention "text_mention") + (custom-emoji "custom_emoji")) diff --git a/src/tg/message-entity.lisp b/src/tg/message-entity.lisp new file mode 100644 index 0000000..c5be269 --- /dev/null +++ b/src/tg/message-entity.lisp @@ -0,0 +1,59 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/message-entity + (:use :c2cl :iterate :ukkoclot/tg/macros :ukkoclot/tg/message-entity-type :ukkoclot/tg/user) + (:export + #:message-entity + #:make-message-entity + #:message-entity-p + #:copy-message-entity + #:message-entity-type + #:message-entity-offset + #:message-entity-length + #:message-entity-url + #:message-entity-user + #:message-entity-language + #:message-entity-custom-emoji-id + + #:message-entity-extract)) +(in-package :ukkoclot/tg/message-entity) + +(define-tg-type message-entity + (type message-entity-type) + (offset integer) + (length integer) + (url (or string null) nil) + (user (or user null) nil) + (language (or string null) nil) + (custom-emoji-id (or string null) nil)) + +(unless (= char-code-limit #x110000) + (error "Some UTF-16 fuckery assumes that system chars are UTF-32")) + +(defun utf16-width (ch) + (if (< (char-code ch) #x10000) + 1 + 2)) + +(defun message-entity-extract (entity text) + (with-slots (length offset) entity + (if (= length 0) + "" + (let* ((start (iterate + (with curr-idx16 = 0) + (for ch in-string text with-index curr-idx32) + (for curr-width = (utf16-width ch)) + (when (or (= curr-idx16 offset) + (> (+ curr-idx16 curr-width) offset)) + (return curr-idx32)) + (setq curr-idx16 (+ curr-idx16 curr-width)) + (finally (return (length text))))) + (end (iterate + (with curr-len16 = 0) + (for ch in-string text from start with-index curr-idx32) + (for curr-width = (utf16-width ch)) + (when (>= curr-len16 length) + (return curr-idx32)) + (setq curr-len16 (+ curr-len16 curr-width)) + (finally (return (length text)))))) + (subseq text start end))))) diff --git a/src/tg/message-reaction-updated.lisp b/src/tg/message-reaction-updated.lisp new file mode 100644 index 0000000..f91a8f1 --- /dev/null +++ b/src/tg/message-reaction-updated.lisp @@ -0,0 +1,31 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/message-reaction-updated + (:use + :c2cl + :ukkoclot/tg/chat + :ukkoclot/tg/macros + :ukkoclot/tg/reaction-type + :ukkoclot/tg/user) + (:export + #:message-reaction-updated + #:make-message-reaction-updated + #:message-reaction-updated-p + #:copy-message-reaction-updated + #:message-reaction-updated-chat + #:message-reaction-updated-message-id + #:message-reaction-updated-user + #:message-reaction-updated-actor-chat + #:message-reaction-updated-date + #:message-reaction-updated-old-reaction + #:message-reaction-updated-new-reaction)) +(in-package :ukkoclot/tg/message-reaction-updated) + +(define-tg-type message-reaction-updated + (chat chat) + (message-id integer) + (user (or user null) nil) + (actor-chat (or chat null) nil) + (date integer) + (old-reaction (array reaction-type)) + (new-reaction (array reaction-type))) diff --git a/src/tg/message.lisp b/src/tg/message.lisp new file mode 100644 index 0000000..18eb5c4 --- /dev/null +++ b/src/tg/message.lisp @@ -0,0 +1,172 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/message + (:use + :c2cl + :ukkoclot/tg/animation + :ukkoclot/tg/chat + :ukkoclot/tg/macros + :ukkoclot/tg/message-entity + :ukkoclot/tg/photo-size + :ukkoclot/tg/user) + (:export + #:message-chat-id + #:message-thread-id + #:message-id + + #:message + #:make-message + #:message-p + #:copy-message + #:message-message-id + #:message-message-thread-id + #:message-from + #:message-sender-boost-count + #:message-sender-business-bot + #:message-date + #:message-business-connection-id + #:message-chat + #:message-is-topic-message + #:message-is-automatic-forward + #:message-reply-to-message + #:message-reply-to-checklist-task-id + #:message-via-bot + #:message-edit-date + #:message-has-protected-content + #:message-is-from-offline + #:message-is-paid-post + #:message-media-group-id + #:message-author-signature + #:message-paid-star-count + #:message-text + #:message-entities + #:message-effect-id + #:message-animation + #:message-photo + #:message-caption + #:message-show-caption-above-media + #:message-has-media-spoiler + #:message-new-chat-members + #:message-new-chat-title + #:message-new-chat-photo + #:message-delete-chat-photo + #:message-group-chat-created + #:message-supergroup-chat-created + #:message-channel-chat-created + #:message-migrate-to-chat-id + #:message-migrate-from-chat-id + #:message-pinned-message + #:message-connected-website)) +(in-package :ukkoclot/tg/message) + +;; If this is a MaybeInaccessibleMessage date will be 0 if this is inaccessible +(define-tg-type message + (message-id integer) + (message-thread-id (or integer null) nil) + ;; (direct-messages-topic (or direct-messages-topic null) nil) + (from (or user null) nil) + ;; (sender-chat (or chat null) nil) + (sender-boost-count (or integer null) nil) + (sender-business-bot (or user null) nil) + (date integer) + (business-connection-id (or string null) nil) + (chat chat nil) + ;; (forward-origin (or message-origin null) nil) + (is-topic-message boolean nil) + (is-automatic-forward boolean nil) + (reply-to-message (or message null) nil) + ;; (external-reply (or external-reply-info null) nil) + ;; (quote (or text-quote null) nil) + ;; (reply-to-story (or story null) nil) + (reply-to-checklist-task-id (or integer null) nil) + (via-bot (or user null) nil) + (edit-date (or integer null) nil) + (has-protected-content boolean nil) + (is-from-offline boolean nil) + (is-paid-post boolean nil) + (media-group-id (or string null) nil) + (author-signature (or string null) nil) + (paid-star-count (or string null) nil) + (text (or string null) nil) + (entities (or (array message-entity) null) nil) + ;; (link-preview-options (or link-preview-options null) nil) + ;; (suggested-post-info (or suggested-post-info null) nil) + (effect-id (or string null) nil) + (animation (or animation null) nil) + ;; (audio (or audio null) nil) + ;; (document (or document null) nil) + ;; (paid-media (or paid-media-info null) nil) + (photo (or (array photo-size) null) nil) + ;; (sticker (or sticker null) nil) + ;; (story (or story null) nil) + ;; (video (or video null) nil) + ;; (video-note (or video-note null) nil) + ;; (voice (or voice null) nil) + (caption (or string null) nil) + ;; (caption-entities (or (array message-entity) null) nil) + (show-caption-above-media boolean nil) + (has-media-spoiler boolean nil) + ;; (contact (or contact null) nil) + ;; (dice (or dice null) nil) + ;; (game (or game null) nil) + ;; (poll (or poll null) nil) + ;; (venue (or venue null) nil) + ;; (location (or location null) nil) + (new-chat-members (or (array user) null) nil) + ;; (left-chat-member (or user null) nil) + (new-chat-title (or string null) nil) + (new-chat-photo (or (array photo-size) null) nil) + (delete-chat-photo boolean nil) + (group-chat-created boolean nil) + (supergroup-chat-created boolean nil) + (channel-chat-created boolean nil) + ;; (message-auto-delete-timer-changed (orp message-auto-delete-timer-changed null) nil) + (migrate-to-chat-id (or integer null) nil) + (migrate-from-chat-id (or integer null) nil) + (pinned-message (or message null) nil) + ;; (invoice (or invoice null) nil) + ;; (successful-payment (or successful-payment null) nil) + ;; (refunded-payment (or refunded-payment null) nil) + ;; (users-shared (or users-shared null) nil) + ;; (chat-shared (or chat-shared null) nil) + ;; (gift (or gift-info null) nil) + ;; (unique-gift (or unique-gift-info null) nil) + (connected-website (or string null) nil) + ;; (write-access-allowed (or write-access-allowed null) nil) + ;; (passport-data (or passport-data null) nil) + ;; (proximity-alert-triggered (or proximity-alert-triggered null) nil) + ;; (boost-added (or chat-boost-added null) nil) + ;; (chat-background-set (or chat-background null) nil) + ;; (checklist-tasks-added (or checklist-tasks-added null) nil) + ;; (direct-message-price-changed (or direct-message-price-changed null) nil) + ;; (forum-topic-created (or forum-topic-created null) nil) + ;; (forum-topic-edited (or forum-topic-edited null) nil) + ;; (forum-topic-closed (or forum-topic-closed null) nil) + ;; (forum-topic-reopened (or forum-topic-reopened null) nil) + ;; (general-forum-topic-hidden (or general-forum-topic-hidden null) nil) + ;; (general-forum-topic-unhidden (or general-forum-topic-unhidden null) nil) + ;; (giveaway-created (or giveaway-created null) nil) + ;; (giveaway-winners (or giveaway-winners null) nil) + ;; (giveaway-completed (or giveaway-completed null) nil) + ;; (paid-message-price-changed (or paid-message-price-changed null) nil) + ;; (suggested-post-approved (or suggested-post-approved null) nil) + ;; (suggested-post-approval-failed (or suggested-post-approval-failed null) nil) + ;; (suggested-post-declined (or suggested-post-declined null) nil) + ;; (suggested-post-paid (or suggested-post-paid null) nil) + ;; (suggested-post-refunded (or suggested-post-refunded null) nil) + ;; (video-chat-scheduled (or video-chat-scheduled null) nil) + ;; (video-chat-started (or video-chat-started null) nil) + ;; (video-chat-ended (or video-chat-ended null) nil) + ;; (video-chat-participants-invited (or video-chat-participants-invited null) nil) + ;; (web-app-data (or web-app-data null) nil) + ;; (reply-markup (or inline-keyboard-markup null) nil) + ) + +(defun message-id (msg) + (message-message-id msg)) + +(defun message-chat-id (msg) + (chat-id (message-chat msg))) + +(defun message-thread-id (msg) + (message-message-thread-id msg)) diff --git a/src/tg/parse-mode.lisp b/src/tg/parse-mode.lisp new file mode 100644 index 0000000..57ef2af --- /dev/null +++ b/src/tg/parse-mode.lisp @@ -0,0 +1,11 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/parse-mode + (:use :c2cl :ukkoclot/enum) + (:export :html :markdown-legacy :markdown :parse-mode)) +(in-package :ukkoclot/tg/parse-mode) + +(define-enum parse-mode + (markdown-legacy "Markdown") + (markdown "MarkdownV2") + (html "HTML")) diff --git a/src/tg/photo-size.lisp b/src/tg/photo-size.lisp new file mode 100644 index 0000000..32b586c --- /dev/null +++ b/src/tg/photo-size.lisp @@ -0,0 +1,22 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/photo-size + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:photo-size + #:make-photo-size + #:photo-size-p + #:copy-photo-size + #:photo-size-file-id + #:photo-size-file-unique-id + #:photo-size-width + #:photo-size-height + #:photo-size-file-size)) +(in-package :ukkoclot/tg/photo-size) + +(define-tg-type photo-size + (file-id string) + (file-unique-id string) + (width integer) + (height integer) + (file-size (or integer null) nil)) diff --git a/src/tg/reaction-type-custom-emoji.lisp b/src/tg/reaction-type-custom-emoji.lisp new file mode 100644 index 0000000..9191f1e --- /dev/null +++ b/src/tg/reaction-type-custom-emoji.lisp @@ -0,0 +1,20 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reaction-type-custom-emoji + (:use :c2cl :ukkoclot/enum :ukkoclot/tg/macros) + (:export + #:custom-emoji-type + #:reaction-type-custom-emoji-type + #:reaction-type-custom-emoji + #:make-reaction-type-custom-emoji + #:reaction-type-custom-emoji-p + #:copy-reaction-type-custom-emoji + #:reaction-type-custom-emoji-custom-emoji-id)) +(in-package :ukkoclot/tg/reaction-type-custom-emoji) + +(define-enum reaction-type-custom-emoji-type + (custom-emoji-type "custom_emoji")) + +(define-tg-type reaction-type-custom-emoji + (type reaction-type-custom-emoji-type) + (custom-emoji-id string)) diff --git a/src/tg/reaction-type-emoji.lisp b/src/tg/reaction-type-emoji.lisp new file mode 100644 index 0000000..bf4920a --- /dev/null +++ b/src/tg/reaction-type-emoji.lisp @@ -0,0 +1,20 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reaction-type-emoji + (:use :c2cl :ukkoclot/enum :ukkoclot/tg/macros) + (:export + #:reaction-type-emoji-type + #:emoji-type + #:reaction-type-emoji + #:make-reaction-type-emoji + #:reaction-type-emoji-p + #:copy-reaction-type-emoji + #:reaction-type-emoji-emoji)) +(in-package :ukkoclot/tg/reaction-type-emoji) + +(define-enum reaction-type-emoji-type + (emoji-type "emoji")) + +(define-tg-type reaction-type-emoji + (type reaction-type-emoji-type) + (emoji string)) diff --git a/src/tg/reaction-type-paid.lisp b/src/tg/reaction-type-paid.lisp new file mode 100644 index 0000000..f5b1bfd --- /dev/null +++ b/src/tg/reaction-type-paid.lisp @@ -0,0 +1,18 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reaction-type-paid + (:use :c2cl :ukkoclot/enum :ukkoclot/tg/macros) + (:export + #:reaction-type-paid-type + #:paid-type + #:reaction-type-paid + #:make-reaction-type-paid + #:reaction-type-paid-p + #:copy-reaction-type-paid)) +(in-package :ukkoclot/tg/reaction-type-paid) + +(define-enum reaction-type-paid-type + (paid-type "paid")) + +(define-tg-type reaction-type-paid + (type reaction-type-paid-type)) diff --git a/src/tg/reaction-type.lisp b/src/tg/reaction-type.lisp new file mode 100644 index 0000000..35bf4cd --- /dev/null +++ b/src/tg/reaction-type.lisp @@ -0,0 +1,14 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reaction-type + (:use + :c2cl + :ukkoclot/tg/macros + :ukkoclot/tg/reaction-type-custom-emoji + :ukkoclot/tg/reaction-type-emoji + :ukkoclot/tg/reaction-type-paid) + (:export :reaction-type)) +(in-package :ukkoclot/tg/reaction-type) + +(deftype reaction-type () + '(or reaction-type-emoji reaction-type-custom-emoji reaction-type-paid)) diff --git a/src/tg/reply-keyboard-markup.lisp b/src/tg/reply-keyboard-markup.lisp new file mode 100644 index 0000000..2674c10 --- /dev/null +++ b/src/tg/reply-keyboard-markup.lisp @@ -0,0 +1,24 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reply-keyboard-markup + (:use :c2cl :ukkoclot/tg/keyboard-button :ukkoclot/tg/macros) + (:export + #:reply-keyboard-markup + #:make-reply-keyboard-markup + #:reply-keyboard-markup-p + #:copy-reply-keyboard-markup + #:reply-keyboard-markup-keyboard + #:reply-keyboard-markup-is-persistent + #:reply-keyboard-markup-resize-keyboard + #:reply-keyboard-markup-one-time-keyboard + #:reply-keyboard-markup-input-field-placeholder + #:reply-keyboard-markup-selective)) +(in-package :ukkoclot/tg/reply-keyboard-markup) + +(define-tg-type reply-keyboard-markup + (keyboard (array (array keyboard-button))) + (is-persistent boolean nil) + (resize-keyboard boolean nil) + (one-time-keyboard boolean nil) + (input-field-placeholder (or string null) nil) + (selective boolean nil)) diff --git a/src/tg/reply-keyboard-remove.lisp b/src/tg/reply-keyboard-remove.lisp new file mode 100644 index 0000000..908e46d --- /dev/null +++ b/src/tg/reply-keyboard-remove.lisp @@ -0,0 +1,16 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reply-keyboard-remove + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:reply-keyboard-remove + #:make-reply-keyboard-remove + #:reply-keyboard-remove-p + #:copy-reply-keyboard-remove + #:reply-keyboard-remove-remove-keyboard + #:reply-keyboard-remove-selective)) +(in-package :ukkoclot/tg/reply-keyboard-remove) + +(define-tg-type reply-keyboard-remove + (remove-keyboard boolean t :skip-if-default nil) + (selective boolean nil)) diff --git a/src/tg/reply-parameters.lisp b/src/tg/reply-parameters.lisp new file mode 100644 index 0000000..e41d837 --- /dev/null +++ b/src/tg/reply-parameters.lisp @@ -0,0 +1,29 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/reply-parameters + (:use :c2cl :ukkoclot/tg/macros :ukkoclot/tg/message-entity) + (:export + #:reply-parameters + #:make-reply-parameters + #:reply-parameters-p + #:copy-reply-parameters + #:reply-parameters-message-id + #:reply-parameters-chat-id + #:reply-parameters-allow-sending-without-reply + #:reply-parameters-quote + #:reply-parameters-quote-parse-mode + #:reply-parameters-quote-entities + #:reply-parameters-quote-position + #:reply-parameters-checklist-task-id)) +(in-package :ukkoclot/tg/reply-parameters) + +(define-tg-type reply-parameters + (message-id integer) + (chat-id (or integer string null) nil) + ;; TODO: This should be a ternary true, false, default + (allow-sending-without-reply boolean nil) + (quote (or string null) nil) + (quote-parse-mode (or string null) nil) + (quote-entities (or (array message-entity) null) nil) + (quote-position (or integer null) nil) + (checklist-task-id (or integer null) nil)) diff --git a/src/tg/suggested-post-parameters.lisp b/src/tg/suggested-post-parameters.lisp new file mode 100644 index 0000000..525272a --- /dev/null +++ b/src/tg/suggested-post-parameters.lisp @@ -0,0 +1,16 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/suggested-post-parameters + (:use :c2cl :ukkoclot/tg/macros :ukkoclot/tg/suggested-post-price) + (:export + #:suggested-post-parameters + #:make-suggested-post-parameters + #:suggested-post-parameters-p + #:copy-suggested-post-parameters + #:suggested-post-parameters-price + #:suggested-post-parameters-send-date)) +(in-package :ukkoclot/tg/suggested-post-parameters) + +(define-tg-type suggested-post-parameters + (price (or suggested-post-price null) nil) + (send-date (or integer null) nil)) diff --git a/src/tg/suggested-post-price.lisp b/src/tg/suggested-post-price.lisp new file mode 100644 index 0000000..9012e75 --- /dev/null +++ b/src/tg/suggested-post-price.lisp @@ -0,0 +1,16 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/suggested-post-price + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:suggested-post-price + #:make-suggested-post-price + #:suggested-post-price-p + #:copy-suggested-post-price + #:suggested-post-price-currency + #:suggested-post-price-amount)) +(in-package :ukkoclot/tg/suggested-post-price) + +(define-tg-type suggested-post-price + (currency string) ;(member "XTR" "TON") + (amount integer)) diff --git a/src/tg/update.lisp b/src/tg/update.lisp new file mode 100644 index 0000000..1f0a463 --- /dev/null +++ b/src/tg/update.lisp @@ -0,0 +1,52 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/update + (:use + :c2cl + :ukkoclot/tg/macros + :ukkoclot/tg/business-connection + :ukkoclot/tg/callback-query + :ukkoclot/tg/message + :ukkoclot/tg/message-reaction-updated) + (:export + #:update + #:make-update + #:update-p + #:copy-update + #:update-update-id + #:update-message + #:update-edited-message + #:update-channel-post + #:update-edited-channel-post + #:update-business-connection + #:update-business-message + #:update-edited-business-message + #:update-message-reaction + #:update-callback-query)) +(in-package :ukkoclot/tg/update) + +(define-tg-type update + (update-id integer) + (message (or message null) nil) + (edited-message (or message null) nil) + (channel-post (or message null) nil) + (edited-channel-post (or message null) nil) + (business-connection (or business-connection null) nil) + (business-message (or message null) nil) + (edited-business-message (or message null) nil) + ;; (deleted-business-messages (or business-messages-deleted null) nil) + (message-reaction (or message-reaction-updated null) nil) + ;; (message-reaction-count (or message-reaction-count-updated null) nil) + ;; (inline-query (or inline-query null) nil) + ;; (chosen-inline-result (or chosen-inline-result null) nil) + (callback-query (or callback-query null) nil) + ;; (shipping-query (or shipping-query null) nil) + ;; (pre-checkout-query (or pre-checkout-query null) nil) + ;; (poll (or poll null) nil) + ;; (poll-answer (or poll-answer null) nil) + ;; (my-chat-member (or chat-member-updated null) nil) + ;; (chat-member (or chat-member-updated null) nil) + ;; (chat-join-request (or chat-join-request null) nil) + ;; (chat-boost (or chat-boost-updated null) nil) + ;; (removed-chat-boost (or chat-boost-removed) nil) + ) diff --git a/src/tg/user.lisp b/src/tg/user.lisp new file mode 100644 index 0000000..c5b5b4d --- /dev/null +++ b/src/tg/user.lisp @@ -0,0 +1,59 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/user + (:use :c2cl :ukkoclot/tg/macros) + (:import-from :ukkoclot/strings :escape-xml) + (:export + #:user + #:make-user + #:user-p + #:copy-user + #:user-id + #:user-is-bot + #:user-first-name + #:user-last-name + #:user-username + #:user-language-code + #:user-is-premium + #:user-added-to-attachment-menu + #:user-can-join-groups + #:user-can-read-all-group-messages + #:user-supports-inline-queries + #:user-can-connect-to-business + + #:user-format-name)) +(in-package :ukkoclot/tg/user) + +(define-tg-type user + (id integer) + (is-bot boolean) + (first-name string) + (last-name (or string null) nil) + (username (or string null) nil) + (language-code (or string null) nil) + (is-premium boolean nil) + (added-to-attachment-menu boolean nil) + (can-join-groups boolean nil) + (can-read-all-group-messages boolean nil) + (supports-inline-queries boolean nil) + (can-connect-to-business boolean nil)) + +(defun user-format-name% (user out) + (format out "" (user-id user)) + (escape-xml (user-first-name user) out) + (when (user-last-name user) + (write-char #\Space out) + (escape-xml (user-last-name user) out)) + (write-string "" out) + + (when (user-username user) + (write-string " @" out) + (escape-xml (user-username user) out)) + + (format out " [~A]" (user-id user))) + +(defun user-format-name (user &optional out) + (if out + (user-format-name% user out) + (with-output-to-string (stream) + (user-format-name% user stream)))) diff --git a/src/tg/web-app-info.lisp b/src/tg/web-app-info.lisp new file mode 100644 index 0000000..8e96df2 --- /dev/null +++ b/src/tg/web-app-info.lisp @@ -0,0 +1,14 @@ +;; SPDX-License-Identifier: EUPL-1.2 +;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs +(defpackage :ukkoclot/tg/web-app-info + (:use :c2cl :ukkoclot/tg/macros) + (:export + #:web-app-info + #:make-web-app-info + #:web-app-info-p + #:copy-web-app-info + #:web-app-info-url)) +(in-package :ukkoclot/tg/web-app-info) + +(define-tg-type web-app-info + (url string)) -- cgit v1.2.3