;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/bot/advanced (:use :c2cl :ukkoclot/tg) (:import-from :ukkoclot/state :bot-id% :bot-username%) (:export :bot-id :bot-username :reply-animation :reply-message :try-delete-message)) (in-package :ukkoclot/bot/advanced) (defun bot-id (bot) (or (bot-id% bot) (progn (get-me bot) (bot-id% bot)))) (defun bot-username (bot) (or (bot-username% bot) (progn (get-me bot) (bot-username% bot)))) ;; TODO: Some kind of caching for files? (defun reply-animation (bot msg animation &key allow-sending-without-reply text parse-mode caption-above) (send-animation bot :chat-id (message-chat-id msg) :animation animation :caption text :parse-mode parse-mode :show-caption-above-media caption-above :reply-parameters (make-reply-parameters :allow-sending-without-reply allow-sending-without-reply :message-id (message-id msg) :chat-id (message-chat-id msg)))) (defun reply-message (bot msg text &key parse-mode allow-sending-without-reply) (send-message bot :chat-id (message-chat-id msg) :text text :parse-mode parse-mode :reply-parameters (make-reply-parameters :allow-sending-without-reply allow-sending-without-reply :message-id (message-id msg) :chat-id (message-chat-id msg)))) (defun try-delete-message (bot msg) (handler-case (delete-message bot :chat-id (message-chat-id msg) :message-id (message-id msg)) (error () (handler-case (reply-animation bot msg #P"blob/do-not.mp4" :allow-sending-without-reply nil) (error () nil)))))