simplex-chat 6.5.0-beta.4.1 → 6.5.0-beta.4.3

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.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/binding.gyp +19 -4
  3. package/cpp/simplex.cc +426 -0
  4. package/cpp/simplex.h +46 -0
  5. package/dist/index.d.ts +17 -2
  6. package/dist/index.js +18 -3
  7. package/dist/index.js.map +1 -1
  8. package/docs/Namespace.api.md +32 -0
  9. package/docs/Namespace.bot.md +20 -0
  10. package/docs/Namespace.core.md +48 -0
  11. package/docs/Namespace.util.md +25 -0
  12. package/docs/README.md +12 -0
  13. package/docs/api.Class.ChatApi.md +1602 -0
  14. package/docs/api.Class.ChatCommandError.md +205 -0
  15. package/docs/api.Enumeration.ConnReqType.md +27 -0
  16. package/docs/api.Interface.BotAddressSettings.md +60 -0
  17. package/docs/api.TypeAlias.EventSubscriberFunc.md +27 -0
  18. package/docs/api.TypeAlias.EventSubscribers.md +11 -0
  19. package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
  20. package/docs/bot.Function.run.md +21 -0
  21. package/docs/bot.Interface.BotConfig.md +75 -0
  22. package/docs/bot.Interface.BotDbOpts.md +33 -0
  23. package/docs/bot.Interface.BotOptions.md +81 -0
  24. package/docs/core.Class.ChatAPIError.md +205 -0
  25. package/docs/core.Class.ChatInitError.md +205 -0
  26. package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
  27. package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
  28. package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
  29. package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
  30. package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
  31. package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
  32. package/docs/core.Function.chatCloseStore.md +23 -0
  33. package/docs/core.Function.chatDecryptFile.md +31 -0
  34. package/docs/core.Function.chatEncryptFile.md +31 -0
  35. package/docs/core.Function.chatMigrateInit.md +31 -0
  36. package/docs/core.Function.chatReadFile.md +27 -0
  37. package/docs/core.Function.chatRecvMsgWait.md +27 -0
  38. package/docs/core.Function.chatSendCmd.md +27 -0
  39. package/docs/core.Function.chatWriteFile.md +31 -0
  40. package/docs/core.Interface.APIResult.md +31 -0
  41. package/docs/core.Interface.CryptoArgs.md +27 -0
  42. package/docs/core.Interface.UpMigration.md +25 -0
  43. package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
  44. package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
  45. package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
  46. package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
  47. package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
  48. package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
  49. package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
  50. package/docs/core.Namespace.DBMigrationError.md +18 -0
  51. package/docs/core.Namespace.MTRError.md +16 -0
  52. package/docs/core.Namespace.MigrationError.md +17 -0
  53. package/docs/core.TypeAlias.DBMigrationError.md +11 -0
  54. package/docs/core.TypeAlias.MTRError.md +11 -0
  55. package/docs/core.TypeAlias.MigrationError.md +11 -0
  56. package/docs/util.Function.botAddressSettings.md +21 -0
  57. package/docs/util.Function.chatInfoName.md +21 -0
  58. package/docs/util.Function.chatInfoRef.md +21 -0
  59. package/docs/util.Function.ciBotCommand.md +21 -0
  60. package/docs/util.Function.ciContentText.md +21 -0
  61. package/docs/util.Function.contactAddressStr.md +21 -0
  62. package/docs/util.Function.fromLocalProfile.md +21 -0
  63. package/docs/util.Function.reactionText.md +21 -0
  64. package/docs/util.Function.senderName.md +25 -0
  65. package/docs/util.Interface.BotCommand.md +25 -0
  66. package/examples/squaring-bot-readme.js +17 -0
  67. package/examples/squaring-bot.ts +42 -0
  68. package/package.json +7 -3
  69. package/tsconfig.json +23 -0
