diff options
Diffstat (limited to 'src/tg/get-me.lisp')
| -rw-r--r-- | src/tg/get-me.lisp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/tg/get-me.lisp b/src/tg/get-me.lisp index b7e8bc0..e7d41a1 100644 --- a/src/tg/get-me.lisp +++ b/src/tg/get-me.lisp | |||
| @@ -1,27 +1,31 @@ | |||
| 1 | ;; SPDX-License-Identifier: EUPL-1.2 | 1 | ;; SPDX-License-Identifier: EUPL-1.2 |
| 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> | 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> |
| 3 | (defpackage :ukkoclot/src/tg/get-me | 3 | (defpackage :ukkoclot/src/tg/get-me |
| 4 | (:documentation "getMe Telegram method") | ||
| 4 | (:use :c2cl :ukkoclot/src/tg/method-macros :ukkoclot/src/tg/user) | 5 | (:use :c2cl :ukkoclot/src/tg/method-macros :ukkoclot/src/tg/user) |
| 5 | (:import-from :ukkoclot/src/state :bot-id% :bot-username%) | 6 | (:import-from :state) |
| 6 | (:export :bot-id :bot-username :get-me)) | 7 | (:export :bot-id :bot-username :get-me)) |
| 7 | (in-package :ukkoclot/src/tg/get-me) | 8 | (in-package :ukkoclot/src/tg/get-me) |
| 8 | 9 | ||
| 9 | (define-tg-method (get-me% user :GET)) | 10 | (define-tg-method (get-me% user :GET)) |
| 10 | 11 | ||
| 11 | (defun get-me (bot) | 12 | (defun get-me () |
| 12 | (let ((me (get-me% bot))) | 13 | "getMe Telegram method" |
| 13 | (setf (bot-id% bot) (user-id me)) | 14 | (let ((me (get-me%))) |
| 14 | (setf (bot-username% bot) (user-username me)) | 15 | (setf (state:id%) (user-id me)) |
| 16 | (setf (state:username%) (user-username me)) | ||
| 15 | me)) | 17 | me)) |
| 16 | 18 | ||
| 17 | (defun bot-id (bot) | 19 | (defun bot-id () |
| 18 | (or (bot-id% bot) | 20 | "Get the bot's ID, this memoizes the result" |
| 21 | (or (state:id%) | ||
| 19 | (progn | 22 | (progn |
| 20 | (get-me bot) | 23 | (get-me) |
| 21 | (bot-id% bot)))) | 24 | (state:id%)))) |
| 22 | 25 | ||
| 23 | (defun bot-username (bot) | 26 | (defun bot-username () |
| 24 | (or (bot-username% bot) | 27 | "Get the bot's username, this memoizes the result" |
| 28 | (or (state:username%) | ||
| 25 | (progn | 29 | (progn |
| 26 | (get-me bot) | 30 | (get-me) |
| 27 | (bot-username% bot)))) | 31 | (state:username%)))) |