maxbot-api-client-python 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maxbot_api_client_python/__init__.py +7 -0
- maxbot_api_client_python/api.py +35 -0
- maxbot_api_client_python/client.py +195 -0
- maxbot_api_client_python/exceptions.py +36 -0
- maxbot_api_client_python/tools/__init__.py +8 -0
- maxbot_api_client_python/tools/bots.py +52 -0
- maxbot_api_client_python/tools/chats.py +445 -0
- maxbot_api_client_python/tools/helpers.py +259 -0
- maxbot_api_client_python/tools/messages.py +194 -0
- maxbot_api_client_python/tools/subscriptions.py +101 -0
- maxbot_api_client_python/tools/uploads.py +91 -0
- maxbot_api_client_python/types/__init__.py +4 -0
- maxbot_api_client_python/types/constants.py +109 -0
- maxbot_api_client_python/types/models.py +458 -0
- maxbot_api_client_python/utils.py +68 -0
- maxbot_api_client_python-1.1.0.dist-info/METADATA +241 -0
- maxbot_api_client_python-1.1.0.dist-info/RECORD +20 -0
- maxbot_api_client_python-1.1.0.dist-info/WHEEL +5 -0
- maxbot_api_client_python-1.1.0.dist-info/licenses/LICENSE +21 -0
- maxbot_api_client_python-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Any
|
|
3
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
4
|
+
from maxbot_api_client_python.types.constants import (
|
|
5
|
+
AttachmentType, ChatType, ChatStatus, MarkupType, Format, UpdateType,
|
|
6
|
+
LinkedMessageType, SenderAction, ChatAdminPermission, ButtonType, UploadType
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
class MaxBotModel(BaseModel):
|
|
10
|
+
model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
|
|
11
|
+
|
|
12
|
+
class APIError(MaxBotModel):
|
|
13
|
+
code: str
|
|
14
|
+
message: str
|
|
15
|
+
|
|
16
|
+
class SimpleQueryResult(MaxBotModel):
|
|
17
|
+
success: bool = Field(..., alias="success")
|
|
18
|
+
message: str | None = Field(None, alias="message")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class User(MaxBotModel):
|
|
22
|
+
user_id: int
|
|
23
|
+
first_name: str
|
|
24
|
+
last_name: str | None = None
|
|
25
|
+
username: str | None = None
|
|
26
|
+
is_bot: bool
|
|
27
|
+
last_activity_time: int
|
|
28
|
+
|
|
29
|
+
class BotCommand(MaxBotModel):
|
|
30
|
+
name: str
|
|
31
|
+
description: str | None = None
|
|
32
|
+
|
|
33
|
+
class BotInfo(User):
|
|
34
|
+
description: str | None = None
|
|
35
|
+
avatar_url: str | None = None
|
|
36
|
+
full_avatar_url: str | None = None
|
|
37
|
+
commands: list[BotCommand] | None = None
|
|
38
|
+
|
|
39
|
+
class DialogWithUser(User):
|
|
40
|
+
description: str | None = None
|
|
41
|
+
avatar_url: str
|
|
42
|
+
full_avatar_url: str
|
|
43
|
+
|
|
44
|
+
class ChatMember(DialogWithUser):
|
|
45
|
+
last_access_time: int
|
|
46
|
+
is_owner: bool
|
|
47
|
+
is_admin: bool
|
|
48
|
+
join_time: int
|
|
49
|
+
permissions: list[ChatAdminPermission]
|
|
50
|
+
alias: str | None = None
|
|
51
|
+
|
|
52
|
+
class ChatAdmin(MaxBotModel):
|
|
53
|
+
user_id: int
|
|
54
|
+
permissions: list[ChatAdminPermission]
|
|
55
|
+
alias: str | None = None
|
|
56
|
+
|
|
57
|
+
class Recipient(MaxBotModel):
|
|
58
|
+
chat_id: int | None = None
|
|
59
|
+
chat_type: ChatType
|
|
60
|
+
user_id: int | None = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Image(MaxBotModel):
|
|
64
|
+
url: str
|
|
65
|
+
|
|
66
|
+
class Photos(MaxBotModel):
|
|
67
|
+
token: str
|
|
68
|
+
|
|
69
|
+
class PhotoData(MaxBotModel):
|
|
70
|
+
token: str
|
|
71
|
+
|
|
72
|
+
class ImagePayload(MaxBotModel):
|
|
73
|
+
photos: dict[str, PhotoData]
|
|
74
|
+
|
|
75
|
+
class StickerData(MaxBotModel):
|
|
76
|
+
url: str | None = None
|
|
77
|
+
code: str | None = None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class MediaPayload(MaxBotModel):
|
|
81
|
+
url: str | None = None
|
|
82
|
+
token: str | None = None
|
|
83
|
+
|
|
84
|
+
class PhotoAttachmentPayload(MaxBotModel):
|
|
85
|
+
photo_id: int | None = None
|
|
86
|
+
token: str | None = None
|
|
87
|
+
url: str | None = None
|
|
88
|
+
|
|
89
|
+
class PhotoAttachmentRequestPayload(MaxBotModel):
|
|
90
|
+
url: str
|
|
91
|
+
token: str | None = None
|
|
92
|
+
photos: dict[str, PhotoData] | None = None
|
|
93
|
+
|
|
94
|
+
class VideoAttachmentPayload(MediaPayload):
|
|
95
|
+
thumbnail: str | None = None
|
|
96
|
+
width: int | None = None
|
|
97
|
+
height: int | None = None
|
|
98
|
+
duration: int | None = None
|
|
99
|
+
|
|
100
|
+
class AudioAttachmentPayload(MediaPayload):
|
|
101
|
+
transcription: str | None = None
|
|
102
|
+
|
|
103
|
+
class FileAttachmentPayload(MediaPayload):
|
|
104
|
+
filename: str | None = None
|
|
105
|
+
size: int | None = None
|
|
106
|
+
|
|
107
|
+
class StickerAttachmentPayload(StickerData):
|
|
108
|
+
width: int | None = None
|
|
109
|
+
height: int | None = None
|
|
110
|
+
|
|
111
|
+
class ContactAttachmentPayload(MaxBotModel):
|
|
112
|
+
name: str | None = None
|
|
113
|
+
contact_id: int | None = None
|
|
114
|
+
vcf_info: str | None = None
|
|
115
|
+
vcf_phone: str | None = None
|
|
116
|
+
|
|
117
|
+
class KeyboardButton(MaxBotModel):
|
|
118
|
+
type: ButtonType
|
|
119
|
+
text: str
|
|
120
|
+
payload: str | None = None
|
|
121
|
+
url: str | None = None
|
|
122
|
+
quick: bool | None = None
|
|
123
|
+
web_app: str | None = None
|
|
124
|
+
contact_id: int | None = None
|
|
125
|
+
|
|
126
|
+
class Keyboard(MaxBotModel):
|
|
127
|
+
buttons: list[list[KeyboardButton]]
|
|
128
|
+
|
|
129
|
+
class ShareAttachmentPayload(MaxBotModel):
|
|
130
|
+
url: str | None = None
|
|
131
|
+
token: str | None = None
|
|
132
|
+
title: str | None = None
|
|
133
|
+
description: str | None = None
|
|
134
|
+
image_url: str | None = None
|
|
135
|
+
|
|
136
|
+
class AttachmentRequest(MaxBotModel):
|
|
137
|
+
type: AttachmentType
|
|
138
|
+
|
|
139
|
+
class Attachment(MaxBotModel):
|
|
140
|
+
type: AttachmentType
|
|
141
|
+
payload: Any | None = None
|
|
142
|
+
latitude: float | None = None
|
|
143
|
+
longitude: float | None = None
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class BotPatch(MaxBotModel):
|
|
147
|
+
name: str | None = None
|
|
148
|
+
username: str | None = None
|
|
149
|
+
description: str | None = None
|
|
150
|
+
commands: list[BotCommand] | None = None
|
|
151
|
+
photo: PhotoAttachmentRequestPayload | None = None
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class MarkupElement(MaxBotModel):
|
|
155
|
+
type: MarkupType
|
|
156
|
+
from_: int = Field(alias="from")
|
|
157
|
+
length: int
|
|
158
|
+
|
|
159
|
+
class NewMessageLink(MaxBotModel):
|
|
160
|
+
type: LinkedMessageType
|
|
161
|
+
mid: str
|
|
162
|
+
|
|
163
|
+
class LinkedMessage(MaxBotModel):
|
|
164
|
+
type: LinkedMessageType
|
|
165
|
+
sender: User | None = None
|
|
166
|
+
chat_id: int | None = None
|
|
167
|
+
message: MessageBody | None = None
|
|
168
|
+
|
|
169
|
+
class MessageBody(MaxBotModel):
|
|
170
|
+
mid: str
|
|
171
|
+
seq: int
|
|
172
|
+
text: str | None = None
|
|
173
|
+
attachments: list[Attachment] | None = None
|
|
174
|
+
markup: list[MarkupElement] | None = None
|
|
175
|
+
|
|
176
|
+
class NewMessageBody(MaxBotModel):
|
|
177
|
+
text: str | None = None
|
|
178
|
+
attachments: list[Attachment] | None = None
|
|
179
|
+
link: NewMessageLink | None = None
|
|
180
|
+
notify: bool | None = None
|
|
181
|
+
format: Format | None = None
|
|
182
|
+
|
|
183
|
+
class MessageStat(MaxBotModel):
|
|
184
|
+
views: int
|
|
185
|
+
|
|
186
|
+
class Message(MaxBotModel):
|
|
187
|
+
sender: User | None = None
|
|
188
|
+
recipient: Recipient | None = None
|
|
189
|
+
timestamp: int | None = None
|
|
190
|
+
linked_message: LinkedMessage | None = Field(None, alias="link")
|
|
191
|
+
body: MessageBody | None = None
|
|
192
|
+
stat: MessageStat | None = None
|
|
193
|
+
url: str | None = None
|
|
194
|
+
|
|
195
|
+
class MessagesList(MaxBotModel):
|
|
196
|
+
messages: list[Message]
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class Chat(MaxBotModel):
|
|
200
|
+
chat_id: int
|
|
201
|
+
type: ChatType
|
|
202
|
+
status: ChatStatus
|
|
203
|
+
title: str | None = None
|
|
204
|
+
icon: Image | None = None
|
|
205
|
+
last_event_time: int
|
|
206
|
+
participants_count: int | None = None
|
|
207
|
+
owner_id: int | None = None
|
|
208
|
+
participants: dict[str, int] | None = None
|
|
209
|
+
is_public: bool
|
|
210
|
+
link: str | None = None
|
|
211
|
+
description: str | None = None
|
|
212
|
+
dialog_with_user: DialogWithUser | None = None
|
|
213
|
+
chat_message_id: str | None = None
|
|
214
|
+
pinned_message: Message | None = None
|
|
215
|
+
|
|
216
|
+
class ChatInfo(MaxBotModel):
|
|
217
|
+
chat_id: int
|
|
218
|
+
type: ChatType
|
|
219
|
+
status: ChatStatus
|
|
220
|
+
title: str | None = None
|
|
221
|
+
icon: Image | None = None
|
|
222
|
+
last_event_time: int
|
|
223
|
+
participants_count: int | None = None
|
|
224
|
+
owner_id: int | None = None
|
|
225
|
+
participants: dict[str, int] | None = None
|
|
226
|
+
is_public: bool
|
|
227
|
+
link: str | None = None
|
|
228
|
+
description: str | None = None
|
|
229
|
+
dialog_with_user: list[DialogWithUser] | None = None
|
|
230
|
+
chat_message_id: str | None = None
|
|
231
|
+
pinned_message: list[Message] | None = None
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class Callback(MaxBotModel):
|
|
235
|
+
timestamp: int
|
|
236
|
+
callback_id: str
|
|
237
|
+
payload: str | None = None
|
|
238
|
+
user: User
|
|
239
|
+
|
|
240
|
+
class Update(MaxBotModel):
|
|
241
|
+
update_type: UpdateType
|
|
242
|
+
timestamp: int
|
|
243
|
+
callback: Callback | None = None
|
|
244
|
+
message: Message | None = None
|
|
245
|
+
message_id: str | None = None
|
|
246
|
+
chat_id: int | None = None
|
|
247
|
+
user_id: int | None = None
|
|
248
|
+
muted_until: int | None = None
|
|
249
|
+
user_locale: str | None = None
|
|
250
|
+
is_channel: bool | None = None
|
|
251
|
+
|
|
252
|
+
class MessageCallbackUpdate(Update):
|
|
253
|
+
callback: Callback
|
|
254
|
+
message: Message | None = None
|
|
255
|
+
|
|
256
|
+
class Subscription(MaxBotModel):
|
|
257
|
+
url: str
|
|
258
|
+
time: int
|
|
259
|
+
update_types: list[UpdateType] | None = None
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class GetChatsReq(MaxBotModel):
|
|
263
|
+
count: int | None = Field(None, alias="count")
|
|
264
|
+
marker: int | None = Field(None, alias="marker")
|
|
265
|
+
|
|
266
|
+
class GetChatsResp(MaxBotModel):
|
|
267
|
+
chats: list[Chat]
|
|
268
|
+
marker: int | None = None
|
|
269
|
+
|
|
270
|
+
class GetChatReq(MaxBotModel):
|
|
271
|
+
chat_id: int = Field(..., alias="chatId")
|
|
272
|
+
|
|
273
|
+
class EditChatReq(MaxBotModel):
|
|
274
|
+
chat_id: int = Field(..., alias="chatId")
|
|
275
|
+
icon: Image | None = None
|
|
276
|
+
title: str | None = None
|
|
277
|
+
pin: str | None = None
|
|
278
|
+
notify: bool | None = None
|
|
279
|
+
|
|
280
|
+
class DeleteChatReq(MaxBotModel):
|
|
281
|
+
chat_id: int = Field(..., alias="chatId")
|
|
282
|
+
|
|
283
|
+
class SendActionReq(MaxBotModel):
|
|
284
|
+
chat_id: int = Field(..., alias="chatId")
|
|
285
|
+
action: SenderAction
|
|
286
|
+
|
|
287
|
+
class PinMessageReq(MaxBotModel):
|
|
288
|
+
chat_id: int = Field(..., alias="chatId")
|
|
289
|
+
message_id: str
|
|
290
|
+
notify: bool | None = None
|
|
291
|
+
|
|
292
|
+
class UnpinMessageReq(MaxBotModel):
|
|
293
|
+
chat_id: int = Field(..., alias="chatId")
|
|
294
|
+
|
|
295
|
+
class GetPinnedMessageReq(MaxBotModel):
|
|
296
|
+
chat_id: int = Field(..., alias="chatId")
|
|
297
|
+
|
|
298
|
+
class GetChatMembershipReq(MaxBotModel):
|
|
299
|
+
chat_id: int = Field(..., alias="chatId")
|
|
300
|
+
|
|
301
|
+
class LeaveChatReq(MaxBotModel):
|
|
302
|
+
chat_id: int = Field(..., alias="chatId")
|
|
303
|
+
|
|
304
|
+
class GetChatAdminsReq(MaxBotModel):
|
|
305
|
+
chat_id: int = Field(..., alias="chatId")
|
|
306
|
+
|
|
307
|
+
class GetChatAdminsResp(MaxBotModel):
|
|
308
|
+
members: list[ChatMember]
|
|
309
|
+
marker: int | None = None
|
|
310
|
+
|
|
311
|
+
class SetChatAdminsReq(MaxBotModel):
|
|
312
|
+
chat_id: int = Field(..., alias="chatId")
|
|
313
|
+
admins: list[ChatAdmin]
|
|
314
|
+
marker: int | None = None
|
|
315
|
+
|
|
316
|
+
class DeleteAdminReq(MaxBotModel):
|
|
317
|
+
chat_id: int = Field(..., alias="chatId")
|
|
318
|
+
user_id: int = Field(..., alias="userId")
|
|
319
|
+
|
|
320
|
+
class GetChatMembersReq(MaxBotModel):
|
|
321
|
+
chat_id: int = Field(..., alias="chatId")
|
|
322
|
+
user_ids: list[int] | None = Field(None, alias="user_ids")
|
|
323
|
+
marker: int | None = Field(None, alias="marker")
|
|
324
|
+
count: int | None = Field(None, alias="count")
|
|
325
|
+
|
|
326
|
+
class AddMembersReq(MaxBotModel):
|
|
327
|
+
chat_id: int = Field(..., alias="chatId")
|
|
328
|
+
user_ids: list[int] | None = None
|
|
329
|
+
|
|
330
|
+
class FailedUserDetails(MaxBotModel):
|
|
331
|
+
error_code: str
|
|
332
|
+
user_ids: list[int]
|
|
333
|
+
|
|
334
|
+
class AddMembersResp(SimpleQueryResult):
|
|
335
|
+
failed_user_ids: list[int] | None = Field(None, alias="failed_user_ids")
|
|
336
|
+
failed_user_details: list[FailedUserDetails] | None = Field(None, alias="failed_user_details")
|
|
337
|
+
|
|
338
|
+
class DeleteMemberReq(MaxBotModel):
|
|
339
|
+
chat_id: int = Field(..., alias="chatId")
|
|
340
|
+
user_id: int = Field(..., alias="userId")
|
|
341
|
+
block: bool | None = Field(None, alias="block")
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
class GetMessagesReq(MaxBotModel):
|
|
345
|
+
chat_id: int | None = Field(None, alias="chat_id")
|
|
346
|
+
message_ids: list[str] | None = Field(None, alias="message_ids")
|
|
347
|
+
from_: int | None = Field(None, alias="from")
|
|
348
|
+
to: int | None = Field(None, alias="to")
|
|
349
|
+
count: int | None = Field(None, alias="count")
|
|
350
|
+
|
|
351
|
+
class SendMessageReq(MaxBotModel):
|
|
352
|
+
user_id: int | None = Field(None, alias="user_id")
|
|
353
|
+
chat_id: int | None = Field(None, alias="chat_id")
|
|
354
|
+
text: str | None = None
|
|
355
|
+
format: Format | None = None
|
|
356
|
+
notify: bool | None = None
|
|
357
|
+
attachments: list[Attachment] | None = None
|
|
358
|
+
link: NewMessageLink | None = None
|
|
359
|
+
disable_link_preview: bool | None = Field(None, alias="disable_link_preview")
|
|
360
|
+
|
|
361
|
+
class SendMessageResp(MaxBotModel):
|
|
362
|
+
message: Message
|
|
363
|
+
|
|
364
|
+
class EditMessageReq(MaxBotModel):
|
|
365
|
+
message_id: str = Field(..., alias="message_id")
|
|
366
|
+
text: str | None = None
|
|
367
|
+
attachments: list[Attachment] | None = None
|
|
368
|
+
link: NewMessageLink | None = None
|
|
369
|
+
notify: bool | None = None
|
|
370
|
+
format: Format | None = None
|
|
371
|
+
|
|
372
|
+
class DeleteMessageReq(MaxBotModel):
|
|
373
|
+
message_id: str = Field(..., alias="message_id")
|
|
374
|
+
|
|
375
|
+
class GetMessageReq(MaxBotModel):
|
|
376
|
+
message_id: str = Field(..., alias="message_id")
|
|
377
|
+
|
|
378
|
+
class VideoUrls(MaxBotModel):
|
|
379
|
+
mp4_1080: str | None = None
|
|
380
|
+
mp4_720: str | None = None
|
|
381
|
+
mp4_480: str | None = None
|
|
382
|
+
mp4_360: str | None = None
|
|
383
|
+
mp4_240: str | None = None
|
|
384
|
+
mp4_144: str | None = None
|
|
385
|
+
hls: str | None = None
|
|
386
|
+
|
|
387
|
+
class VideoInfo(MaxBotModel):
|
|
388
|
+
id: str
|
|
389
|
+
status: str
|
|
390
|
+
duration: int
|
|
391
|
+
url: str
|
|
392
|
+
|
|
393
|
+
class GetVideoInfoReq(MaxBotModel):
|
|
394
|
+
video_token: str = Field(..., alias="video_token")
|
|
395
|
+
|
|
396
|
+
class GetVideoInfoResp(MaxBotModel):
|
|
397
|
+
token: str
|
|
398
|
+
urls: VideoUrls | None = None
|
|
399
|
+
thumbnail: PhotoAttachmentPayload | None = None
|
|
400
|
+
width: int | None = None
|
|
401
|
+
height: int | None = None
|
|
402
|
+
duration: int | None = None
|
|
403
|
+
|
|
404
|
+
class AnswerCallbackReq(MaxBotModel):
|
|
405
|
+
callback_id: str = Field(..., alias="callback_id")
|
|
406
|
+
message: NewMessageBody | None = None
|
|
407
|
+
notification: str | None = None
|
|
408
|
+
|
|
409
|
+
class SendFileReq(MaxBotModel):
|
|
410
|
+
user_id: int | None = Field(None, alias="user_id")
|
|
411
|
+
chat_id: int | None = Field(None, alias="chat_id")
|
|
412
|
+
text: str | None = None
|
|
413
|
+
format: Format | None = None
|
|
414
|
+
notify: bool | None = None
|
|
415
|
+
file_source: str
|
|
416
|
+
link: NewMessageLink | None = None
|
|
417
|
+
disable_link_preview: bool | None = Field(None, alias="disable_link_preview")
|
|
418
|
+
attachments: list[Attachment] | None = None
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
class GetSubscriptionsResp(MaxBotModel):
|
|
422
|
+
subscriptions: list[Subscription]
|
|
423
|
+
|
|
424
|
+
class SubscribeReq(MaxBotModel):
|
|
425
|
+
url: str
|
|
426
|
+
update_types: list[UpdateType] | None = None
|
|
427
|
+
secret: str | None = None
|
|
428
|
+
|
|
429
|
+
class UnsubscribeReq(MaxBotModel):
|
|
430
|
+
url: str = Field(..., alias="url")
|
|
431
|
+
|
|
432
|
+
class GetUpdatesReq(MaxBotModel):
|
|
433
|
+
limit: int | None = Field(None, alias="limit")
|
|
434
|
+
timeout: int | None = Field(None, alias="timeout")
|
|
435
|
+
marker: int | None = Field(None, alias="marker")
|
|
436
|
+
types: list[UpdateType] | None = Field(None, alias="types")
|
|
437
|
+
|
|
438
|
+
class GetUpdatesResp(MaxBotModel):
|
|
439
|
+
updates: list[Update]
|
|
440
|
+
marker: int
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
class UploadFileReq(MaxBotModel):
|
|
444
|
+
type: UploadType = Field(..., alias="type")
|
|
445
|
+
upload_url: str | None = None
|
|
446
|
+
file_path: str | None = None
|
|
447
|
+
|
|
448
|
+
class UploadTypeReq(MaxBotModel):
|
|
449
|
+
type: UploadType = Field(..., alias="type")
|
|
450
|
+
|
|
451
|
+
class UploadFileMultipartReq(MaxBotModel):
|
|
452
|
+
upload_url: str
|
|
453
|
+
file_path: str
|
|
454
|
+
|
|
455
|
+
class UploadedInfo(MaxBotModel):
|
|
456
|
+
file_id: int | None = None
|
|
457
|
+
token: str | None = None
|
|
458
|
+
photos: dict[str, PhotoData] | None = None
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from maxbot_api_client_python.types.models import (
|
|
4
|
+
Attachment, AttachmentType, AudioAttachmentPayload, ContactAttachmentPayload,
|
|
5
|
+
FileAttachmentPayload, Keyboard, KeyboardButton, PhotoAttachmentPayload,
|
|
6
|
+
ShareAttachmentPayload, StickerAttachmentPayload, VideoAttachmentPayload
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
def attach_image(token: str | None = None, url: str | None = None) -> Attachment:
|
|
10
|
+
return Attachment(
|
|
11
|
+
type=AttachmentType.IMAGE,
|
|
12
|
+
payload=PhotoAttachmentPayload(token=token, url=url).model_dump(exclude_none=True)
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def attach_video(token: str | None = None, url: str | None = None) -> Attachment:
|
|
16
|
+
return Attachment(
|
|
17
|
+
type=AttachmentType.VIDEO,
|
|
18
|
+
payload=VideoAttachmentPayload(token=token, url=url).model_dump(exclude_none=True)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def attach_audio(token: str | None = None, url: str | None = None) -> Attachment:
|
|
22
|
+
return Attachment(
|
|
23
|
+
type=AttachmentType.AUDIO,
|
|
24
|
+
payload=AudioAttachmentPayload(token=token, url=url).model_dump(exclude_none=True)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def attach_file(token: str | None = None, url: str | None = None, filename: str | None = None) -> Attachment:
|
|
28
|
+
return Attachment(
|
|
29
|
+
type=AttachmentType.FILE,
|
|
30
|
+
payload=FileAttachmentPayload(token=token, url=url, filename=filename).model_dump(exclude_none=True)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def attach_sticker(url: str | None = None, code: str | None = None) -> Attachment:
|
|
34
|
+
return Attachment(
|
|
35
|
+
type=AttachmentType.STICKER,
|
|
36
|
+
payload=StickerAttachmentPayload(url=url, code=code).model_dump(exclude_none=True)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
def attach_contact(name: str, phone: str, contact_id: int | None = None) -> Attachment:
|
|
40
|
+
vcf_info = f"BEGIN:VCARD\nVERSION:3.0\nFN:{name}\nTEL:{phone}\nEND:VCARD"
|
|
41
|
+
return Attachment(
|
|
42
|
+
type=AttachmentType.CONTACT,
|
|
43
|
+
payload=ContactAttachmentPayload(
|
|
44
|
+
name=name,
|
|
45
|
+
contact_id=contact_id,
|
|
46
|
+
vcf_info=vcf_info,
|
|
47
|
+
vcf_phone=phone
|
|
48
|
+
).model_dump(exclude_none=True)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def attach_keyboard(buttons: list[list[KeyboardButton]]) -> Attachment:
|
|
52
|
+
return Attachment(
|
|
53
|
+
type=AttachmentType.KEYBOARD,
|
|
54
|
+
payload=Keyboard(buttons=buttons).model_dump(exclude_none=True)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def attach_share(url: str | None = None, title: str | None = None, desc: str | None = None) -> Attachment:
|
|
58
|
+
return Attachment(
|
|
59
|
+
type=AttachmentType.SHARE,
|
|
60
|
+
payload=ShareAttachmentPayload(url=url, title=title, description=desc).model_dump(exclude_none=True)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def attach_location(lat: float, lon: float) -> Attachment:
|
|
64
|
+
return Attachment(
|
|
65
|
+
type=AttachmentType.LOCATION,
|
|
66
|
+
latitude=lat,
|
|
67
|
+
longitude=lon
|
|
68
|
+
)
|