@theophilusdev/conduit 1.0.1 → 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 +59 -38
- package/docs/DOCS.md +153 -94
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
> A lightweight TypeScript wrapper around [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial) with a clean, middleware-based event system.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
|
|
9
|
-
await conduit.login({ appstate });
|
|
8
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
const client = new ConduitClient({ listenEvents: true });
|
|
11
|
+
await client.login({ appstate });
|
|
12
|
+
|
|
13
|
+
client.on("message:create", async (ctx) => {
|
|
12
14
|
await ctx.reply(`hey, you said: ${ctx.body}`);
|
|
13
15
|
});
|
|
14
16
|
```
|
|
@@ -22,18 +24,19 @@ npm install @theophilusdev/conduit
|
|
|
22
24
|
## Quick Start
|
|
23
25
|
|
|
24
26
|
```ts
|
|
25
|
-
import { ConduitClient } from "conduit";
|
|
27
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
26
28
|
import appstate from "./appstate.json" assert { type: "json" };
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const client = new ConduitClient({ listenEvents: true });
|
|
29
31
|
|
|
30
|
-
await
|
|
32
|
+
await client.login({ appstate });
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
client.on("message:create", async (ctx, next) => {
|
|
33
35
|
if (ctx.body === "ping") {
|
|
34
36
|
await ctx.reply("pong");
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
39
|
+
|
|
37
40
|
await next();
|
|
38
41
|
});
|
|
39
42
|
```
|
|
@@ -50,56 +53,69 @@ Pass **one** of the following to `.login()`:
|
|
|
50
53
|
|
|
51
54
|
```ts
|
|
52
55
|
// appstate (recommended)
|
|
53
|
-
await
|
|
56
|
+
await client.login({ appstate: [...] });
|
|
54
57
|
|
|
55
58
|
// raw cookies
|
|
56
|
-
await
|
|
59
|
+
await client.login({ cookies: "c_user=...; xs=..." });
|
|
57
60
|
|
|
58
61
|
// email/password (not recommended)
|
|
59
|
-
await
|
|
62
|
+
await client.login({
|
|
63
|
+
account: { email: "...", password: "..." },
|
|
64
|
+
});
|
|
60
65
|
```
|
|
61
66
|
|
|
62
67
|
## Events
|
|
63
68
|
|
|
64
|
-
Register handlers with `.on(event, ...middlewares)`.
|
|
69
|
+
Register handlers with `.on(event, ...middlewares)`.
|
|
70
|
+
|
|
71
|
+
Handlers receive a context object and an optional `next()` function for middleware chaining.
|
|
72
|
+
|
|
73
|
+
All events include:
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
- `send(body)` — send a message to the same thread
|
|
76
|
+
|
|
77
|
+
Message events additionally include:
|
|
78
|
+
|
|
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.
|
|
67
83
|
|
|
68
84
|
### Message Events
|
|
69
85
|
|
|
70
|
-
| Event |
|
|
71
|
-
| ----------------- |
|
|
72
|
-
| `message:create` | New message received
|
|
73
|
-
| `message:respond` | Reply to an existing message
|
|
74
|
-
| `message:remove` | Message unsent by sender
|
|
75
|
-
| `message:react` | Reaction added or removed
|
|
76
|
-
| `message:writing` |
|
|
77
|
-
| `message:read` | Thread or message marked as read
|
|
86
|
+
| Event | Description |
|
|
87
|
+
| ----------------- | ------------------------------------------------ |
|
|
88
|
+
| `message:create` | New message received |
|
|
89
|
+
| `message:respond` | Reply to an existing message |
|
|
90
|
+
| `message:remove` | Message unsent by sender |
|
|
91
|
+
| `message:react` | Reaction added or removed |
|
|
92
|
+
| `message:writing` | Typing indicator (requires `listenTyping: true`) |
|
|
93
|
+
| `message:read` | Thread or message marked as read |
|
|
78
94
|
|
|
79
95
|
### User Events
|
|
80
96
|
|
|
81
|
-
| Event |
|
|
97
|
+
| Event | Description |
|
|
82
98
|
| ------------- | -------------------------------------------- |
|
|
83
99
|
| `user:create` | User added to a group thread |
|
|
84
100
|
| `user:remove` | User left or was removed from a group thread |
|
|
85
101
|
|
|
86
102
|
### Thread Events
|
|
87
103
|
|
|
88
|
-
| Event |
|
|
89
|
-
| ------------------------- |
|
|
90
|
-
| `thread:update` |
|
|
91
|
-
| `thread:title_change` | Group title updated
|
|
92
|
-
| `thread:photo_replaced` | Group photo changed
|
|
93
|
-
| `thread:theme_changed` | Chat theme
|
|
94
|
-
| `thread:nickname_changed` |
|
|
95
|
-
| `thread:admin_changed` |
|
|
104
|
+
| Event | Description |
|
|
105
|
+
| ------------------------- | ---------------------------- |
|
|
106
|
+
| `thread:update` | Catch-all for thread updates |
|
|
107
|
+
| `thread:title_change` | Group title updated |
|
|
108
|
+
| `thread:photo_replaced` | Group photo changed |
|
|
109
|
+
| `thread:theme_changed` | Chat theme changed |
|
|
110
|
+
| `thread:nickname_changed` | Participant nickname updated |
|
|
111
|
+
| `thread:admin_changed` | Admin role changed |
|
|
96
112
|
|
|
97
113
|
## Middleware
|
|
98
114
|
|
|
99
|
-
`.on()` accepts multiple handlers. Each must call `next()` to
|
|
115
|
+
`.on()` accepts multiple handlers. Each must call `next()` to continue the chain.
|
|
100
116
|
|
|
101
117
|
```ts
|
|
102
|
-
|
|
118
|
+
client.on(
|
|
103
119
|
"message:create",
|
|
104
120
|
async (ctx, next) => {
|
|
105
121
|
console.log("middleware 1");
|
|
@@ -114,26 +130,31 @@ conduit.on(
|
|
|
114
130
|
|
|
115
131
|
## Raw FCA Access
|
|
116
132
|
|
|
117
|
-
|
|
133
|
+
Drop down to FCA when needed:
|
|
118
134
|
|
|
119
135
|
```ts
|
|
120
136
|
// raw FCA event
|
|
121
|
-
|
|
137
|
+
client.onFca("presence", async (data) => {
|
|
122
138
|
console.log(data);
|
|
123
139
|
});
|
|
124
140
|
|
|
125
|
-
// raw FCA
|
|
126
|
-
|
|
141
|
+
// raw FCA API (no type safety)
|
|
142
|
+
client.api.getThreadList(10, null, ["INBOX"]);
|
|
127
143
|
```
|
|
128
144
|
|
|
129
145
|
## API Reference
|
|
130
146
|
|
|
131
|
-
See [docs/DOCS.md](docs/DOCS.md) for
|
|
147
|
+
See [docs/DOCS.md](docs/DOCS.md) for full API details:
|
|
148
|
+
|
|
149
|
+
- `client.messages`
|
|
150
|
+
- `client.threads`
|
|
151
|
+
- `client.users`
|
|
152
|
+
- `client.account`
|
|
132
153
|
|
|
133
154
|
## License
|
|
134
155
|
|
|
135
|
-
GNU GPL v3 ©
|
|
156
|
+
GNU GPL v3 © theophilusdev
|
|
136
157
|
|
|
137
158
|
---
|
|
138
159
|
|
|
139
|
-
Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial).
|
|
160
|
+
Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial).
|
package/docs/DOCS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Conduit — API Reference
|
|
2
2
|
|
|
3
|
-
Full reference for all
|
|
3
|
+
Full reference for all APIs exposed by `ConduitClient`.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -16,28 +16,33 @@ Full reference for all namespaced APIs exposed by `ConduitClient`.
|
|
|
16
16
|
## ConduitClient
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
import { ConduitClient } from "conduit";
|
|
19
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
await
|
|
21
|
+
const client = new ConduitClient(config);
|
|
22
|
+
await client.login(credentials);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
---
|
|
26
|
+
|
|
25
27
|
### Constructor
|
|
26
28
|
|
|
27
29
|
```ts
|
|
28
30
|
new ConduitClient(config: ConduitClientConfig)
|
|
29
31
|
```
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
Creates a new Conduit client instance.
|
|
34
|
+
|
|
35
|
+
- Extends `MessengerBotOptions` from `@dongdev/fca-unofficial`
|
|
36
|
+
- `logLevel` defaults to `"silent"`
|
|
32
37
|
|
|
33
38
|
---
|
|
34
39
|
|
|
35
40
|
### `.login(credentials)`
|
|
36
41
|
|
|
37
|
-
Authenticates with Messenger and
|
|
42
|
+
Authenticates with Messenger and initializes the client.
|
|
38
43
|
|
|
39
44
|
```ts
|
|
40
|
-
await
|
|
45
|
+
await client.login(credentials: ConduitCredentials): Promise<ConduitClient>
|
|
41
46
|
```
|
|
42
47
|
|
|
43
48
|
Returns the client instance for chaining.
|
|
@@ -46,14 +51,14 @@ Returns the client instance for chaining.
|
|
|
46
51
|
|
|
47
52
|
### `.on(event, ...middlewares)`
|
|
48
53
|
|
|
49
|
-
Registers one or more middleware handlers for a Conduit event.
|
|
54
|
+
Registers one or more middleware handlers for a Conduit event.
|
|
50
55
|
|
|
51
56
|
```ts
|
|
52
|
-
|
|
57
|
+
client.on(event: keyof ConduitEvents, ...middlewares: Middleware[]): this
|
|
53
58
|
```
|
|
54
59
|
|
|
55
60
|
```ts
|
|
56
|
-
|
|
61
|
+
client.on("message:create", async (ctx, next) => {
|
|
57
62
|
await ctx.reply("hello!");
|
|
58
63
|
await next();
|
|
59
64
|
});
|
|
@@ -63,56 +68,80 @@ conduit.on("message:create", async (ctx, next) => {
|
|
|
63
68
|
|
|
64
69
|
### `.onFca(event, ...middlewares)`
|
|
65
70
|
|
|
66
|
-
Registers middleware directly
|
|
71
|
+
Registers middleware directly on raw FCA events.
|
|
67
72
|
|
|
68
73
|
```ts
|
|
69
|
-
|
|
74
|
+
client.onFca(event: string, ...middlewares): this
|
|
70
75
|
```
|
|
71
76
|
|
|
72
77
|
---
|
|
73
78
|
|
|
74
79
|
### `.api`
|
|
75
80
|
|
|
76
|
-
Direct access to the raw FCA
|
|
81
|
+
Direct access to the raw FCA API. No type safety — use as a last resort.
|
|
77
82
|
|
|
78
83
|
```ts
|
|
79
|
-
|
|
84
|
+
client.api.getThreadList(10, null, ["INBOX"]);
|
|
80
85
|
```
|
|
81
86
|
|
|
82
87
|
---
|
|
83
88
|
|
|
84
89
|
## client.messages
|
|
85
90
|
|
|
86
|
-
Accessible via
|
|
91
|
+
Accessible via:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
client.messages;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Handles message-level operations.
|
|
87
98
|
|
|
88
99
|
---
|
|
89
100
|
|
|
90
101
|
### `.send(body, threadID)`
|
|
91
102
|
|
|
92
|
-
Sends a
|
|
103
|
+
Sends a message to a thread. Accepts a plain string or a `ConduitMessageBody` for rich messages.
|
|
93
104
|
|
|
94
105
|
```ts
|
|
95
|
-
await
|
|
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
|
+
);
|
|
96
116
|
```
|
|
97
117
|
|
|
98
118
|
---
|
|
99
119
|
|
|
100
120
|
### `.reply(body, threadID, messageID)`
|
|
101
121
|
|
|
102
|
-
Sends a quoted reply to a specific message.
|
|
122
|
+
Sends a quoted reply to a specific message. Accepts a plain string or a `ConduitMessageBody`.
|
|
103
123
|
|
|
104
124
|
```ts
|
|
105
|
-
await
|
|
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
|
+
);
|
|
106
135
|
```
|
|
107
136
|
|
|
108
137
|
---
|
|
109
138
|
|
|
110
139
|
### `.edit(messageID, body)`
|
|
111
140
|
|
|
112
|
-
Edits an existing message
|
|
141
|
+
Edits an existing message.
|
|
113
142
|
|
|
114
143
|
```ts
|
|
115
|
-
await
|
|
144
|
+
await client.messages.edit(messageID, "updated text");
|
|
116
145
|
```
|
|
117
146
|
|
|
118
147
|
---
|
|
@@ -122,7 +151,7 @@ await conduit.messages.edit(messageID, "updated text");
|
|
|
122
151
|
Retracts a message sent by the bot.
|
|
123
152
|
|
|
124
153
|
```ts
|
|
125
|
-
await
|
|
154
|
+
await client.messages.unsend(messageID);
|
|
126
155
|
```
|
|
127
156
|
|
|
128
157
|
---
|
|
@@ -132,7 +161,7 @@ await conduit.messages.unsend(messageID);
|
|
|
132
161
|
Deletes a message.
|
|
133
162
|
|
|
134
163
|
```ts
|
|
135
|
-
await
|
|
164
|
+
await client.messages.delete(messageID);
|
|
136
165
|
```
|
|
137
166
|
|
|
138
167
|
---
|
|
@@ -142,17 +171,17 @@ await conduit.messages.delete(messageID);
|
|
|
142
171
|
Adds or removes a reaction on a message.
|
|
143
172
|
|
|
144
173
|
```ts
|
|
145
|
-
await
|
|
174
|
+
await client.messages.react("👍", messageID, threadID);
|
|
146
175
|
```
|
|
147
176
|
|
|
148
177
|
---
|
|
149
178
|
|
|
150
179
|
### `.sendTypingIndicator(threadID)`
|
|
151
180
|
|
|
152
|
-
Sends a typing indicator
|
|
181
|
+
Sends a typing indicator.
|
|
153
182
|
|
|
154
183
|
```ts
|
|
155
|
-
await
|
|
184
|
+
await client.messages.sendTypingIndicator(threadID);
|
|
156
185
|
```
|
|
157
186
|
|
|
158
187
|
---
|
|
@@ -162,205 +191,209 @@ await conduit.messages.sendTypingIndicator(threadID);
|
|
|
162
191
|
Marks a message as read.
|
|
163
192
|
|
|
164
193
|
```ts
|
|
165
|
-
await
|
|
194
|
+
await client.messages.markAsRead(messageID);
|
|
166
195
|
```
|
|
167
196
|
|
|
168
197
|
---
|
|
169
198
|
|
|
170
199
|
### `.uploadAttachment(file)`
|
|
171
200
|
|
|
172
|
-
Uploads a file attachment
|
|
201
|
+
Uploads a file attachment.
|
|
173
202
|
|
|
174
203
|
```ts
|
|
175
|
-
const attachment = await
|
|
204
|
+
const attachment = await client.messages.uploadAttachment(stream);
|
|
176
205
|
```
|
|
177
206
|
|
|
178
207
|
---
|
|
179
208
|
|
|
180
209
|
### `.forwardAttachment(attachmentID, threadID)`
|
|
181
210
|
|
|
182
|
-
Forwards an
|
|
211
|
+
Forwards an attachment to another thread.
|
|
183
212
|
|
|
184
213
|
```ts
|
|
185
|
-
await
|
|
214
|
+
await client.messages.forwardAttachment(attachmentID, threadID);
|
|
186
215
|
```
|
|
187
216
|
|
|
188
217
|
---
|
|
189
218
|
|
|
190
219
|
### `.shareContact(userID, threadID)`
|
|
191
220
|
|
|
192
|
-
Shares a contact card
|
|
221
|
+
Shares a contact card.
|
|
193
222
|
|
|
194
223
|
```ts
|
|
195
|
-
await
|
|
224
|
+
await client.messages.shareContact(userID, threadID);
|
|
196
225
|
```
|
|
197
226
|
|
|
198
227
|
---
|
|
199
228
|
|
|
200
229
|
### `.changeThreadColor(color, threadID)`
|
|
201
230
|
|
|
202
|
-
Changes
|
|
231
|
+
Changes thread color.
|
|
203
232
|
|
|
204
233
|
```ts
|
|
205
|
-
await
|
|
234
|
+
await client.messages.changeThreadColor("#FF0000", threadID);
|
|
206
235
|
```
|
|
207
236
|
|
|
208
237
|
---
|
|
209
238
|
|
|
210
239
|
### `.changeThreadEmoji(emoji, threadID)`
|
|
211
240
|
|
|
212
|
-
Changes
|
|
241
|
+
Changes thread emoji.
|
|
213
242
|
|
|
214
243
|
```ts
|
|
215
|
-
await
|
|
244
|
+
await client.messages.changeThreadEmoji("🔥", threadID);
|
|
216
245
|
```
|
|
217
246
|
|
|
218
247
|
---
|
|
219
248
|
|
|
220
249
|
### `.getMessage(messageID)`
|
|
221
250
|
|
|
222
|
-
Fetches a
|
|
251
|
+
Fetches a message by ID.
|
|
223
252
|
|
|
224
253
|
```ts
|
|
225
|
-
const message = await
|
|
254
|
+
const message = await client.messages.getMessage(messageID);
|
|
226
255
|
```
|
|
227
256
|
|
|
228
257
|
---
|
|
229
258
|
|
|
230
259
|
### `.getThreadColors()`
|
|
231
260
|
|
|
232
|
-
Returns
|
|
261
|
+
Returns available thread colors.
|
|
233
262
|
|
|
234
263
|
```ts
|
|
235
|
-
const colors = await
|
|
264
|
+
const colors = await client.messages.getThreadColors();
|
|
236
265
|
```
|
|
237
266
|
|
|
238
267
|
---
|
|
239
268
|
|
|
240
269
|
## client.threads
|
|
241
270
|
|
|
242
|
-
Accessible via
|
|
271
|
+
Accessible via:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
client.threads;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Handles thread-level operations.
|
|
243
278
|
|
|
244
279
|
---
|
|
245
280
|
|
|
246
281
|
### `.getInfo(threadID)`
|
|
247
282
|
|
|
248
|
-
Fetches
|
|
283
|
+
Fetches thread information.
|
|
249
284
|
|
|
250
285
|
```ts
|
|
251
|
-
const info = await
|
|
286
|
+
const info = await client.threads.getInfo(threadID);
|
|
252
287
|
```
|
|
253
288
|
|
|
254
289
|
---
|
|
255
290
|
|
|
256
291
|
### `.getList(limit, cursor, folders)`
|
|
257
292
|
|
|
258
|
-
Fetches a
|
|
293
|
+
Fetches a list of threads.
|
|
259
294
|
|
|
260
295
|
```ts
|
|
261
|
-
const threads = await
|
|
296
|
+
const threads = await client.threads.getList(10, null, ["INBOX"]);
|
|
262
297
|
```
|
|
263
298
|
|
|
264
299
|
---
|
|
265
300
|
|
|
266
301
|
### `.getHistory(threadID, limit)`
|
|
267
302
|
|
|
268
|
-
Fetches message history
|
|
303
|
+
Fetches message history.
|
|
269
304
|
|
|
270
305
|
```ts
|
|
271
|
-
const history = await
|
|
306
|
+
const history = await client.threads.getHistory(threadID, 20);
|
|
272
307
|
```
|
|
273
308
|
|
|
274
309
|
---
|
|
275
310
|
|
|
276
311
|
### `.search(query)`
|
|
277
312
|
|
|
278
|
-
Searches
|
|
313
|
+
Searches threads.
|
|
279
314
|
|
|
280
315
|
```ts
|
|
281
|
-
const results = await
|
|
316
|
+
const results = await client.threads.search("dev chat");
|
|
282
317
|
```
|
|
283
318
|
|
|
284
319
|
---
|
|
285
320
|
|
|
286
321
|
### `.createGroup(userIDs, name?)`
|
|
287
322
|
|
|
288
|
-
Creates a
|
|
323
|
+
Creates a group conversation.
|
|
289
324
|
|
|
290
325
|
```ts
|
|
291
|
-
const thread = await
|
|
326
|
+
const thread = await client.threads.createGroup(["uid1", "uid2"], "my group");
|
|
292
327
|
```
|
|
293
328
|
|
|
294
329
|
---
|
|
295
330
|
|
|
296
331
|
### `.addUser(userID, threadID)`
|
|
297
332
|
|
|
298
|
-
Adds a user to
|
|
333
|
+
Adds a user to a thread.
|
|
299
334
|
|
|
300
335
|
```ts
|
|
301
|
-
await
|
|
336
|
+
await client.threads.addUser(userID, threadID);
|
|
302
337
|
```
|
|
303
338
|
|
|
304
339
|
---
|
|
305
340
|
|
|
306
341
|
### `.removeUser(userID, threadID)`
|
|
307
342
|
|
|
308
|
-
Removes a user from a
|
|
343
|
+
Removes a user from a thread.
|
|
309
344
|
|
|
310
345
|
```ts
|
|
311
|
-
await
|
|
346
|
+
await client.threads.removeUser(userID, threadID);
|
|
312
347
|
```
|
|
313
348
|
|
|
314
349
|
---
|
|
315
350
|
|
|
316
351
|
### `.changeAdminStatus(userID, threadID, admin)`
|
|
317
352
|
|
|
318
|
-
|
|
353
|
+
Changes admin status.
|
|
319
354
|
|
|
320
355
|
```ts
|
|
321
|
-
await
|
|
322
|
-
await conduit.threads.changeAdminStatus(userID, threadID, false); // demote
|
|
356
|
+
await client.threads.changeAdminStatus(userID, threadID, true);
|
|
323
357
|
```
|
|
324
358
|
|
|
325
359
|
---
|
|
326
360
|
|
|
327
361
|
### `.changeGroupImage(image, threadID)`
|
|
328
362
|
|
|
329
|
-
Updates
|
|
363
|
+
Updates group image.
|
|
330
364
|
|
|
331
365
|
```ts
|
|
332
|
-
await
|
|
366
|
+
await client.threads.changeGroupImage(stream, threadID);
|
|
333
367
|
```
|
|
334
368
|
|
|
335
369
|
---
|
|
336
370
|
|
|
337
371
|
### `.changeNickname(nickname, threadID, userID)`
|
|
338
372
|
|
|
339
|
-
Sets
|
|
373
|
+
Sets nickname.
|
|
340
374
|
|
|
341
375
|
```ts
|
|
342
|
-
await
|
|
343
|
-
await conduit.threads.changeNickname("", threadID, userID); // clear
|
|
376
|
+
await client.threads.changeNickname("nick", threadID, userID);
|
|
344
377
|
```
|
|
345
378
|
|
|
346
379
|
---
|
|
347
380
|
|
|
348
381
|
### `.setTitle(title, threadID)`
|
|
349
382
|
|
|
350
|
-
Changes
|
|
383
|
+
Changes thread title.
|
|
351
384
|
|
|
352
385
|
```ts
|
|
353
|
-
await
|
|
386
|
+
await client.threads.setTitle("new title", threadID);
|
|
354
387
|
```
|
|
355
388
|
|
|
356
389
|
---
|
|
357
390
|
|
|
358
391
|
### `.createPoll(title, threadID, options)`
|
|
359
392
|
|
|
360
|
-
Creates a poll
|
|
393
|
+
Creates a poll.
|
|
361
394
|
|
|
362
395
|
```ts
|
|
363
|
-
await
|
|
396
|
+
await client.threads.createPoll("Favourite language?", threadID, [
|
|
364
397
|
"TypeScript",
|
|
365
398
|
"Python",
|
|
366
399
|
]);
|
|
@@ -373,55 +406,59 @@ await conduit.threads.createPoll("Favourite language?", threadID, [
|
|
|
373
406
|
Deletes a thread.
|
|
374
407
|
|
|
375
408
|
```ts
|
|
376
|
-
await
|
|
409
|
+
await client.threads.delete(threadID);
|
|
377
410
|
```
|
|
378
411
|
|
|
379
412
|
---
|
|
380
413
|
|
|
381
414
|
### `.mute(threadID, muteUntil)`
|
|
382
415
|
|
|
383
|
-
Mutes or unmutes
|
|
416
|
+
Mutes or unmutes a thread. Pass `-1` to mute indefinitely, `0` to unmute.
|
|
384
417
|
|
|
385
418
|
```ts
|
|
386
|
-
await
|
|
387
|
-
await
|
|
419
|
+
await client.threads.mute(threadID, -1); // mute forever
|
|
420
|
+
await client.threads.mute(threadID, 0); // unmute
|
|
388
421
|
```
|
|
389
422
|
|
|
390
423
|
---
|
|
391
424
|
|
|
392
425
|
### `.handleMessageRequest(threadID, accept)`
|
|
393
426
|
|
|
394
|
-
|
|
427
|
+
Handles message requests.
|
|
395
428
|
|
|
396
429
|
```ts
|
|
397
|
-
await
|
|
430
|
+
await client.threads.handleMessageRequest(threadID, true);
|
|
398
431
|
```
|
|
399
432
|
|
|
400
433
|
---
|
|
401
434
|
|
|
402
435
|
## client.users
|
|
403
436
|
|
|
404
|
-
Accessible via
|
|
437
|
+
Accessible via:
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
client.users;
|
|
441
|
+
```
|
|
405
442
|
|
|
406
443
|
---
|
|
407
444
|
|
|
408
445
|
### `.getInfo(userID)`
|
|
409
446
|
|
|
410
|
-
Fetches info
|
|
447
|
+
Fetches user info. Accepts a single ID or an array.
|
|
411
448
|
|
|
412
449
|
```ts
|
|
413
|
-
const user = await
|
|
414
|
-
const users = await
|
|
450
|
+
const user = await client.users.getInfo("uid");
|
|
451
|
+
const users = await client.users.getInfo(["uid1", "uid2"]);
|
|
415
452
|
```
|
|
416
453
|
|
|
417
454
|
---
|
|
418
455
|
|
|
419
456
|
### `.getID(vanity)`
|
|
420
457
|
|
|
421
|
-
Resolves a vanity
|
|
458
|
+
Resolves a vanity username to a Facebook user ID.
|
|
422
459
|
|
|
423
460
|
```ts
|
|
424
|
-
const id = await
|
|
461
|
+
const id = await client.users.getID("zuck");
|
|
425
462
|
```
|
|
426
463
|
|
|
427
464
|
---
|
|
@@ -431,23 +468,27 @@ const id = await conduit.users.getID("zuck");
|
|
|
431
468
|
Returns the authenticated user's friends list.
|
|
432
469
|
|
|
433
470
|
```ts
|
|
434
|
-
const friends = await
|
|
471
|
+
const friends = await client.users.getFriendsList();
|
|
435
472
|
```
|
|
436
473
|
|
|
437
474
|
---
|
|
438
475
|
|
|
439
476
|
## client.account
|
|
440
477
|
|
|
441
|
-
Accessible via
|
|
478
|
+
Accessible via:
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
client.account;
|
|
482
|
+
```
|
|
442
483
|
|
|
443
484
|
---
|
|
444
485
|
|
|
445
486
|
### `.getCurrentUserID()`
|
|
446
487
|
|
|
447
|
-
Returns
|
|
488
|
+
Returns current user ID. Synchronous.
|
|
448
489
|
|
|
449
490
|
```ts
|
|
450
|
-
const myID =
|
|
491
|
+
const myID = client.account.getCurrentUserID();
|
|
451
492
|
```
|
|
452
493
|
|
|
453
494
|
---
|
|
@@ -457,8 +498,8 @@ const myID = conduit.account.getCurrentUserID();
|
|
|
457
498
|
Blocks or unblocks a user.
|
|
458
499
|
|
|
459
500
|
```ts
|
|
460
|
-
await
|
|
461
|
-
await
|
|
501
|
+
await client.account.blockUser(userID, true); // block
|
|
502
|
+
await client.account.blockUser(userID, false); // unblock
|
|
462
503
|
```
|
|
463
504
|
|
|
464
505
|
---
|
|
@@ -468,7 +509,7 @@ await conduit.account.blockUser(userID, false); // unblock
|
|
|
468
509
|
Accepts or declines a friend request.
|
|
469
510
|
|
|
470
511
|
```ts
|
|
471
|
-
await
|
|
512
|
+
await client.account.handleFriendRequest(userID, true);
|
|
472
513
|
```
|
|
473
514
|
|
|
474
515
|
---
|
|
@@ -478,25 +519,23 @@ await conduit.account.handleFriendRequest(userID, true);
|
|
|
478
519
|
Removes a user from the friends list.
|
|
479
520
|
|
|
480
521
|
```ts
|
|
481
|
-
await
|
|
522
|
+
await client.account.unfriend(userID);
|
|
482
523
|
```
|
|
483
524
|
|
|
484
525
|
---
|
|
485
526
|
|
|
486
527
|
### `.logout()`
|
|
487
528
|
|
|
488
|
-
Ends the
|
|
529
|
+
Ends the session and invalidates cookies.
|
|
489
530
|
|
|
490
531
|
```ts
|
|
491
|
-
await
|
|
532
|
+
await client.account.logout();
|
|
492
533
|
```
|
|
493
534
|
|
|
494
535
|
---
|
|
495
536
|
|
|
496
537
|
## Types
|
|
497
538
|
|
|
498
|
-
Key types exported from conduit. See `src/types.ts` for the full source.
|
|
499
|
-
|
|
500
539
|
### `ConduitCredentials`
|
|
501
540
|
|
|
502
541
|
```ts
|
|
@@ -510,6 +549,22 @@ interface ConduitCredentials {
|
|
|
510
549
|
}
|
|
511
550
|
```
|
|
512
551
|
|
|
552
|
+
---
|
|
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
|
+
|
|
513
568
|
### `Message`
|
|
514
569
|
|
|
515
570
|
```ts
|
|
@@ -525,6 +580,8 @@ interface Message {
|
|
|
525
580
|
}
|
|
526
581
|
```
|
|
527
582
|
|
|
583
|
+
---
|
|
584
|
+
|
|
528
585
|
### `Middleware<K>`
|
|
529
586
|
|
|
530
587
|
```ts
|
|
@@ -534,6 +591,8 @@ type Middleware<K extends keyof ConduitEvents> = (
|
|
|
534
591
|
) => Promise<void>;
|
|
535
592
|
```
|
|
536
593
|
|
|
594
|
+
---
|
|
595
|
+
|
|
537
596
|
### `ConduitEvents`
|
|
538
597
|
|
|
539
|
-
|
|
598
|
+
Full event map is defined in `src/types.ts`.
|