summaryrefslogtreecommitdiff
path: root/src/tg/send-message.lisp
blob: 7c24f8733cc246341b352ef15403eb6a0e77ad14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;; SPDX-License-Identifier: EUPL-1.2
;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
(defpackage :ukkoclot/src/tg/send-message
  (:documentation "sendMessage Telegram method")
  (:import-from :serapeum :->)
  (:use
   :c2cl
   :ukkoclot/src/tg/force-reply
   :ukkoclot/src/tg/inline-keyboard-markup
   :ukkoclot/src/tg/link-preview-options
   :ukkoclot/src/tg/message
   :ukkoclot/src/tg/message-entity
   :ukkoclot/src/tg/method-macros
   :ukkoclot/src/tg/parse-mode
   :ukkoclot/src/tg/reply-keyboard-markup
   :ukkoclot/src/tg/reply-keyboard-remove
   :ukkoclot/src/tg/reply-parameters)
  (:export :reply-message :send-message))
(in-package :ukkoclot/src/tg/send-message)

(define-tg-method (send-message message)
  (business-connection-id (or string null) nil)
  (chat-id (or integer string))
  (message-thread-id (or integer null) nil)
  (text string)
  (parse-mode (or parse-mode null) nil)
  (entities (or (array message-entity) null) nil)
  (link-preview-options (or link-preview-options null) nil)
  (disable-notification (or boolean null) nil)
  (protect-content (or boolean null) nil)
  (message-effect-id (or string null) nil)
  (reply-parameters (or reply-parameters null) nil)
  (reply-markup (or inline-keyboard-markup reply-keyboard-markup reply-keyboard-remove force-reply null) nil))

(-> reply-message (message
                   string
                   &key
                   (:parse-mode (or parse-mode null))
                   (:allow-sending-without-reply boolean)))
(defun reply-message (msg text &key parse-mode allow-sending-without-reply)
  "Shortcut to reply to a given MSG."
  (send-message :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))))