summaryrefslogtreecommitdiff
path: root/src/tg
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-10-13 06:32:57 +0300
committerGravatar Uko Kokņevičs2025-10-13 06:32:57 +0300
commit9e424b351da370630924e32d0a84eba6fdb8c05e (patch)
tree60999a1b91e73c8aa74e43085e3c0be39d5ec8cf /src/tg
parentImprove define-tg-method (diff)
downloadukkoclot-9e424b351da370630924e32d0a84eba6fdb8c05e.tar.gz
ukkoclot-9e424b351da370630924e32d0a84eba6fdb8c05e.tar.xz
ukkoclot-9e424b351da370630924e32d0a84eba6fdb8c05e.zip
Move bot/methods to tg/*
Diffstat (limited to 'src/tg')
-rw-r--r--src/tg/answer-callback-query.lisp13
-rw-r--r--src/tg/delete-message.lisp10
-rw-r--r--src/tg/edit-message-text.lisp25
-rw-r--r--src/tg/get-me.lisp15
-rw-r--r--src/tg/get-my-name.lisp9
-rw-r--r--src/tg/get-updates.lisp12
-rw-r--r--src/tg/send-animation.lisp40
-rw-r--r--src/tg/send-message.lisp31
-rw-r--r--src/tg/set-my-name.lisp19
9 files changed, 174 insertions, 0 deletions
diff --git a/src/tg/answer-callback-query.lisp b/src/tg/answer-callback-query.lisp
new file mode 100644
index 0000000..badd8a4
--- /dev/null
+++ b/src/tg/answer-callback-query.lisp
@@ -0,0 +1,13 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/answer-callback-query
4 (:use :c2cl :ukkoclot/bot/method-macros)
5 (:export :answer-callback-query))
6(in-package :ukkoclot/tg/answer-callback-query)
7
8(define-tg-method (answer-callback-query boolean)
9 (callback-query-id string)
10 (text (or string null) nil)
11 (show-alert boolean nil)
12 (url (or string null) nil)
13 (cache-time (or integer null) nil))
diff --git a/src/tg/delete-message.lisp b/src/tg/delete-message.lisp
new file mode 100644
index 0000000..3e79de7
--- /dev/null
+++ b/src/tg/delete-message.lisp
@@ -0,0 +1,10 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/delete-message
4 (:use :c2cl :ukkoclot/bot/method-macros)
5 (:export :delete-message))
6(in-package :ukkoclot/tg/delete-message)
7
8(define-tg-method (delete-message boolean)
9 (chat-id (or integer string))
10 (message-id integer))
diff --git a/src/tg/edit-message-text.lisp b/src/tg/edit-message-text.lisp
new file mode 100644
index 0000000..a7db3a8
--- /dev/null
+++ b/src/tg/edit-message-text.lisp
@@ -0,0 +1,25 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/edit-message-text
4 (:use
5 :c2cl
6 :ukkoclot/tg/inline-keyboard-markup
7 :ukkoclot/tg/link-preview-options
8 :ukkoclot/tg/message
9 :ukkoclot/tg/message-entity
10 :ukkoclot/bot/method-macros
11 :ukkoclot/tg/parse-mode)
12 (:export :edit-message-text))
13(in-package :ukkoclot/tg/edit-message-text)
14
15;; TODO: Add a way to simply specify :message msg :)
16(define-tg-method (edit-message-text message)
17 (business-connection-id (or string null) nil)
18 (chat-id (or integer string null) nil)
19 (message-id (or integer null) nil)
20 (inline-message-id (or string null) nil)
21 (text string)
22 (parse-mode (or parse-mode null) nil)
23 (entities (or (array message-entity) null) nil)
24 (link-preview-options (or link-preview-options null) nil)
25 (reply-markup (or inline-keyboard-markup null) nil))
diff --git a/src/tg/get-me.lisp b/src/tg/get-me.lisp
new file mode 100644
index 0000000..ae00717
--- /dev/null
+++ b/src/tg/get-me.lisp
@@ -0,0 +1,15 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/get-me
4 (:use :c2cl :ukkoclot/bot/method-macros :ukkoclot/tg/user)
5 (:import-from :ukkoclot/state :bot-id% :bot-username%)
6 (:export :get-me))
7(in-package :ukkoclot/tg/get-me)
8
9(define-tg-method (get-me% user :GET))
10
11(defun get-me (bot)
12 (let ((res (get-me% bot)))
13 (setf (bot-id% bot) (user-id res))
14 (setf (bot-username% bot) (user-username res))
15 res))
diff --git a/src/tg/get-my-name.lisp b/src/tg/get-my-name.lisp
new file mode 100644
index 0000000..59bb753
--- /dev/null
+++ b/src/tg/get-my-name.lisp
@@ -0,0 +1,9 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/get-my-name
4 (:use :c2cl :ukkoclot/tg/bot-name :ukkoclot/bot/method-macros)
5 (:export :get-my-name))
6(in-package :ukkoclot/tg/get-my-name)
7
8(define-tg-method (get-my-name bot-name :GET)
9 (language-code (or string null) nil))
diff --git a/src/tg/get-updates.lisp b/src/tg/get-updates.lisp
new file mode 100644
index 0000000..15f5e3f
--- /dev/null
+++ b/src/tg/get-updates.lisp
@@ -0,0 +1,12 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/get-updates
4 (:use :c2cl :ukkoclot/bot/method-macros :ukkoclot/tg/update)
5 (:export :get-updates))
6(in-package :ukkoclot/tg/get-updates)
7
8(define-tg-method (get-updates (array update))
9 (offset (or integer null) nil)
10 (limit (or integer null) nil)
11 (timeout (or integer null) nil)
12 (allowed-updates (or string null) nil))
diff --git a/src/tg/send-animation.lisp b/src/tg/send-animation.lisp
new file mode 100644
index 0000000..e9558fa
--- /dev/null
+++ b/src/tg/send-animation.lisp
@@ -0,0 +1,40 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/send-animation
4 (:use
5 :c2cl
6 :ukkoclot/tg/force-reply
7 :ukkoclot/tg/inline-keyboard-markup
8 :ukkoclot/tg/message
9 :ukkoclot/tg/message-entity
10 :ukkoclot/bot/method-macros
11 :ukkoclot/tg/parse-mode
12 :ukkoclot/tg/reply-keyboard-markup
13 :ukkoclot/tg/reply-keyboard-remove
14 :ukkoclot/tg/reply-parameters
15 :ukkoclot/tg/suggested-post-parameters)
16 (:export :send-animation))
17(in-package :ukkoclot/tg/send-animation)
18
19(define-tg-method (send-animation message)
20 (business-connection-id (or string null) nil)
21 (chat-id (or integer string))
22 (message-thread-id (or integer null) nil)
23 (direct-messages-topic-id (or integer null) nil)
24 (animation (or pathname string))
25 (duration (or integer null) nil)
26 (width (or integer null) nil)
27 (height (or integer null) nil)
28 (thumbnail (or pathname string null) nil)
29 (caption (or string null) nil)
30 (parse-mode (or parse-mode null) nil)
31 (caption-entities (or (array message-entity) null) nil)
32 (show-caption-above-media boolean nil)
33 (has-spoiler boolean nil)
34 (disable-notification boolean nil)
35 (protect-content boolean nil)
36 (allow-paid-broadcast boolean nil)
37 (message-effect-id (or string null) nil)
38 (suggested-post-parameters (or suggested-post-parameters null) nil)
39 (reply-parameters (or reply-parameters null) nil)
40 (reply-markup (or inline-keyboard-markup reply-keyboard-markup reply-keyboard-remove force-reply null) nil))
diff --git a/src/tg/send-message.lisp b/src/tg/send-message.lisp
new file mode 100644
index 0000000..d2e7248
--- /dev/null
+++ b/src/tg/send-message.lisp
@@ -0,0 +1,31 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/send-message
4 (:use
5 :c2cl
6 :ukkoclot/tg/force-reply
7 :ukkoclot/tg/inline-keyboard-markup
8 :ukkoclot/tg/link-preview-options
9 :ukkoclot/tg/message
10 :ukkoclot/tg/message-entity
11 :ukkoclot/bot/method-macros
12 :ukkoclot/tg/parse-mode
13 :ukkoclot/tg/reply-keyboard-markup
14 :ukkoclot/tg/reply-keyboard-remove
15 :ukkoclot/tg/reply-parameters)
16 (:export :send-message))
17(in-package :ukkoclot/tg/send-message)
18
19(define-tg-method (send-message message)
20 (business-connection-id (or string null) nil)
21 (chat-id (or integer string))
22 (message-thread-id (or integer null) nil)
23 (text string)
24 (parse-mode (or parse-mode null) nil)
25 (entities (or (array message-entity) null) nil)
26 (link-preview-options (or link-preview-options null) nil)
27 (disable-notification (or boolean null) nil)
28 (protect-content (or boolean null) nil)
29 (message-effect-id (or string null) nil)
30 (reply-parameters (or reply-parameters null) nil)
31 (reply-markup (or inline-keyboard-markup reply-keyboard-markup reply-keyboard-remove force-reply null) nil))
diff --git a/src/tg/set-my-name.lisp b/src/tg/set-my-name.lisp
new file mode 100644
index 0000000..5638a92
--- /dev/null
+++ b/src/tg/set-my-name.lisp
@@ -0,0 +1,19 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/set-my-name
4 (:use :c2cl :ukkoclot/tg/bot-name :ukkoclot/tg/get-my-name :ukkoclot/bot/method-macros)
5 (:export :set-my-name))
6(in-package :ukkoclot/tg/set-my-name)
7
8(define-tg-method (set-my-name% boolean)
9 (name (or string null) nil)
10 (language-code (or string null) nil))
11
12(defun set-my-name (bot &key (name nil) (language-code nil))
13 (block nil
14 (when name
15 (let ((curr-name (get-my-name bot :language-code language-code)))
16 (when (string= name (bot-name-name curr-name))
17 (return))))
18 (unless (set-my-name% bot :name name :language-code language-code)
19 (error "Failed to set name"))))