simplex-chat 6.5.1__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.
- simplex_chat/__init__.py +59 -0
- simplex_chat/__main__.py +35 -0
- simplex_chat/_native.py +257 -0
- simplex_chat/_version.py +9 -0
- simplex_chat/api.py +704 -0
- simplex_chat/bot.py +707 -0
- simplex_chat/core.py +200 -0
- simplex_chat/filters.py +45 -0
- simplex_chat/py.typed +0 -0
- simplex_chat/types/__init__.py +16 -0
- simplex_chat/types/_commands.py +705 -0
- simplex_chat/types/_events.py +379 -0
- simplex_chat/types/_responses.py +360 -0
- simplex_chat/types/_types.py +3506 -0
- simplex_chat/util.py +128 -0
- simplex_chat-6.5.1.dist-info/METADATA +98 -0
- simplex_chat-6.5.1.dist-info/RECORD +19 -0
- simplex_chat-6.5.1.dist-info/WHEEL +4 -0
- simplex_chat-6.5.1.dist-info/licenses/LICENSE +661 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
# API Commands
|
|
2
|
+
# This file is generated automatically.
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
import json
|
|
5
|
+
from typing import NotRequired, TypedDict
|
|
6
|
+
from . import _types as T
|
|
7
|
+
from . import _responses as CR
|
|
8
|
+
|
|
9
|
+
# Address commands
|
|
10
|
+
# Bots can use these commands to automatically check and create address when initialized
|
|
11
|
+
|
|
12
|
+
# Create bot address.
|
|
13
|
+
# Network usage: interactive.
|
|
14
|
+
class APICreateMyAddress(TypedDict):
|
|
15
|
+
userId: int # int64
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def APICreateMyAddress_cmd_string(self: APICreateMyAddress) -> str:
|
|
19
|
+
return '/_address ' + str(self['userId'])
|
|
20
|
+
|
|
21
|
+
APICreateMyAddress_Response = CR.UserContactLinkCreated | CR.ChatCmdError
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Delete bot address.
|
|
25
|
+
# Network usage: background.
|
|
26
|
+
class APIDeleteMyAddress(TypedDict):
|
|
27
|
+
userId: int # int64
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def APIDeleteMyAddress_cmd_string(self: APIDeleteMyAddress) -> str:
|
|
31
|
+
return '/_delete_address ' + str(self['userId'])
|
|
32
|
+
|
|
33
|
+
APIDeleteMyAddress_Response = CR.UserContactLinkDeleted | CR.ChatCmdError
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Get bot address and settings.
|
|
37
|
+
# Network usage: no.
|
|
38
|
+
class APIShowMyAddress(TypedDict):
|
|
39
|
+
userId: int # int64
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def APIShowMyAddress_cmd_string(self: APIShowMyAddress) -> str:
|
|
43
|
+
return '/_show_address ' + str(self['userId'])
|
|
44
|
+
|
|
45
|
+
APIShowMyAddress_Response = CR.UserContactLink | CR.ChatCmdError
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# Add address to bot profile.
|
|
49
|
+
# Network usage: interactive.
|
|
50
|
+
class APISetProfileAddress(TypedDict):
|
|
51
|
+
userId: int # int64
|
|
52
|
+
enable: bool
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def APISetProfileAddress_cmd_string(self: APISetProfileAddress) -> str:
|
|
56
|
+
return '/_profile_address ' + str(self['userId']) + ' ' + ('on' if self['enable'] else 'off')
|
|
57
|
+
|
|
58
|
+
APISetProfileAddress_Response = CR.UserProfileUpdated | CR.ChatCmdError
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Set bot address settings.
|
|
62
|
+
# Network usage: interactive.
|
|
63
|
+
class APISetAddressSettings(TypedDict):
|
|
64
|
+
userId: int # int64
|
|
65
|
+
settings: "T.AddressSettings"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def APISetAddressSettings_cmd_string(self: APISetAddressSettings) -> str:
|
|
69
|
+
return '/_address_settings ' + str(self['userId']) + ' ' + json.dumps(self['settings'])
|
|
70
|
+
|
|
71
|
+
APISetAddressSettings_Response = CR.UserContactLinkUpdated | CR.ChatCmdError
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Message commands
|
|
75
|
+
# Commands to send, update, delete, moderate messages and set message reactions
|
|
76
|
+
|
|
77
|
+
# Send messages.
|
|
78
|
+
# Network usage: background.
|
|
79
|
+
class APISendMessages(TypedDict):
|
|
80
|
+
sendRef: "T.ChatRef"
|
|
81
|
+
liveMessage: bool
|
|
82
|
+
ttl: NotRequired[int] # int
|
|
83
|
+
composedMessages: list["T.ComposedMessage"] # non-empty
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def APISendMessages_cmd_string(self: APISendMessages) -> str:
|
|
87
|
+
return '/_send ' + T.ChatRef_cmd_string(self['sendRef']) + (' live=on' if self['liveMessage'] else '') + ((' ttl=' + str(self.get('ttl'))) if self.get('ttl') is not None else '') + ' json ' + json.dumps(self['composedMessages'])
|
|
88
|
+
|
|
89
|
+
APISendMessages_Response = CR.NewChatItems | CR.ChatCmdError
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Update message.
|
|
93
|
+
# Network usage: background.
|
|
94
|
+
class APIUpdateChatItem(TypedDict):
|
|
95
|
+
chatRef: "T.ChatRef"
|
|
96
|
+
chatItemId: int # int64
|
|
97
|
+
liveMessage: bool
|
|
98
|
+
updatedMessage: "T.UpdatedMessage"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def APIUpdateChatItem_cmd_string(self: APIUpdateChatItem) -> str:
|
|
102
|
+
return '/_update item ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + str(self['chatItemId']) + (' live=on' if self['liveMessage'] else '') + ' json ' + json.dumps(self['updatedMessage'])
|
|
103
|
+
|
|
104
|
+
APIUpdateChatItem_Response = CR.ChatItemUpdated | CR.ChatItemNotChanged | CR.ChatCmdError
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# Delete message.
|
|
108
|
+
# Network usage: background.
|
|
109
|
+
class APIDeleteChatItem(TypedDict):
|
|
110
|
+
chatRef: "T.ChatRef"
|
|
111
|
+
chatItemIds: list[int] # int64, non-empty
|
|
112
|
+
deleteMode: "T.CIDeleteMode"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def APIDeleteChatItem_cmd_string(self: APIDeleteChatItem) -> str:
|
|
116
|
+
return '/_delete item ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + ','.join(map(str, self['chatItemIds'])) + ' ' + str(self['deleteMode'])
|
|
117
|
+
|
|
118
|
+
APIDeleteChatItem_Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# Moderate message. Requires Moderator role (and higher than message author's).
|
|
122
|
+
# Network usage: background.
|
|
123
|
+
class APIDeleteMemberChatItem(TypedDict):
|
|
124
|
+
groupId: int # int64
|
|
125
|
+
chatItemIds: list[int] # int64, non-empty
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def APIDeleteMemberChatItem_cmd_string(self: APIDeleteMemberChatItem) -> str:
|
|
129
|
+
return '/_delete member item #' + str(self['groupId']) + ' ' + ','.join(map(str, self['chatItemIds']))
|
|
130
|
+
|
|
131
|
+
APIDeleteMemberChatItem_Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# Add/remove message reaction.
|
|
135
|
+
# Network usage: background.
|
|
136
|
+
class APIChatItemReaction(TypedDict):
|
|
137
|
+
chatRef: "T.ChatRef"
|
|
138
|
+
chatItemId: int # int64
|
|
139
|
+
add: bool
|
|
140
|
+
reaction: "T.MsgReaction"
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def APIChatItemReaction_cmd_string(self: APIChatItemReaction) -> str:
|
|
144
|
+
return '/_reaction ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + str(self['chatItemId']) + ' ' + ('on' if self['add'] else 'off') + ' ' + json.dumps(self['reaction'])
|
|
145
|
+
|
|
146
|
+
APIChatItemReaction_Response = CR.ChatItemReaction | CR.ChatCmdError
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# File commands
|
|
150
|
+
# Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.
|
|
151
|
+
|
|
152
|
+
# Receive file.
|
|
153
|
+
# Network usage: no.
|
|
154
|
+
class ReceiveFile(TypedDict):
|
|
155
|
+
fileId: int # int64
|
|
156
|
+
userApprovedRelays: bool
|
|
157
|
+
storeEncrypted: NotRequired[bool]
|
|
158
|
+
fileInline: NotRequired[bool]
|
|
159
|
+
filePath: NotRequired[str]
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def ReceiveFile_cmd_string(self: ReceiveFile) -> str:
|
|
163
|
+
return '/freceive ' + str(self['fileId']) + (' approved_relays=on' if self['userApprovedRelays'] else '') + ((' encrypt=' + ('on' if self.get('storeEncrypted') else 'off')) if self.get('storeEncrypted') is not None else '') + ((' inline=' + ('on' if self.get('fileInline') else 'off')) if self.get('fileInline') is not None else '') + ((' ' + self.get('filePath')) if self.get('filePath') is not None else '')
|
|
164
|
+
|
|
165
|
+
ReceiveFile_Response = CR.RcvFileAccepted | CR.RcvFileAcceptedSndCancelled | CR.ChatCmdError
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# Cancel file.
|
|
169
|
+
# Network usage: background.
|
|
170
|
+
class CancelFile(TypedDict):
|
|
171
|
+
fileId: int # int64
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def CancelFile_cmd_string(self: CancelFile) -> str:
|
|
175
|
+
return '/fcancel ' + str(self['fileId'])
|
|
176
|
+
|
|
177
|
+
CancelFile_Response = CR.SndFileCancelled | CR.RcvFileCancelled | CR.ChatCmdError
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# Group commands
|
|
181
|
+
# Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.
|
|
182
|
+
|
|
183
|
+
# Add contact to group. Requires bot to have Admin role.
|
|
184
|
+
# Network usage: interactive.
|
|
185
|
+
class APIAddMember(TypedDict):
|
|
186
|
+
groupId: int # int64
|
|
187
|
+
contactId: int # int64
|
|
188
|
+
memberRole: "T.GroupMemberRole"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def APIAddMember_cmd_string(self: APIAddMember) -> str:
|
|
192
|
+
return '/_add #' + str(self['groupId']) + ' ' + str(self['contactId']) + ' ' + str(self['memberRole'])
|
|
193
|
+
|
|
194
|
+
APIAddMember_Response = CR.SentGroupInvitation | CR.ChatCmdError
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# Join group.
|
|
198
|
+
# Network usage: interactive.
|
|
199
|
+
class APIJoinGroup(TypedDict):
|
|
200
|
+
groupId: int # int64
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def APIJoinGroup_cmd_string(self: APIJoinGroup) -> str:
|
|
204
|
+
return '/_join #' + str(self['groupId'])
|
|
205
|
+
|
|
206
|
+
APIJoinGroup_Response = CR.UserAcceptedGroupSent | CR.ChatCmdError
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# Accept group member. Requires Admin role.
|
|
210
|
+
# Network usage: background.
|
|
211
|
+
class APIAcceptMember(TypedDict):
|
|
212
|
+
groupId: int # int64
|
|
213
|
+
groupMemberId: int # int64
|
|
214
|
+
memberRole: "T.GroupMemberRole"
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def APIAcceptMember_cmd_string(self: APIAcceptMember) -> str:
|
|
218
|
+
return '/_accept member #' + str(self['groupId']) + ' ' + str(self['groupMemberId']) + ' ' + str(self['memberRole'])
|
|
219
|
+
|
|
220
|
+
APIAcceptMember_Response = CR.MemberAccepted | CR.ChatCmdError
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
# Set members role. Requires Admin role.
|
|
224
|
+
# Network usage: background.
|
|
225
|
+
class APIMembersRole(TypedDict):
|
|
226
|
+
groupId: int # int64
|
|
227
|
+
groupMemberIds: list[int] # int64, non-empty
|
|
228
|
+
memberRole: "T.GroupMemberRole"
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def APIMembersRole_cmd_string(self: APIMembersRole) -> str:
|
|
232
|
+
return '/_member role #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + ' ' + str(self['memberRole'])
|
|
233
|
+
|
|
234
|
+
APIMembersRole_Response = CR.MembersRoleUser | CR.ChatCmdError
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
# Block members. Requires Moderator role.
|
|
238
|
+
# Network usage: background.
|
|
239
|
+
class APIBlockMembersForAll(TypedDict):
|
|
240
|
+
groupId: int # int64
|
|
241
|
+
groupMemberIds: list[int] # int64, non-empty
|
|
242
|
+
blocked: bool
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def APIBlockMembersForAll_cmd_string(self: APIBlockMembersForAll) -> str:
|
|
246
|
+
return '/_block #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + ' blocked=' + ('on' if self['blocked'] else 'off')
|
|
247
|
+
|
|
248
|
+
APIBlockMembersForAll_Response = CR.MembersBlockedForAllUser | CR.ChatCmdError
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
# Remove members. Requires Admin role.
|
|
252
|
+
# Network usage: background.
|
|
253
|
+
class APIRemoveMembers(TypedDict):
|
|
254
|
+
groupId: int # int64
|
|
255
|
+
groupMemberIds: list[int] # int64, non-empty
|
|
256
|
+
withMessages: bool
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def APIRemoveMembers_cmd_string(self: APIRemoveMembers) -> str:
|
|
260
|
+
return '/_remove #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + (' messages=on' if self['withMessages'] else '')
|
|
261
|
+
|
|
262
|
+
APIRemoveMembers_Response = CR.UserDeletedMembers | CR.ChatCmdError
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
# Leave group.
|
|
266
|
+
# Network usage: background.
|
|
267
|
+
class APILeaveGroup(TypedDict):
|
|
268
|
+
groupId: int # int64
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def APILeaveGroup_cmd_string(self: APILeaveGroup) -> str:
|
|
272
|
+
return '/_leave #' + str(self['groupId'])
|
|
273
|
+
|
|
274
|
+
APILeaveGroup_Response = CR.LeftMemberUser | CR.ChatCmdError
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
# Get group members.
|
|
278
|
+
# Network usage: no.
|
|
279
|
+
class APIListMembers(TypedDict):
|
|
280
|
+
groupId: int # int64
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def APIListMembers_cmd_string(self: APIListMembers) -> str:
|
|
284
|
+
return '/_members #' + str(self['groupId'])
|
|
285
|
+
|
|
286
|
+
APIListMembers_Response = CR.GroupMembers | CR.ChatCmdError
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
# Create group.
|
|
290
|
+
# Network usage: no.
|
|
291
|
+
class APINewGroup(TypedDict):
|
|
292
|
+
userId: int # int64
|
|
293
|
+
incognito: bool
|
|
294
|
+
groupProfile: "T.GroupProfile"
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def APINewGroup_cmd_string(self: APINewGroup) -> str:
|
|
298
|
+
return '/_group ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '') + ' ' + json.dumps(self['groupProfile'])
|
|
299
|
+
|
|
300
|
+
APINewGroup_Response = CR.GroupCreated | CR.ChatCmdError
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# Create public group.
|
|
304
|
+
# Network usage: interactive.
|
|
305
|
+
class APINewPublicGroup(TypedDict):
|
|
306
|
+
userId: int # int64
|
|
307
|
+
incognito: bool
|
|
308
|
+
relayIds: list[int] # int64, non-empty
|
|
309
|
+
groupProfile: "T.GroupProfile"
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def APINewPublicGroup_cmd_string(self: APINewPublicGroup) -> str:
|
|
313
|
+
return '/_public group ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '') + ' ' + ','.join(map(str, self['relayIds'])) + ' ' + json.dumps(self['groupProfile'])
|
|
314
|
+
|
|
315
|
+
APINewPublicGroup_Response = CR.PublicGroupCreated | CR.PublicGroupCreationFailed | CR.ChatCmdError
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# Get group relays.
|
|
319
|
+
# Network usage: no.
|
|
320
|
+
class APIGetGroupRelays(TypedDict):
|
|
321
|
+
groupId: int # int64
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def APIGetGroupRelays_cmd_string(self: APIGetGroupRelays) -> str:
|
|
325
|
+
return '/_get relays #' + str(self['groupId'])
|
|
326
|
+
|
|
327
|
+
APIGetGroupRelays_Response = CR.GroupRelays | CR.ChatCmdError
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# Add relays to group.
|
|
331
|
+
# Network usage: interactive.
|
|
332
|
+
class APIAddGroupRelays(TypedDict):
|
|
333
|
+
groupId: int # int64
|
|
334
|
+
relayIds: list[int] # int64, non-empty
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def APIAddGroupRelays_cmd_string(self: APIAddGroupRelays) -> str:
|
|
338
|
+
return '/_add relays #' + str(self['groupId']) + ' ' + ','.join(map(str, self['relayIds']))
|
|
339
|
+
|
|
340
|
+
APIAddGroupRelays_Response = CR.GroupRelaysAdded | CR.GroupRelaysAddFailed | CR.ChatCmdError
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# Update group profile.
|
|
344
|
+
# Network usage: background.
|
|
345
|
+
class APIUpdateGroupProfile(TypedDict):
|
|
346
|
+
groupId: int # int64
|
|
347
|
+
groupProfile: "T.GroupProfile"
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def APIUpdateGroupProfile_cmd_string(self: APIUpdateGroupProfile) -> str:
|
|
351
|
+
return '/_group_profile #' + str(self['groupId']) + ' ' + json.dumps(self['groupProfile'])
|
|
352
|
+
|
|
353
|
+
APIUpdateGroupProfile_Response = CR.GroupUpdated | CR.ChatCmdError
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
# Group link commands
|
|
357
|
+
# These commands can be used by bots that manage multiple public groups
|
|
358
|
+
|
|
359
|
+
# Create group link.
|
|
360
|
+
# Network usage: interactive.
|
|
361
|
+
class APICreateGroupLink(TypedDict):
|
|
362
|
+
groupId: int # int64
|
|
363
|
+
memberRole: "T.GroupMemberRole"
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def APICreateGroupLink_cmd_string(self: APICreateGroupLink) -> str:
|
|
367
|
+
return '/_create link #' + str(self['groupId']) + ' ' + str(self['memberRole'])
|
|
368
|
+
|
|
369
|
+
APICreateGroupLink_Response = CR.GroupLinkCreated | CR.ChatCmdError
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
# Set member role for group link.
|
|
373
|
+
# Network usage: no.
|
|
374
|
+
class APIGroupLinkMemberRole(TypedDict):
|
|
375
|
+
groupId: int # int64
|
|
376
|
+
memberRole: "T.GroupMemberRole"
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def APIGroupLinkMemberRole_cmd_string(self: APIGroupLinkMemberRole) -> str:
|
|
380
|
+
return '/_set link role #' + str(self['groupId']) + ' ' + str(self['memberRole'])
|
|
381
|
+
|
|
382
|
+
APIGroupLinkMemberRole_Response = CR.GroupLink | CR.ChatCmdError
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
# Delete group link.
|
|
386
|
+
# Network usage: background.
|
|
387
|
+
class APIDeleteGroupLink(TypedDict):
|
|
388
|
+
groupId: int # int64
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def APIDeleteGroupLink_cmd_string(self: APIDeleteGroupLink) -> str:
|
|
392
|
+
return '/_delete link #' + str(self['groupId'])
|
|
393
|
+
|
|
394
|
+
APIDeleteGroupLink_Response = CR.GroupLinkDeleted | CR.ChatCmdError
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
# Get group link.
|
|
398
|
+
# Network usage: no.
|
|
399
|
+
class APIGetGroupLink(TypedDict):
|
|
400
|
+
groupId: int # int64
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def APIGetGroupLink_cmd_string(self: APIGetGroupLink) -> str:
|
|
404
|
+
return '/_get link #' + str(self['groupId'])
|
|
405
|
+
|
|
406
|
+
APIGetGroupLink_Response = CR.GroupLink | CR.ChatCmdError
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
# Connection commands
|
|
410
|
+
# These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.
|
|
411
|
+
|
|
412
|
+
# Create 1-time invitation link.
|
|
413
|
+
# Network usage: interactive.
|
|
414
|
+
class APIAddContact(TypedDict):
|
|
415
|
+
userId: int # int64
|
|
416
|
+
incognito: bool
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def APIAddContact_cmd_string(self: APIAddContact) -> str:
|
|
420
|
+
return '/_connect ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '')
|
|
421
|
+
|
|
422
|
+
APIAddContact_Response = CR.Invitation | CR.ChatCmdError
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
# Determine SimpleX link type and if the bot is already connected via this link.
|
|
426
|
+
# Network usage: interactive.
|
|
427
|
+
class APIConnectPlan(TypedDict):
|
|
428
|
+
userId: int # int64
|
|
429
|
+
connectionLink: NotRequired[str]
|
|
430
|
+
resolveKnown: bool
|
|
431
|
+
linkOwnerSig: NotRequired["T.LinkOwnerSig"]
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def APIConnectPlan_cmd_string(self: APIConnectPlan) -> str:
|
|
435
|
+
return '/_connect plan ' + str(self['userId']) + ' ' + self.get('connectionLink')
|
|
436
|
+
|
|
437
|
+
APIConnectPlan_Response = CR.ConnectionPlan | CR.ChatCmdError
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
# Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link.
|
|
441
|
+
# Network usage: interactive.
|
|
442
|
+
class APIConnect(TypedDict):
|
|
443
|
+
userId: int # int64
|
|
444
|
+
incognito: bool
|
|
445
|
+
preparedLink_: NotRequired["T.CreatedConnLink"]
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def APIConnect_cmd_string(self: APIConnect) -> str:
|
|
449
|
+
return '/_connect ' + str(self['userId']) + ((' ' + T.CreatedConnLink_cmd_string(self.get('preparedLink_'))) if self.get('preparedLink_') is not None else '')
|
|
450
|
+
|
|
451
|
+
APIConnect_Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
# Connect via SimpleX link as string in the active user profile.
|
|
455
|
+
# Network usage: interactive.
|
|
456
|
+
class Connect(TypedDict):
|
|
457
|
+
incognito: bool
|
|
458
|
+
connLink_: NotRequired[str]
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def Connect_cmd_string(self: Connect) -> str:
|
|
462
|
+
return '/connect' + ((' ' + self.get('connLink_')) if self.get('connLink_') is not None else '')
|
|
463
|
+
|
|
464
|
+
Connect_Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
# Accept contact request.
|
|
468
|
+
# Network usage: interactive.
|
|
469
|
+
class APIAcceptContact(TypedDict):
|
|
470
|
+
contactReqId: int # int64
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def APIAcceptContact_cmd_string(self: APIAcceptContact) -> str:
|
|
474
|
+
return '/_accept ' + str(self['contactReqId'])
|
|
475
|
+
|
|
476
|
+
APIAcceptContact_Response = CR.AcceptingContactRequest | CR.ChatCmdError
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
# Reject contact request. The user who sent the request is **not notified**.
|
|
480
|
+
# Network usage: no.
|
|
481
|
+
class APIRejectContact(TypedDict):
|
|
482
|
+
contactReqId: int # int64
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def APIRejectContact_cmd_string(self: APIRejectContact) -> str:
|
|
486
|
+
return '/_reject ' + str(self['contactReqId'])
|
|
487
|
+
|
|
488
|
+
APIRejectContact_Response = CR.ContactRequestRejected | CR.ChatCmdError
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
# Chat commands
|
|
492
|
+
# Commands to list and delete conversations.
|
|
493
|
+
|
|
494
|
+
# Get contacts.
|
|
495
|
+
# Network usage: no.
|
|
496
|
+
class APIListContacts(TypedDict):
|
|
497
|
+
userId: int # int64
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
def APIListContacts_cmd_string(self: APIListContacts) -> str:
|
|
501
|
+
return '/_contacts ' + str(self['userId'])
|
|
502
|
+
|
|
503
|
+
APIListContacts_Response = CR.ContactsList | CR.ChatCmdError
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
# Get groups.
|
|
507
|
+
# Network usage: no.
|
|
508
|
+
class APIListGroups(TypedDict):
|
|
509
|
+
userId: int # int64
|
|
510
|
+
contactId_: NotRequired[int] # int64
|
|
511
|
+
search: NotRequired[str]
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def APIListGroups_cmd_string(self: APIListGroups) -> str:
|
|
515
|
+
return '/_groups ' + str(self['userId']) + ((' @' + str(self.get('contactId_'))) if self.get('contactId_') is not None else '') + ((' ' + self.get('search')) if self.get('search') is not None else '')
|
|
516
|
+
|
|
517
|
+
APIListGroups_Response = CR.GroupsList | CR.ChatCmdError
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
# Get chat previews. Supports time-based pagination — use this instead of APIListContacts / APIListGroups when scanning at scale (those load every record into memory and fail on large databases).
|
|
521
|
+
# Network usage: no.
|
|
522
|
+
class APIGetChats(TypedDict):
|
|
523
|
+
userId: int # int64
|
|
524
|
+
pendingConnections: bool
|
|
525
|
+
pagination: "T.PaginationByTime"
|
|
526
|
+
query: "T.ChatListQuery"
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def APIGetChats_cmd_string(self: APIGetChats) -> str:
|
|
530
|
+
return '/_get chats ' + str(self['userId']) + (' pcc=on' if self['pendingConnections'] else '') + ' ' + T.PaginationByTime_cmd_string(self['pagination']) + ' ' + json.dumps(self['query'])
|
|
531
|
+
|
|
532
|
+
APIGetChats_Response = CR.ApiChats | CR.ChatCmdError
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
# Delete chat.
|
|
536
|
+
# Network usage: background.
|
|
537
|
+
class APIDeleteChat(TypedDict):
|
|
538
|
+
chatRef: "T.ChatRef"
|
|
539
|
+
chatDeleteMode: "T.ChatDeleteMode"
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def APIDeleteChat_cmd_string(self: APIDeleteChat) -> str:
|
|
543
|
+
return '/_delete ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + T.ChatDeleteMode_cmd_string(self['chatDeleteMode'])
|
|
544
|
+
|
|
545
|
+
APIDeleteChat_Response = CR.ContactDeleted | CR.ContactConnectionDeleted | CR.GroupDeletedUser | CR.ChatCmdError
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
# Set group custom data.
|
|
549
|
+
# Network usage: no.
|
|
550
|
+
class APISetGroupCustomData(TypedDict):
|
|
551
|
+
groupId: int # int64
|
|
552
|
+
customData: NotRequired[dict[str, object]]
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def APISetGroupCustomData_cmd_string(self: APISetGroupCustomData) -> str:
|
|
556
|
+
return '/_set custom #' + str(self['groupId']) + ((' ' + json.dumps(self.get('customData'))) if self.get('customData') is not None else '')
|
|
557
|
+
|
|
558
|
+
APISetGroupCustomData_Response = CR.CmdOk | CR.ChatCmdError
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
# Set contact custom data.
|
|
562
|
+
# Network usage: no.
|
|
563
|
+
class APISetContactCustomData(TypedDict):
|
|
564
|
+
contactId: int # int64
|
|
565
|
+
customData: NotRequired[dict[str, object]]
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
def APISetContactCustomData_cmd_string(self: APISetContactCustomData) -> str:
|
|
569
|
+
return '/_set custom @' + str(self['contactId']) + ((' ' + json.dumps(self.get('customData'))) if self.get('customData') is not None else '')
|
|
570
|
+
|
|
571
|
+
APISetContactCustomData_Response = CR.CmdOk | CR.ChatCmdError
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
# Set auto-accept member contacts.
|
|
575
|
+
# Network usage: no.
|
|
576
|
+
class APISetUserAutoAcceptMemberContacts(TypedDict):
|
|
577
|
+
userId: int # int64
|
|
578
|
+
onOff: bool
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def APISetUserAutoAcceptMemberContacts_cmd_string(self: APISetUserAutoAcceptMemberContacts) -> str:
|
|
582
|
+
return '/_set accept member contacts ' + str(self['userId']) + ' ' + ('on' if self['onOff'] else 'off')
|
|
583
|
+
|
|
584
|
+
APISetUserAutoAcceptMemberContacts_Response = CR.CmdOk | CR.ChatCmdError
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
# User profile commands
|
|
588
|
+
# Most bots don't need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).
|
|
589
|
+
|
|
590
|
+
# Get active user profile.
|
|
591
|
+
# Network usage: no.
|
|
592
|
+
class ShowActiveUser(TypedDict):
|
|
593
|
+
pass
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def ShowActiveUser_cmd_string(self: ShowActiveUser) -> str:
|
|
597
|
+
return '/user'
|
|
598
|
+
|
|
599
|
+
ShowActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
# Create new user profile.
|
|
603
|
+
# Network usage: no.
|
|
604
|
+
class CreateActiveUser(TypedDict):
|
|
605
|
+
newUser: "T.NewUser"
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
def CreateActiveUser_cmd_string(self: CreateActiveUser) -> str:
|
|
609
|
+
return '/_create user ' + json.dumps(self['newUser'])
|
|
610
|
+
|
|
611
|
+
CreateActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
# Get all user profiles.
|
|
615
|
+
# Network usage: no.
|
|
616
|
+
class ListUsers(TypedDict):
|
|
617
|
+
pass
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def ListUsers_cmd_string(self: ListUsers) -> str:
|
|
621
|
+
return '/users'
|
|
622
|
+
|
|
623
|
+
ListUsers_Response = CR.UsersList | CR.ChatCmdError
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
# Set active user profile.
|
|
627
|
+
# Network usage: no.
|
|
628
|
+
class APISetActiveUser(TypedDict):
|
|
629
|
+
userId: int # int64
|
|
630
|
+
viewPwd: NotRequired[str]
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
def APISetActiveUser_cmd_string(self: APISetActiveUser) -> str:
|
|
634
|
+
return '/_user ' + str(self['userId']) + ((' ' + json.dumps(self.get('viewPwd'))) if self.get('viewPwd') is not None else '')
|
|
635
|
+
|
|
636
|
+
APISetActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
# Delete user profile.
|
|
640
|
+
# Network usage: background.
|
|
641
|
+
class APIDeleteUser(TypedDict):
|
|
642
|
+
userId: int # int64
|
|
643
|
+
delSMPQueues: bool
|
|
644
|
+
viewPwd: NotRequired[str]
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
def APIDeleteUser_cmd_string(self: APIDeleteUser) -> str:
|
|
648
|
+
return '/_delete user ' + str(self['userId']) + ' del_smp=' + ('on' if self['delSMPQueues'] else 'off') + ((' ' + json.dumps(self.get('viewPwd'))) if self.get('viewPwd') is not None else '')
|
|
649
|
+
|
|
650
|
+
APIDeleteUser_Response = CR.CmdOk | CR.ChatCmdError
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
# Update user profile.
|
|
654
|
+
# Network usage: background.
|
|
655
|
+
class APIUpdateProfile(TypedDict):
|
|
656
|
+
userId: int # int64
|
|
657
|
+
profile: "T.Profile"
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def APIUpdateProfile_cmd_string(self: APIUpdateProfile) -> str:
|
|
661
|
+
return '/_profile ' + str(self['userId']) + ' ' + json.dumps(self['profile'])
|
|
662
|
+
|
|
663
|
+
APIUpdateProfile_Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
# Configure chat preference overrides for the contact.
|
|
667
|
+
# Network usage: background.
|
|
668
|
+
class APISetContactPrefs(TypedDict):
|
|
669
|
+
contactId: int # int64
|
|
670
|
+
preferences: "T.Preferences"
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def APISetContactPrefs_cmd_string(self: APISetContactPrefs) -> str:
|
|
674
|
+
return '/_set prefs @' + str(self['contactId']) + ' ' + json.dumps(self['preferences'])
|
|
675
|
+
|
|
676
|
+
APISetContactPrefs_Response = CR.ContactPrefsUpdated | CR.ChatCmdError
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
# Chat management
|
|
680
|
+
# These commands should not be used with CLI-based bots
|
|
681
|
+
|
|
682
|
+
# Start chat controller.
|
|
683
|
+
# Network usage: no.
|
|
684
|
+
class StartChat(TypedDict):
|
|
685
|
+
mainApp: bool
|
|
686
|
+
enableSndFiles: bool
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
def StartChat_cmd_string(self: StartChat) -> str:
|
|
690
|
+
return '/_start'
|
|
691
|
+
|
|
692
|
+
StartChat_Response = CR.ChatStarted | CR.ChatRunning
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
# Stop chat controller.
|
|
696
|
+
# Network usage: no.
|
|
697
|
+
class APIStopChat(TypedDict):
|
|
698
|
+
pass
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
def APIStopChat_cmd_string(self: APIStopChat) -> str:
|
|
702
|
+
return '/_stop'
|
|
703
|
+
|
|
704
|
+
APIStopChat_Response = CR.ChatStopped
|
|
705
|
+
|