@theophilusdev/conduit 1.0.2 → 1.1.2
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.
- package/README.md +5 -3
- package/docs/DOCS.md +47 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,12 +72,14 @@ Handlers receive a context object and an optional `next()` function for middlewa
|
|
|
72
72
|
|
|
73
73
|
All events include:
|
|
74
74
|
|
|
75
|
-
- `send(body)`
|
|
75
|
+
- `send(body)` — send a message to the same thread
|
|
76
76
|
|
|
77
77
|
Message events additionally include:
|
|
78
78
|
|
|
79
|
-
- `reply(body)`
|
|
80
|
-
- `react(emoji)`
|
|
79
|
+
- `reply(body)` — quoted reply to the triggering message
|
|
80
|
+
- `react(emoji)` — react to the triggering message
|
|
81
|
+
|
|
82
|
+
Both `send()` and `reply()` accept a plain string or a `ConduitMessageBody` object for rich messages with attachments and mentions.
|
|
81
83
|
|
|
82
84
|
### Message Events
|
|
83
85
|
|
package/docs/DOCS.md
CHANGED
|
@@ -78,7 +78,7 @@ client.onFca(event: string, ...middlewares): this
|
|
|
78
78
|
|
|
79
79
|
### `.api`
|
|
80
80
|
|
|
81
|
-
Direct access to the raw FCA API.
|
|
81
|
+
Direct access to the raw FCA API. No type safety — use as a last resort.
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
84
|
client.api.getThreadList(10, null, ["INBOX"]);
|
|
@@ -100,20 +100,38 @@ Handles message-level operations.
|
|
|
100
100
|
|
|
101
101
|
### `.send(body, threadID)`
|
|
102
102
|
|
|
103
|
-
Sends a
|
|
103
|
+
Sends a message to a thread. Accepts a plain string or a `ConduitMessageBody` for rich messages.
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
await client.messages.send("hello", threadID);
|
|
107
|
+
|
|
108
|
+
await client.messages.send(
|
|
109
|
+
{
|
|
110
|
+
body: "hey @user",
|
|
111
|
+
mentions: [{ tag: "@user", id: "uid", fromIndex: 4 }],
|
|
112
|
+
attachment: [stream],
|
|
113
|
+
},
|
|
114
|
+
threadID,
|
|
115
|
+
);
|
|
107
116
|
```
|
|
108
117
|
|
|
109
118
|
---
|
|
110
119
|
|
|
111
120
|
### `.reply(body, threadID, messageID)`
|
|
112
121
|
|
|
113
|
-
Sends a reply to a specific message.
|
|
122
|
+
Sends a quoted reply to a specific message. Accepts a plain string or a `ConduitMessageBody`.
|
|
114
123
|
|
|
115
124
|
```ts
|
|
116
125
|
await client.messages.reply("got it", threadID, messageID);
|
|
126
|
+
|
|
127
|
+
await client.messages.reply(
|
|
128
|
+
{
|
|
129
|
+
body: "got it",
|
|
130
|
+
attachment: [stream],
|
|
131
|
+
},
|
|
132
|
+
threadID,
|
|
133
|
+
messageID,
|
|
134
|
+
);
|
|
117
135
|
```
|
|
118
136
|
|
|
119
137
|
---
|
|
@@ -395,11 +413,11 @@ await client.threads.delete(threadID);
|
|
|
395
413
|
|
|
396
414
|
### `.mute(threadID, muteUntil)`
|
|
397
415
|
|
|
398
|
-
Mutes or unmutes a thread.
|
|
416
|
+
Mutes or unmutes a thread. Pass `-1` to mute indefinitely, `0` to unmute.
|
|
399
417
|
|
|
400
418
|
```ts
|
|
401
|
-
await client.threads.mute(threadID, -1);
|
|
402
|
-
await client.threads.mute(threadID, 0);
|
|
419
|
+
await client.threads.mute(threadID, -1); // mute forever
|
|
420
|
+
await client.threads.mute(threadID, 0); // unmute
|
|
403
421
|
```
|
|
404
422
|
|
|
405
423
|
---
|
|
@@ -426,7 +444,7 @@ client.users;
|
|
|
426
444
|
|
|
427
445
|
### `.getInfo(userID)`
|
|
428
446
|
|
|
429
|
-
Fetches user info.
|
|
447
|
+
Fetches user info. Accepts a single ID or an array.
|
|
430
448
|
|
|
431
449
|
```ts
|
|
432
450
|
const user = await client.users.getInfo("uid");
|
|
@@ -437,7 +455,7 @@ const users = await client.users.getInfo(["uid1", "uid2"]);
|
|
|
437
455
|
|
|
438
456
|
### `.getID(vanity)`
|
|
439
457
|
|
|
440
|
-
Resolves username to ID.
|
|
458
|
+
Resolves a vanity username to a Facebook user ID.
|
|
441
459
|
|
|
442
460
|
```ts
|
|
443
461
|
const id = await client.users.getID("zuck");
|
|
@@ -447,7 +465,7 @@ const id = await client.users.getID("zuck");
|
|
|
447
465
|
|
|
448
466
|
### `.getFriendsList()`
|
|
449
467
|
|
|
450
|
-
Returns friends list.
|
|
468
|
+
Returns the authenticated user's friends list.
|
|
451
469
|
|
|
452
470
|
```ts
|
|
453
471
|
const friends = await client.users.getFriendsList();
|
|
@@ -467,7 +485,7 @@ client.account;
|
|
|
467
485
|
|
|
468
486
|
### `.getCurrentUserID()`
|
|
469
487
|
|
|
470
|
-
Returns current user ID.
|
|
488
|
+
Returns current user ID. Synchronous.
|
|
471
489
|
|
|
472
490
|
```ts
|
|
473
491
|
const myID = client.account.getCurrentUserID();
|
|
@@ -480,14 +498,15 @@ const myID = client.account.getCurrentUserID();
|
|
|
480
498
|
Blocks or unblocks a user.
|
|
481
499
|
|
|
482
500
|
```ts
|
|
483
|
-
await client.account.blockUser(userID, true);
|
|
501
|
+
await client.account.blockUser(userID, true); // block
|
|
502
|
+
await client.account.blockUser(userID, false); // unblock
|
|
484
503
|
```
|
|
485
504
|
|
|
486
505
|
---
|
|
487
506
|
|
|
488
507
|
### `.handleFriendRequest(userID, accept)`
|
|
489
508
|
|
|
490
|
-
|
|
509
|
+
Accepts or declines a friend request.
|
|
491
510
|
|
|
492
511
|
```ts
|
|
493
512
|
await client.account.handleFriendRequest(userID, true);
|
|
@@ -497,7 +516,7 @@ await client.account.handleFriendRequest(userID, true);
|
|
|
497
516
|
|
|
498
517
|
### `.unfriend(userID)`
|
|
499
518
|
|
|
500
|
-
Removes a
|
|
519
|
+
Removes a user from the friends list.
|
|
501
520
|
|
|
502
521
|
```ts
|
|
503
522
|
await client.account.unfriend(userID);
|
|
@@ -507,7 +526,7 @@ await client.account.unfriend(userID);
|
|
|
507
526
|
|
|
508
527
|
### `.logout()`
|
|
509
528
|
|
|
510
|
-
|
|
529
|
+
Ends the session and invalidates cookies.
|
|
511
530
|
|
|
512
531
|
```ts
|
|
513
532
|
await client.account.logout();
|
|
@@ -532,6 +551,20 @@ interface ConduitCredentials {
|
|
|
532
551
|
|
|
533
552
|
---
|
|
534
553
|
|
|
554
|
+
### `ConduitMessageBody`
|
|
555
|
+
|
|
556
|
+
Used by `send()` and `reply()` for rich messages with attachments and mentions.
|
|
557
|
+
|
|
558
|
+
```ts
|
|
559
|
+
interface ConduitMessageBody {
|
|
560
|
+
body?: string;
|
|
561
|
+
mentions?: { tag: string; id: string; fromIndex: number }[];
|
|
562
|
+
attachment?: any[];
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
535
568
|
### `Message`
|
|
536
569
|
|
|
537
570
|
```ts
|