@@ -0,0 +1,1602 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / ChatApi
6
+
7
+ # Class: ChatApi
8
+
9
+ Defined in: [src/api.ts:62](../src/api.ts#L62)
10
+
11
+ Main API class for interacting with the chat core library.
12
+
13
+ ## Properties
14
+
15
+ ### ctrl\_
16
+
17
+ > `protected` **ctrl\_**: `bigint` \| `undefined`
18
+
19
+ Defined in: [src/api.ts:68](../src/api.ts#L68)
20
+
21
+ ## Accessors
22
+
23
+ ### ctrl
24
+
25
+ #### Get Signature
26
+
27
+ > **get** **ctrl**(): `bigint`
28
+
29
+ Defined in: [src/api.ts:295](../src/api.ts#L295)
30
+
31
+ Chat controller reference
32
+
33
+ ##### Returns
34
+
35
+ `bigint`
36
+
37
+ ***
38
+
39
+ ### initialized
40
+
41
+ #### Get Signature
42
+
43
+ > **get** **initialized**(): `boolean`
44
+
45
+ Defined in: [src/api.ts:281](../src/api.ts#L281)
46
+
47
+ Chat controller is initialized
48
+
49
+ ##### Returns
50
+
51
+ `boolean`
52
+
53
+ ***
54
+
55
+ ### started
56
+
57
+ #### Get Signature
58
+
59
+ > **get** **started**(): `boolean`
60
+
61
+ Defined in: [src/api.ts:288](../src/api.ts#L288)
62
+
63
+ Chat controller is started
64
+
65
+ ##### Returns
66
+
67
+ `boolean`
68
+
69
+ ## Methods
70
+
71
+ ### apiAcceptContactRequest()
72
+
73
+ > **apiAcceptContactRequest**(`contactReqId`): `Promise`\<`Contact`\>
74
+
75
+ Defined in: [src/api.ts:697](../src/api.ts#L697)
76
+
77
+ Accept contact request.
78
+ Network usage: interactive.
79
+
80
+ #### Parameters
81
+
82
+ ##### contactReqId
83
+
84
+ `number`
85
+
86
+ #### Returns
87
+
88
+ `Promise`\<`Contact`\>
89
+
90
+ ***
91
+
92
+ ### apiAcceptMember()
93
+
94
+ > **apiAcceptMember**(`groupId`, `groupMemberId`, `memberRole`): `Promise`\<`GroupMember`\>
95
+
96
+ Defined in: [src/api.ts:517](../src/api.ts#L517)
97
+
98
+ Accept group member. Requires Admin role.
99
+ Network usage: background.
100
+
101
+ #### Parameters
102
+
103
+ ##### groupId
104
+
105
+ `number`
106
+
107
+ ##### groupMemberId
108
+
109
+ `number`
110
+
111
+ ##### memberRole
112
+
113
+ `GroupMemberRole`
114
+
115
+ #### Returns
116
+
117
+ `Promise`\<`GroupMember`\>
118
+
119
+ ***
120
+
121
+ ### apiAddMember()
122
+
123
+ > **apiAddMember**(`groupId`, `contactId`, `memberRole`): `Promise`\<`GroupMember`\>
124
+
125
+ Defined in: [src/api.ts:497](../src/api.ts#L497)
126
+
127
+ Add contact to group. Requires bot to have Admin role.
128
+ Network usage: interactive.
129
+
130
+ #### Parameters
131
+
132
+ ##### groupId
133
+
134
+ `number`
135
+
136
+ ##### contactId
137
+
138
+ `number`
139
+
140
+ ##### memberRole
141
+
142
+ `GroupMemberRole`
143
+
144
+ #### Returns
145
+
146
+ `Promise`\<`GroupMember`\>
147
+
148
+ ***
149
+
150
+ ### apiBlockMembersForAll()
151
+
152
+ > **apiBlockMembersForAll**(`groupId`, `groupMemberIds`, `blocked`): `Promise`\<`void`\>
153
+
154
+ Defined in: [src/api.ts:537](../src/api.ts#L537)
155
+
156
+ Block members. Requires Moderator role.
157
+ Network usage: background.
158
+
159
+ #### Parameters
160
+
161
+ ##### groupId
162
+
163
+ `number`
164
+
165
+ ##### groupMemberIds
166
+
167
+ `number`[]
168
+
169
+ ##### blocked
170
+
171
+ `boolean`
172
+
173
+ #### Returns
174
+
175
+ `Promise`\<`void`\>
176
+
177
+ ***
178
+
179
+ ### apiCancelFile()
180
+
181
+ > **apiCancelFile**(`fileId`): `Promise`\<`void`\>
182
+
183
+ Defined in: [src/api.ts:487](../src/api.ts#L487)
184
+
185
+ Cancel file.
186
+ Network usage: background.
187
+
188
+ #### Parameters
189
+
190
+ ##### fileId
191
+
192
+ `number`
193
+
194
+ #### Returns
195
+
196
+ `Promise`\<`void`\>
197
+
198
+ ***
199
+
200
+ ### apiChatItemReaction()
201
+
202
+ > **apiChatItemReaction**(`chatType`, `chatId`, `chatItemId`, `add`, `reaction`): `Promise`\<`ChatItemDeletion`[]\>
203
+
204
+ Defined in: [src/api.ts:461](../src/api.ts#L461)
205
+
206
+ Add/remove message reaction.
207
+ Network usage: background.
208
+
209
+ #### Parameters
210
+
211
+ ##### chatType
212
+
213
+ `ChatType`
214
+
215
+ ##### chatId
216
+
217
+ `number`
218
+
219
+ ##### chatItemId
220
+
221
+ `number`
222
+
223
+ ##### add
224
+
225
+ `boolean`
226
+
227
+ ##### reaction
228
+
229
+ `MsgReaction`
230
+
231
+ #### Returns
232
+
233
+ `Promise`\<`ChatItemDeletion`[]\>
234
+
235
+ ***
236
+
237
+ ### apiConnect()
238
+
239
+ > **apiConnect**(`userId`, `incognito`, `preparedLink?`): `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
240
+
241
+ Defined in: [src/api.ts:666](../src/api.ts#L666)
242
+
243
+ Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link
244
+ Network usage: interactive.
245
+
246
+ #### Parameters
247
+
248
+ ##### userId
249
+
250
+ `number`
251
+
252
+ ##### incognito
253
+
254
+ `boolean`
255
+
256
+ ##### preparedLink?
257
+
258
+ `CreatedConnLink`
259
+
260
+ #### Returns
261
+
262
+ `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
263
+
264
+ ***
265
+
266
+ ### apiConnectActiveUser()
267
+
268
+ > **apiConnectActiveUser**(`connLink`): `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
269
+
270
+ Defined in: [src/api.ts:675](../src/api.ts#L675)
271
+
272
+ Connect via SimpleX link as string in the active user profile.
273
+ Network usage: interactive.
274
+
275
+ #### Parameters
276
+
277
+ ##### connLink
278
+
279
+ `string`
280
+
281
+ #### Returns
282
+
283
+ `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
284
+
285
+ ***
286
+
287
+ ### apiConnectPlan()
288
+
289
+ > **apiConnectPlan**(`userId`, `connectionLink`): `Promise`\<\[`ConnectionPlan`, `CreatedConnLink`\]\>
290
+
291
+ Defined in: [src/api.ts:656](../src/api.ts#L656)
292
+
293
+ Determine SimpleX link type and if the bot is already connected via this link.
294
+ Network usage: interactive.
295
+
296
+ #### Parameters
297
+
298
+ ##### userId
299
+
300
+ `number`
301
+
302
+ ##### connectionLink
303
+
304
+ `string`
305
+
306
+ #### Returns
307
+
308
+ `Promise`\<\[`ConnectionPlan`, `CreatedConnLink`\]\>
309
+
310
+ ***
311
+
312
+ ### apiCreateActiveUser()
313
+
314
+ > **apiCreateActiveUser**(`profile?`): `Promise`\<`User`\>
315
+
316
+ Defined in: [src/api.ts:774](../src/api.ts#L774)
317
+
318
+ Create new user profile
319
+ Network usage: no.
320
+
321
+ #### Parameters
322
+
323
+ ##### profile?
324
+
325
+ `Profile`
326
+
327
+ #### Returns
328
+
329
+ `Promise`\<`User`\>
330
+
331
+ ***
332
+
333
+ ### apiCreateGroupLink()
334
+
335
+ > **apiCreateGroupLink**(`groupId`, `memberRole`): `Promise`\<`string`\>
336
+
337
+ Defined in: [src/api.ts:597](../src/api.ts#L597)
338
+
339
+ Create group link.
340
+ Network usage: interactive.
341
+
342
+ #### Parameters
343
+
344
+ ##### groupId
345
+
346
+ `number`
347
+
348
+ ##### memberRole
349
+
350
+ `GroupMemberRole`
351
+
352
+ #### Returns
353
+
354
+ `Promise`\<`string`\>
355
+
356
+ ***
357
+
358
+ ### apiCreateLink()
359
+
360
+ > **apiCreateLink**(`userId`): `Promise`\<`string`\>
361
+
362
+ Defined in: [src/api.ts:643](../src/api.ts#L643)
363
+
364
+ Create 1-time invitation link.
365
+ Network usage: interactive.
366
+
367
+ #### Parameters
368
+
369
+ ##### userId
370
+
371
+ `number`
372
+
373
+ #### Returns
374
+
375
+ `Promise`\<`string`\>
376
+
377
+ ***
378
+
379
+ ### apiCreateUserAddress()
380
+
381
+ > **apiCreateUserAddress**(`userId`): `Promise`\<`CreatedConnLink`\>
382
+
383
+ Defined in: [src/api.ts:312](../src/api.ts#L312)
384
+
385
+ Create bot address.
386
+ Network usage: interactive.
387
+
388
+ #### Parameters
389
+
390
+ ##### userId
391
+
392
+ `number`
393
+
394
+ #### Returns
395
+
396
+ `Promise`\<`CreatedConnLink`\>
397
+
398
+ ***
399
+
400
+ ### apiDeleteChat()
401
+
402
+ > **apiDeleteChat**(`chatType`, `chatId`, `deleteMode`): `Promise`\<`void`\>
403
+
404
+ Defined in: [src/api.ts:737](../src/api.ts#L737)
405
+
406
+ Delete chat.
407
+ Network usage: background.
408
+
409
+ #### Parameters
410
+
411
+ ##### chatType
412
+
413
+ `ChatType`
414
+
415
+ ##### chatId
416
+
417
+ `number`
418
+
419
+ ##### deleteMode
420
+
421
+ `ChatDeleteMode` = `...`
422
+
423
+ #### Returns
424
+
425
+ `Promise`\<`void`\>
426
+
427
+ ***
428
+
429
+ ### apiDeleteChatItems()
430
+
431
+ > **apiDeleteChatItems**(`chatType`, `chatId`, `chatItemIds`, `deleteMode`): `Promise`\<`ChatItemDeletion`[]\>
432
+
433
+ Defined in: [src/api.ts:436](../src/api.ts#L436)
434
+
435
+ Delete message.
436
+ Network usage: background.
437
+
438
+ #### Parameters
439
+
440
+ ##### chatType
441
+
442
+ `ChatType`
443
+
444
+ ##### chatId
445
+
446
+ `number`
447
+
448
+ ##### chatItemIds
449
+
450
+ `number`[]
451
+
452
+ ##### deleteMode
453
+
454
+ `CIDeleteMode`
455
+
456
+ #### Returns
457
+
458
+ `Promise`\<`ChatItemDeletion`[]\>
459
+
460
+ ***
461
+
462
+ ### apiDeleteGroupLink()
463
+
464
+ > **apiDeleteGroupLink**(`groupId`): `Promise`\<`void`\>
465
+
466
+ Defined in: [src/api.ts:619](../src/api.ts#L619)
467
+
468
+ Delete group link.
469
+ Network usage: background.
470
+
471
+ #### Parameters
472
+
473
+ ##### groupId
474
+
475
+ `number`
476
+
477
+ #### Returns
478
+
479
+ `Promise`\<`void`\>
480
+
481
+ ***
482
+
483
+ ### apiDeleteMemberChatItem()
484
+
485
+ > **apiDeleteMemberChatItem**(`groupId`, `chatItemIds`): `Promise`\<`ChatItemDeletion`[]\>
486
+
487
+ Defined in: [src/api.ts:451](../src/api.ts#L451)
488
+
489
+ Moderate message. Requires Moderator role (and higher than message author's).
490
+ Network usage: background.
491
+
492
+ #### Parameters
493
+
494
+ ##### groupId
495
+
496
+ `number`
497
+
498
+ ##### chatItemIds
499
+
500
+ `number`[]
501
+
502
+ #### Returns
503
+
504
+ `Promise`\<`ChatItemDeletion`[]\>
505
+
506
+ ***
507
+
508
+ ### apiDeleteUser()
509
+
510
+ > **apiDeleteUser**(`userId`, `delSMPQueues`, `viewPwd?`): `Promise`\<`void`\>
511
+
512
+ Defined in: [src/api.ts:804](../src/api.ts#L804)
513
+
514
+ Delete user profile.
515
+ Network usage: background.
516
+
517
+ #### Parameters
518
+
519
+ ##### userId
520
+
521
+ `number`
522
+
523
+ ##### delSMPQueues
524
+
525
+ `boolean`
526
+
527
+ ##### viewPwd?
528
+
529
+ `string`
530
+
531
+ #### Returns
532
+
533
+ `Promise`\<`void`\>
534
+
535
+ ***
536
+
537
+ ### apiDeleteUserAddress()
538
+
539
+ > **apiDeleteUserAddress**(`userId`): `Promise`\<`void`\>
540
+
541
+ Defined in: [src/api.ts:322](../src/api.ts#L322)
542
+
543
+ Deletes a user address.
544
+ Network usage: background.
545
+
546
+ #### Parameters
547
+
548
+ ##### userId
549
+
550
+ `number`
551
+
552
+ #### Returns
553
+
554
+ `Promise`\<`void`\>
555
+
556
+ ***
557
+
558
+ ### apiGetActiveUser()
559
+
560
+ > **apiGetActiveUser**(): `Promise`\<`User` \| `undefined`\>
561
+
562
+ Defined in: [src/api.ts:754](../src/api.ts#L754)
563
+
564
+ Get active user profile
565
+ Network usage: no.
566
+
567
+ #### Returns
568
+
569
+ `Promise`\<`User` \| `undefined`\>
570
+
571
+ ***
572
+
573
+ ### apiGetGroupLink()
574
+
575
+ > **apiGetGroupLink**(`groupId`): `Promise`\<`GroupLink`\>
576
+
577
+ Defined in: [src/api.ts:628](../src/api.ts#L628)
578
+
579
+ Get group link.
580
+ Network usage: no.
581
+
582
+ #### Parameters
583
+
584
+ ##### groupId
585
+
586
+ `number`
587
+
588
+ #### Returns
589
+
590
+ `Promise`\<`GroupLink`\>
591
+
592
+ ***
593
+
594
+ ### apiGetGroupLinkStr()
595
+
596
+ > **apiGetGroupLinkStr**(`groupId`): `Promise`\<`string`\>
597
+
598
+ Defined in: [src/api.ts:634](../src/api.ts#L634)
599
+
600
+ #### Parameters
601
+
602
+ ##### groupId
603
+
604
+ `number`
605
+
606
+ #### Returns
607
+
608
+ `Promise`\<`string`\>
609
+
610
+ ***
611
+
612
+ ### apiGetUserAddress()
613
+
614
+ > **apiGetUserAddress**(`userId`): `Promise`\<`UserContactLink` \| `undefined`\>
615
+
616
+ Defined in: [src/api.ts:332](../src/api.ts#L332)
617
+
618
+ Get bot address and settings.
619
+ Network usage: no.
620
+
621
+ #### Parameters
622
+
623
+ ##### userId
624
+
625
+ `number`
626
+
627
+ #### Returns
628
+
629
+ `Promise`\<`UserContactLink` \| `undefined`\>
630
+
631
+ ***
632
+
633
+ ### apiJoinGroup()
634
+
635
+ > **apiJoinGroup**(`groupId`): `Promise`\<`GroupInfo`\>
636
+
637
+ Defined in: [src/api.ts:507](../src/api.ts#L507)
638
+
639
+ Join group.
640
+ Network usage: interactive.
641
+
642
+ #### Parameters
643
+
644
+ ##### groupId
645
+
646
+ `number`
647
+
648
+ #### Returns
649
+
650
+ `Promise`\<`GroupInfo`\>
651
+
652
+ ***
653
+
654
+ ### apiLeaveGroup()
655
+
656
+ > **apiLeaveGroup**(`groupId`): `Promise`\<`GroupInfo`\>
657
+
658
+ Defined in: [src/api.ts:557](../src/api.ts#L557)
659
+
660
+ Leave group.
661
+ Network usage: background.
662
+
663
+ #### Parameters
664
+
665
+ ##### groupId
666
+
667
+ `number`
668
+
669
+ #### Returns
670
+
671
+ `Promise`\<`GroupInfo`\>
672
+
673
+ ***
674
+
675
+ ### apiListContacts()
676
+
677
+ > **apiListContacts**(`userId`): `Promise`\<`Contact`[]\>
678
+
679
+ Defined in: [src/api.ts:717](../src/api.ts#L717)
680
+
681
+ Get contacts.
682
+ Network usage: no.
683
+
684
+ #### Parameters
685
+
686
+ ##### userId
687
+
688
+ `number`
689
+
690
+ #### Returns
691
+
692
+ `Promise`\<`Contact`[]\>
693
+
694
+ ***
695
+
696
+ ### apiListGroups()
697
+
698
+ > **apiListGroups**(`userId`, `contactId?`, `search?`): `Promise`\<`GroupInfo`[]\>
699
+
700
+ Defined in: [src/api.ts:727](../src/api.ts#L727)
701
+
702
+ Get groups.
703
+ Network usage: no.
704
+
705
+ #### Parameters
706
+
707
+ ##### userId
708
+
709
+ `number`
710
+
711
+ ##### contactId?
712
+
713
+ `number`
714
+
715
+ ##### search?
716
+
717
+ `string`
718
+
719
+ #### Returns
720
+
721
+ `Promise`\<`GroupInfo`[]\>
722
+
723
+ ***
724
+
725
+ ### apiListMembers()
726
+
727
+ > **apiListMembers**(`groupId`): `Promise`\<`GroupMember`[]\>
728
+
729
+ Defined in: [src/api.ts:567](../src/api.ts#L567)
730
+
731
+ Get group members.
732
+ Network usage: no.
733
+
734
+ #### Parameters
735
+
736
+ ##### groupId
737
+
738
+ `number`
739
+
740
+ #### Returns
741
+
742
+ `Promise`\<`GroupMember`[]\>
743
+
744
+ ***
745
+
746
+ ### apiListUsers()
747
+
748
+ > **apiListUsers**(): `Promise`\<`UserInfo`[]\>
749
+
750
+ Defined in: [src/api.ts:784](../src/api.ts#L784)
751
+
752
+ Get all user profiles
753
+ Network usage: no.
754
+
755
+ #### Returns
756
+
757
+ `Promise`\<`UserInfo`[]\>
758
+
759
+ ***
760
+
761
+ ### apiNewGroup()
762
+
763
+ > **apiNewGroup**(`userId`, `groupProfile`): `Promise`\<`GroupInfo`\>
764
+
765
+ Defined in: [src/api.ts:577](../src/api.ts#L577)
766
+
767
+ Create group.
768
+ Network usage: no.
769
+
770
+ #### Parameters
771
+
772
+ ##### userId
773
+
774
+ `number`
775
+
776
+ ##### groupProfile
777
+
778
+ `GroupProfile`
779
+
780
+ #### Returns
781
+
782
+ `Promise`\<`GroupInfo`\>
783
+
784
+ ***
785
+
786
+ ### apiReceiveFile()
787
+
788
+ > **apiReceiveFile**(`fileId`): `Promise`\<`AChatItem`\>
789
+
790
+ Defined in: [src/api.ts:477](../src/api.ts#L477)
791
+
792
+ Receive file.
793
+ Network usage: no.
794
+
795
+ #### Parameters
796
+
797
+ ##### fileId
798
+
799
+ `number`
800
+
801
+ #### Returns
802
+
803
+ `Promise`\<`AChatItem`\>
804
+
805
+ ***
806
+
807
+ ### apiRejectContactRequest()
808
+
809
+ > **apiRejectContactRequest**(`contactReqId`): `Promise`\<`void`\>
810
+
811
+ Defined in: [src/api.ts:707](../src/api.ts#L707)
812
+
813
+ Reject contact request. The user who sent the request is **not notified**.
814
+ Network usage: no.
815
+
816
+ #### Parameters
817
+
818
+ ##### contactReqId
819
+
820
+ `number`
821
+
822
+ #### Returns
823
+
824
+ `Promise`\<`void`\>
825
+
826
+ ***
827
+
828
+ ### apiRemoveMembers()
829
+
830
+ > **apiRemoveMembers**(`groupId`, `memberIds`, `withMessages`): `Promise`\<`GroupMember`[]\>
831
+
832
+ Defined in: [src/api.ts:547](../src/api.ts#L547)
833
+
834
+ Remove members. Requires Admin role.
835
+ Network usage: background.
836
+
837
+ #### Parameters
838
+
839
+ ##### groupId
840
+
841
+ `number`
842
+
843
+ ##### memberIds
844
+
845
+ `number`[]
846
+
847
+ ##### withMessages
848
+
849
+ `boolean` = `false`
850
+
851
+ #### Returns
852
+
853
+ `Promise`\<`GroupMember`[]\>
854
+
855
+ ***
856
+
857
+ ### apiSendMessages()
858
+
859
+ > **apiSendMessages**(`chat`, `messages`, `liveMessage`): `Promise`\<`AChatItem`[]\>
860
+
861
+ Defined in: [src/api.ts:381](../src/api.ts#L381)
862
+
863
+ Send messages.
864
+ Network usage: background.
865
+
866
+ #### Parameters
867
+
868
+ ##### chat
869
+
870
+ `ChatInfo` | `ChatRef` | \[`ChatType`, `number`\]
871
+
872
+ ##### messages
873
+
874
+ `ComposedMessage`[]
875
+
876
+ ##### liveMessage
877
+
878
+ `boolean` = `false`
879
+
880
+ #### Returns
881
+
882
+ `Promise`\<`AChatItem`[]\>
883
+
884
+ ***
885
+
886
+ ### apiSendTextMessage()
887
+
888
+ > **apiSendTextMessage**(`chat`, `text`, `inReplyTo?`): `Promise`\<`AChatItem`[]\>
889
+
890
+ Defined in: [src/api.ts:403](../src/api.ts#L403)
891
+
892
+ Send text message.
893
+ Network usage: background.
894
+
895
+ #### Parameters
896
+
897
+ ##### chat
898
+
899
+ `ChatInfo` | `ChatRef` | \[`ChatType`, `number`\]
900
+
901
+ ##### text
902
+
903
+ `string`
904
+
905
+ ##### inReplyTo?
906
+
907
+ `number`
908
+
909
+ #### Returns
910
+
911
+ `Promise`\<`AChatItem`[]\>
912
+
913
+ ***
914
+
915
+ ### apiSendTextReply()
916
+
917
+ > **apiSendTextReply**(`chatItem`, `text`): `Promise`\<`AChatItem`[]\>
918
+
919
+ Defined in: [src/api.ts:411](../src/api.ts#L411)
920
+
921
+ Send text message in reply to received message.
922
+ Network usage: background.
923
+
924
+ #### Parameters
925
+
926
+ ##### chatItem
927
+
928
+ `AChatItem`
929
+
930
+ ##### text
931
+
932
+ `string`
933
+
934
+ #### Returns
935
+
936
+ `Promise`\<`AChatItem`[]\>
937
+
938
+ ***
939
+
940
+ ### apiSetActiveUser()
941
+
942
+ > **apiSetActiveUser**(`userId`, `viewPwd?`): `Promise`\<`User`\>
943
+
944
+ Defined in: [src/api.ts:794](../src/api.ts#L794)
945
+
946
+ Set active user profile
947
+ Network usage: no.
948
+
949
+ #### Parameters
950
+
951
+ ##### userId
952
+
953
+ `number`
954
+
955
+ ##### viewPwd?
956
+
957
+ `string`
958
+
959
+ #### Returns
960
+
961
+ `Promise`\<`User`\>
962
+
963
+ ***
964
+
965
+ ### apiSetAddressSettings()
966
+
967
+ > **apiSetAddressSettings**(`userId`, `__namedParameters`): `Promise`\<`void`\>
968
+
969
+ Defined in: [src/api.ts:364](../src/api.ts#L364)
970
+
971
+ Set bot address settings.
972
+ Network usage: interactive.
973
+
974
+ #### Parameters
975
+
976
+ ##### userId
977
+
978
+ `number`
979
+
980
+ ##### \_\_namedParameters
981
+
982
+ [`BotAddressSettings`](api.Interface.BotAddressSettings.md)
983
+
984
+ #### Returns
985
+
986
+ `Promise`\<`void`\>
987
+
988
+ ***
989
+
990
+ ### apiSetContactPrefs()
991
+
992
+ > **apiSetContactPrefs**(`contactId`, `preferences`): `Promise`\<`void`\>
993
+
994
+ Defined in: [src/api.ts:830](../src/api.ts#L830)
995
+
996
+ Configure chat preference overrides for the contact.
997
+ Network usage: background.
998
+
999
+ #### Parameters
1000
+
1001
+ ##### contactId
1002
+
1003
+ `number`
1004
+
1005
+ ##### preferences
1006
+
1007
+ `Preferences`
1008
+
1009
+ #### Returns
1010
+
1011
+ `Promise`\<`void`\>
1012
+
1013
+ ***
1014
+
1015
+ ### apiSetGroupLinkMemberRole()
1016
+
1017
+ > **apiSetGroupLinkMemberRole**(`groupId`, `memberRole`): `Promise`\<`void`\>
1018
+
1019
+ Defined in: [src/api.ts:610](../src/api.ts#L610)
1020
+
1021
+ Set member role for group link.
1022
+ Network usage: no.
1023
+
1024
+ #### Parameters
1025
+
1026
+ ##### groupId
1027
+
1028
+ `number`
1029
+
1030
+ ##### memberRole
1031
+
1032
+ `GroupMemberRole`
1033
+
1034
+ #### Returns
1035
+
1036
+ `Promise`\<`void`\>
1037
+
1038
+ ***
1039
+
1040
+ ### apiSetMembersRole()
1041
+
1042
+ > **apiSetMembersRole**(`groupId`, `groupMemberIds`, `memberRole`): `Promise`\<`void`\>
1043
+
1044
+ Defined in: [src/api.ts:527](../src/api.ts#L527)
1045
+
1046
+ Set members role. Requires Admin role.
1047
+ Network usage: background.
1048
+
1049
+ #### Parameters
1050
+
1051
+ ##### groupId
1052
+
1053
+ `number`
1054
+
1055
+ ##### groupMemberIds
1056
+
1057
+ `number`[]
1058
+
1059
+ ##### memberRole
1060
+
1061
+ `GroupMemberRole`
1062
+
1063
+ #### Returns
1064
+
1065
+ `Promise`\<`void`\>
1066
+
1067
+ ***
1068
+
1069
+ ### apiSetProfileAddress()
1070
+
1071
+ > **apiSetProfileAddress**(`userId`, `enable`): `Promise`\<`UserProfileUpdateSummary`\>
1072
+
1073
+ Defined in: [src/api.ts:350](../src/api.ts#L350)
1074
+
1075
+ Add address to bot profile.
1076
+ Network usage: interactive.
1077
+
1078
+ #### Parameters
1079
+
1080
+ ##### userId
1081
+
1082
+ `number`
1083
+
1084
+ ##### enable
1085
+
1086
+ `boolean`
1087
+
1088
+ #### Returns
1089
+
1090
+ `Promise`\<`UserProfileUpdateSummary`\>
1091
+
1092
+ ***
1093
+
1094
+ ### apiUpdateChatItem()
1095
+
1096
+ > **apiUpdateChatItem**(`chatType`, `chatId`, `chatItemId`, `msgContent`, `liveMessage`): `Promise`\<`ChatItem`\>
1097
+
1098
+ Defined in: [src/api.ts:419](../src/api.ts#L419)
1099
+
1100
+ Update message.
1101
+ Network usage: background.
1102
+
1103
+ #### Parameters
1104
+
1105
+ ##### chatType
1106
+
1107
+ `ChatType`
1108
+
1109
+ ##### chatId
1110
+
1111
+ `number`
1112
+
1113
+ ##### chatItemId
1114
+
1115
+ `number`
1116
+
1117
+ ##### msgContent
1118
+
1119
+ `MsgContent`
1120
+
1121
+ ##### liveMessage
1122
+
1123
+ `false`
1124
+
1125
+ #### Returns
1126
+
1127
+ `Promise`\<`ChatItem`\>
1128
+
1129
+ ***
1130
+
1131
+ ### apiUpdateGroupProfile()
1132
+
1133
+ > **apiUpdateGroupProfile**(`groupId`, `groupProfile`): `Promise`\<`GroupInfo`\>
1134
+
1135
+ Defined in: [src/api.ts:587](../src/api.ts#L587)
1136
+
1137
+ Update group profile.
1138
+ Network usage: background.
1139
+
1140
+ #### Parameters
1141
+
1142
+ ##### groupId
1143
+
1144
+ `number`
1145
+
1146
+ ##### groupProfile
1147
+
1148
+ `GroupProfile`
1149
+
1150
+ #### Returns
1151
+
1152
+ `Promise`\<`GroupInfo`\>
1153
+
1154
+ ***
1155
+
1156
+ ### apiUpdateProfile()
1157
+
1158
+ > **apiUpdateProfile**(`userId`, `profile`): `Promise`\<`UserProfileUpdateSummary` \| `undefined`\>
1159
+
1160
+ Defined in: [src/api.ts:814](../src/api.ts#L814)
1161
+
1162
+ Update user profile.
1163
+ Network usage: background.
1164
+
1165
+ #### Parameters
1166
+
1167
+ ##### userId
1168
+
1169
+ `number`
1170
+
1171
+ ##### profile
1172
+
1173
+ `Profile`
1174
+
1175
+ #### Returns
1176
+
1177
+ `Promise`\<`UserProfileUpdateSummary` \| `undefined`\>
1178
+
1179
+ ***
1180
+
1181
+ ### close()
1182
+
1183
+ > **close**(): `Promise`\<`void`\>
1184
+
1185
+ Defined in: [src/api.ts:114](../src/api.ts#L114)
1186
+
1187
+ Close chat database.
1188
+ Usually doesn't need to be called in chat bots.
1189
+
1190
+ #### Returns
1191
+
1192
+ `Promise`\<`void`\>
1193
+
1194
+ ***
1195
+
1196
+ ### off()
1197
+
1198
+ > **off**\<`K`\>(`event`, `subscriber`): `void`
1199
+
1200
+ Defined in: [src/api.ts:253](../src/api.ts#L253)
1201
+
1202
+ Unsubscribe all or a specific handler from a specific event.
1203
+
1204
+ #### Type Parameters
1205
+
1206
+ ##### K
1207
+
1208
+ `K` *extends* `Tag`
1209
+
1210
+ #### Parameters
1211
+
1212
+ ##### event
1213
+
1214
+ `K`
1215
+
1216
+ The event type to unsubscribe from.
1217
+
1218
+ ##### subscriber
1219
+
1220
+ An optional subscriber function for the event.
1221
+
1222
+ [`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\> | `undefined`
1223
+
1224
+ #### Returns
1225
+
1226
+ `void`
1227
+
1228
+ ***
1229
+
1230
+ ### offAny()
1231
+
1232
+ > **offAny**(`receiver`): `void`
1233
+
1234
+ Defined in: [src/api.ts:269](../src/api.ts#L269)
1235
+
1236
+ Unsubscribe all or a specific handler from any events.
1237
+
1238
+ #### Parameters
1239
+
1240
+ ##### receiver
1241
+
1242
+ An optional subscriber function for the event.
1243
+
1244
+ [`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`Tag`\> | `undefined`
1245
+
1246
+ #### Returns
1247
+
1248
+ `void`
1249
+
1250
+ ***
1251
+
1252
+ ### on()
1253
+
1254
+ #### Call Signature
1255
+
1256
+ > **on**\<`K`\>(`subscribers`): `void`
1257
+
1258
+ Defined in: [src/api.ts:163](../src/api.ts#L163)
1259
+
1260
+ Subscribe multiple event handlers at once.
1261
+
1262
+ ##### Type Parameters
1263
+
1264
+ ###### K
1265
+
1266
+ `K` *extends* `Tag`
1267
+
1268
+ ##### Parameters
1269
+
1270
+ ###### subscribers
1271
+
1272
+ [`EventSubscribers`](api.TypeAlias.EventSubscribers.md)
1273
+
1274
+ An object mapping event types (CEvt.Tag) to their subscriber functions.
1275
+
1276
+ ##### Returns
1277
+
1278
+ `void`
1279
+
1280
+ ##### Throws
1281
+
1282
+ If the same function is subscribed to event.
1283
+
1284
+ #### Call Signature
1285
+
1286
+ > **on**\<`K`\>(`event`, `subscriber`): `void`
1287
+
1288
+ Defined in: [src/api.ts:171](../src/api.ts#L171)
1289
+
1290
+ Subscribe a handler to a specific event.
1291
+
1292
+ ##### Type Parameters
1293
+
1294
+ ###### K
1295
+
1296
+ `K` *extends* `Tag`
1297
+
1298
+ ##### Parameters
1299
+
1300
+ ###### event
1301
+
1302
+ `K`
1303
+
1304
+ The event type to subscribe to.
1305
+
1306
+ ###### subscriber
1307
+
1308
+ [`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\>
1309
+
1310
+ The subscriber function for the event.
1311
+
1312
+ ##### Returns
1313
+
1314
+ `void`
1315
+
1316
+ ##### Throws
1317
+
1318
+ If the same function is subscribed to event.
1319
+
1320
+ ***
1321
+
1322
+ ### onAny()
1323
+
1324
+ > **onAny**(`receiver`): `void`
1325
+
1326
+ Defined in: [src/api.ts:194](../src/api.ts#L194)
1327
+
1328
+ Subscribe a handler to any event.
1329
+
1330
+ #### Parameters
1331
+
1332
+ ##### receiver
1333
+
1334
+ [`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`Tag`\>
1335
+
1336
+ The receiver function for any event.
1337
+
1338
+ #### Returns
1339
+
1340
+ `void`
1341
+
1342
+ #### Throws
1343
+
1344
+ If the same function is subscribed to event.
1345
+
1346
+ ***
1347
+
1348
+ ### once()
1349
+
1350
+ > **once**\<`K`\>(`event`, `subscriber`): `void`
1351
+
1352
+ Defined in: [src/api.ts:205](../src/api.ts#L205)
1353
+
1354
+ Subscribe a handler to a specific event to be delivered one time.
1355
+
1356
+ #### Type Parameters
1357
+
1358
+ ##### K
1359
+
1360
+ `K` *extends* `Tag`
1361
+
1362
+ #### Parameters
1363
+
1364
+ ##### event
1365
+
1366
+ `K`
1367
+
1368
+ The event type to subscribe to.
1369
+
1370
+ ##### subscriber
1371
+
1372
+ [`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\>
1373
+
1374
+ The subscriber function for the event.
1375
+
1376
+ #### Returns
1377
+
1378
+ `void`
1379
+
1380
+ #### Throws
1381
+
1382
+ If the same function is subscribed to event.
1383
+
1384
+ ***
1385
+
1386
+ ### recvChatEvent()
1387
+
1388
+ > **recvChatEvent**(`wait`): `Promise`\<`ChatEvent` \| `undefined`\>
1389
+
1390
+ Defined in: [src/api.ts:304](../src/api.ts#L304)
1391
+
1392
+ #### Parameters
1393
+
1394
+ ##### wait
1395
+
1396
+ `number` = `5_000_000`
1397
+
1398
+ #### Returns
1399
+
1400
+ `Promise`\<`ChatEvent` \| `undefined`\>
1401
+
1402
+ ***
1403
+
1404
+ ### sendChatCmd()
1405
+
1406
+ > **sendChatCmd**(`cmd`): `Promise`\<`ChatResponse`\>
1407
+
1408
+ Defined in: [src/api.ts:300](../src/api.ts#L300)
1409
+
1410
+ #### Parameters
1411
+
1412
+ ##### cmd
1413
+
1414
+ `string`
1415
+
1416
+ #### Returns
1417
+
1418
+ `Promise`\<`ChatResponse`\>
1419
+
1420
+ ***
1421
+
1422
+ ### startChat()
1423
+
1424
+ > **startChat**(): `Promise`\<`void`\>
1425
+
1426
+ Defined in: [src/api.ts:88](../src/api.ts#L88)
1427
+
1428
+ Start chat controller. Must be called with the existing user profile.
1429
+
1430
+ #### Returns
1431
+
1432
+ `Promise`\<`void`\>
1433
+
1434
+ ***
1435
+
1436
+ ### stopChat()
1437
+
1438
+ > **stopChat**(): `Promise`\<`void`\>
1439
+
1440
+ Defined in: [src/api.ts:102](../src/api.ts#L102)
1441
+
1442
+ Stop chat controller.
1443
+ Must be called before closing the database.
1444
+ Usually doesn't need to be called in chat bots.
1445
+
1446
+ #### Returns
1447
+
1448
+ `Promise`\<`void`\>
1449
+
1450
+ ***
1451
+
1452
+ ### wait()
1453
+
1454
+ #### Call Signature
1455
+
1456
+ > **wait**\<`K`\>(`event`): `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
1457
+
1458
+ Defined in: [src/api.ts:213](../src/api.ts#L213)
1459
+
1460
+ Waits for specific event, with an optional predicate.
1461
+ Returns `undefined` on timeout if specified.
1462
+
1463
+ ##### Type Parameters
1464
+
1465
+ ###### K
1466
+
1467
+ `K` *extends* `Tag`
1468
+
1469
+ ##### Parameters
1470
+
1471
+ ###### event
1472
+
1473
+ `K`
1474
+
1475
+ ##### Returns
1476
+
1477
+ `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
1478
+
1479
+ #### Call Signature
1480
+
1481
+ > **wait**\<`K`\>(`event`, `predicate`): `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
1482
+
1483
+ Defined in: [src/api.ts:214](../src/api.ts#L214)
1484
+
1485
+ Waits for specific event, with an optional predicate.
1486
+ Returns `undefined` on timeout if specified.
1487
+
1488
+ ##### Type Parameters
1489
+
1490
+ ###### K
1491
+
1492
+ `K` *extends* `Tag`
1493
+
1494
+ ##### Parameters
1495
+
1496
+ ###### event
1497
+
1498
+ `K`
1499
+
1500
+ ###### predicate
1501
+
1502
+ (`event`) => `boolean` | `undefined`
1503
+
1504
+ ##### Returns
1505
+
1506
+ `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
1507
+
1508
+ #### Call Signature
1509
+
1510
+ > **wait**\<`K`\>(`event`, `timeout`): `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
1511
+
1512
+ Defined in: [src/api.ts:215](../src/api.ts#L215)
1513
+
1514
+ Waits for specific event, with an optional predicate.
1515
+ Returns `undefined` on timeout if specified.
1516
+
1517
+ ##### Type Parameters
1518
+
1519
+ ###### K
1520
+
1521
+ `K` *extends* `Tag`
1522
+
1523
+ ##### Parameters
1524
+
1525
+ ###### event
1526
+
1527
+ `K`
1528
+
1529
+ ###### timeout
1530
+
1531
+ `number`
1532
+
1533
+ ##### Returns
1534
+
1535
+ `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
1536
+
1537
+ #### Call Signature
1538
+
1539
+ > **wait**\<`K`\>(`event`, `predicate`, `timeout`): `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
1540
+
1541
+ Defined in: [src/api.ts:216](../src/api.ts#L216)
1542
+
1543
+ Waits for specific event, with an optional predicate.
1544
+ Returns `undefined` on timeout if specified.
1545
+
1546
+ ##### Type Parameters
1547
+
1548
+ ###### K
1549
+
1550
+ `K` *extends* `Tag`
1551
+
1552
+ ##### Parameters
1553
+
1554
+ ###### event
1555
+
1556
+ `K`
1557
+
1558
+ ###### predicate
1559
+
1560
+ (`event`) => `boolean` | `undefined`
1561
+
1562
+ ###### timeout
1563
+
1564
+ `number`
1565
+
1566
+ ##### Returns
1567
+
1568
+ `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
1569
+
1570
+ ***
1571
+
1572
+ ### init()
1573
+
1574
+ > `static` **init**(`dbFilePrefix`, `dbKey?`, `confirm?`): `Promise`\<`ChatApi`\>
1575
+
1576
+ Defined in: [src/api.ts:76](../src/api.ts#L76)
1577
+
1578
+ Initializes the ChatApi.
1579
+
1580
+ #### Parameters
1581
+
1582
+ ##### dbFilePrefix
1583
+
1584
+ `string`
1585
+
1586
+ File prefix for the database files.
1587
+
1588
+ ##### dbKey?
1589
+
1590
+ `string` = `""`
1591
+
1592
+ Database encryption key.
1593
+
1594
+ ##### confirm?
1595
+
1596
+ [`MigrationConfirmation`](core.Enumeration.MigrationConfirmation.md) = `core.MigrationConfirmation.YesUp`
1597
+
1598
+ Migration confirmation mode.
1599
+
1600
+ #### Returns
1601
+
1602
+ `Promise`\<`ChatApi`\>