This repository was archived by the owner on Feb 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTelegramBotApi.Types.UpdatingMessages.pas
206 lines (193 loc) · 8.51 KB
/
TelegramBotApi.Types.UpdatingMessages.pas
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{***************************************************************************}
{ }
{ TelegaPi }
{ }
{ Copyright (C) 2021 Maxim Sysoev }
{ }
{ https://t.me/CloudAPI }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit TelegramBotApi.Types.UpdatingMessages;
// The following methods allow you to change an existing message in the message history instead of sending a new
// one with a result of an action. This is most useful for messages with inline keyboards using callback queries, but can//
// also help reduce clutter in conversations with regular chat bots.
// Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.
interface
uses
CloudAPI.Attributes,
CloudAPI.Types,
TelegramBotApi.Types,
TelegramBotApi.Types.Abstract;
type
[caName('editMessageText')]
[caParameterType(TcaParameterType.GetOrPost)]
[caMethod(TcaMethod.POST)]
/// <summary>Use this method to send text messages.
/// On success, the sent Message is returned.
/// </summary>
TtgEditMessageTextArgument = class(TtgSendMessageBaseWithParseMode)
private
[caName('text')]
[caIsRequaired]
[caDefaultValueString('')]
FText: string;
[caName('entities')]
[caDefaultValueString('[]')]
FEntities: TArray<TtgMessageEntity>;
[caDefaultValueBoolean(False)]
[caName('disable_web_page_preview')]
FDisableWebPagePreview: Boolean;
[caName('message_id')]
[caIsRequaired]
FMessageID: Int64;
public
/// <summary>Unique identifier for the target chat or username of the target
/// channel (in the format @channelusername)</summary>
property ChatId;
/// <summary>
/// Required if inline_message_id is not specified. Identifier of the message to
/// edit
/// </summary>
property MessageID: Int64 read FMessageID write FMessageID;
/// <summary>Text of the message to be sent, 1-4096 characters after entities
/// parsing</summary>
property Text: string read FText write FText;
/// <summary>Send Markdown or HTML, if you want Telegram apps to show bold, italic,
/// fixed-width text or inline URLs in your bot's message. </summary>
property ParseMode;
/// <summary>
/// List of special entities that appear in message text, which can be specified
/// instead of parse_mode
/// </summary>
property Entities: TArray<TtgMessageEntity> read FEntities write FEntities;
/// <summary>Disables link previews for links in this message</summary>
property DisableWebPagePreview: Boolean read FDisableWebPagePreview write FDisableWebPagePreview;
/// <summary>Sends the message silently. Users will receive a notification with no
/// sound.</summary>
property DisableNotification;
/// <summary>If the message is a reply, ID of the original message</summary>
property ReplyToMessageId;
/// <summary>
/// Pass True, if the message should be sent even if the specified replied-to
/// message is not found
/// </summary>
property AllowSendingWithoutReply;
end;
[caName('editMessageText')]
[caParameterType(TcaParameterType.GetOrPost)]
[caMethod(TcaMethod.POST)]
/// <summary>Use this method to send text messages.
/// On success, the sent Message is returned.
/// </summary>
TtgEditMessageTextInlineArgument = class(TtgSendMessageBaseWithParseMode)
private
[caName('text')]
[caIsRequaired]
[caDefaultValueString('')]
FText: string;
[caName('entities')]
[caDefaultValueString('[]')]
FEntities: TArray<TtgMessageEntity>;
[caDefaultValueBoolean(False)]
[caName('disable_web_page_preview')]
FDisableWebPagePreview: Boolean;
[caName('inline_message_id')]
[caIsRequaired]
FInlineMessageId: Int64;
public
/// <summary>
/// Required if chat_id and message_id are not specified. Identifier of the inline
/// message
/// </summary>
property InlineMessageId: Int64 read FInlineMessageId write FInlineMessageId;
/// <summary>Text of the message to be sent, 1-4096 characters after entities
/// parsing</summary>
property Text: string read FText write FText;
/// <summary>Send Markdown or HTML, if you want Telegram apps to show bold, italic,
/// fixed-width text or inline URLs in your bot's message. </summary>
property ParseMode;
/// <summary>
/// List of special entities that appear in message text, which can be specified
/// instead of parse_mode
/// </summary>
property Entities: TArray<TtgMessageEntity> read FEntities write FEntities;
/// <summary>Disables link previews for links in this message</summary>
property DisableWebPagePreview: Boolean read FDisableWebPagePreview write FDisableWebPagePreview;
/// <summary>Sends the message silently. Users will receive a notification with no
/// sound.</summary>
property DisableNotification;
/// <summary>If the message is a reply, ID of the original message</summary>
property ReplyToMessageId;
/// <summary>
/// Pass True, if the message should be sent even if the specified replied-to
/// message is not found
/// </summary>
property AllowSendingWithoutReply;
constructor Create; override;
end;
[caName('deleteMessage')]
[caParameterType(TcaParameterType.GetOrPost)]
[caMethod(TcaMethod.POST)]
/// <summary>
/// Use this method to delete a message, including service messages, with the
/// following limitations:
/// - A message can only be deleted if it was sent less than 48 hours ago.
/// - A dice message in a private chat can only be deleted if it was sent more than
/// 24 hours ago.
/// - Bots can delete outgoing messages in private chats, groups, and supergroups.
/// - Bots can delete incoming messages in private chats.
/// - Bots granted can_post_messages permissions can delete outgoing messages in
/// channels.
/// - If the bot is an administrator of a group, it can delete any message there.
/// - If the bot has can_delete_messages permission in a supergroup or a channel,
/// it can delete any message there.
/// Returns True on success.
/// </summary>
TtgDeleteMessageArgument = class
private
[caName('chat_id')]
[caIsRequaired]
[caDefaultValueInt64(0)]
FChatId: TtgUserLink;
[caName('message_id')]
[caIsRequaired]
[caDefaultValueInt64(0)]
FMessageID: Int64;
public
/// <summary>Unique identifier for the target chat or username of the target
/// channel (in the format @channelusername)</summary>
property ChatId: TtgUserLink read FChatId write FChatId;
/// <summary>Identifier of the message to delete</summary>
property MessageID: Int64 read FMessageID write FMessageID;
constructor Create;
end;
implementation
{ TtgEditMessageTextInlineArgument }
constructor TtgEditMessageTextInlineArgument.Create;
begin
inherited;
FInlineMessageId := 0;
end;
{ TtgDeleteMessageArgument }
constructor TtgDeleteMessageArgument.Create;
begin
inherited;
FChatId := 0;
FMessageID := 0;
end;
end.