@syrix/client 1.1.0 → 1.1.1
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/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/index.js +14 -1
package/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface SyrixMessage {
|
|
|
32
32
|
mentions: string[];
|
|
33
33
|
/** The message this one replies to. */
|
|
34
34
|
quoted: { id: string; senderId: string } | null;
|
|
35
|
+
/** Private reply to a group message: the group message it answers. */
|
|
36
|
+
groupQuote: { author: string; group: string; groupId: string | null; messageId: string | null; text: string } | null;
|
|
35
37
|
createdAt: string;
|
|
36
38
|
reply(text: string): Promise<unknown>;
|
|
37
39
|
/** Decrypted attachment bytes. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syrix/client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Official SYRIX CHAT library: link a bot or a program to a SYRIX account with a QR code or a pairing code (like a linked device), with end-to-end encryption.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/index.js
CHANGED
|
@@ -272,13 +272,26 @@ export class SyrixClient extends EventEmitter {
|
|
|
272
272
|
this.emit('undecryptable', { id: raw.id, conversationId: raw.conversation_id });
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
+
// A private reply to a group message carries its quote in front of the text (apps show it as a card).
|
|
276
|
+
let text = content.t ?? '';
|
|
277
|
+
let groupQuote = null;
|
|
278
|
+
const PRQ = '\u2063[PRQ]', PRQ_END = '[/PRQ]\u2063';
|
|
279
|
+
if (text.startsWith(PRQ) && text.includes(PRQ_END)) {
|
|
280
|
+
const end = text.indexOf(PRQ_END);
|
|
281
|
+
try {
|
|
282
|
+
const q = JSON.parse(text.slice(PRQ.length, end));
|
|
283
|
+
groupQuote = { author: q.n ?? '', group: q.g ?? '', groupId: q.gid ?? null, messageId: q.mid ?? null, text: q.t ?? '' };
|
|
284
|
+
} catch { /* malformed quote: keep the text only */ }
|
|
285
|
+
text = text.slice(end + PRQ_END.length);
|
|
286
|
+
}
|
|
275
287
|
const message = {
|
|
276
288
|
id: raw.id,
|
|
277
289
|
conversationId: raw.conversation_id,
|
|
278
290
|
senderId: raw.sender_id,
|
|
279
291
|
sender: raw.sender ?? null,
|
|
280
292
|
fromMe,
|
|
281
|
-
text
|
|
293
|
+
text,
|
|
294
|
+
groupQuote,
|
|
282
295
|
type: content.mt ?? 'text',
|
|
283
296
|
fileName: content.fn ?? null,
|
|
284
297
|
media: content.m ?? null,
|