@chatman-media/channel-telegram 1.5.0 → 1.6.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-parser.d.ts","sourceRoot":"","sources":["../../src/bot-api/update-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAA0B,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuEnE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-parser.d.ts","sourceRoot":"","sources":["../../src/bot-api/update-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAA0B,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuEnE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAwC/E"}
|
package/dist/index.js
CHANGED
|
@@ -32841,6 +32841,7 @@ function parseUpdate(channelId, update) {
|
|
|
32841
32841
|
return null;
|
|
32842
32842
|
if (!msg.from)
|
|
32843
32843
|
return null;
|
|
32844
|
+
const isEdit = !update.message && Boolean(update.edited_message);
|
|
32844
32845
|
const parts = partsFromMessage(channelId, msg);
|
|
32845
32846
|
if (parts.length === 0)
|
|
32846
32847
|
return null;
|
|
@@ -32851,6 +32852,7 @@ function parseUpdate(channelId, update) {
|
|
|
32851
32852
|
...msg.from.username ? { externalUsername: msg.from.username } : {},
|
|
32852
32853
|
parts,
|
|
32853
32854
|
receivedAt: msg.date,
|
|
32855
|
+
...isEdit ? { edited: true } : {},
|
|
32854
32856
|
raw: update
|
|
32855
32857
|
};
|
|
32856
32858
|
}
|
package/package.json
CHANGED
|
@@ -218,7 +218,7 @@ describe("parseUpdate", () => {
|
|
|
218
218
|
expect(parseUpdate(CH, update)?.parts).toEqual([{ kind: "text", text: "stray caption" }]);
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
it("edited_message парсится
|
|
221
|
+
it("edited_message парсится с теми же id/parts и флагом edited=true", () => {
|
|
222
222
|
const update: TgUpdate = {
|
|
223
223
|
update_id: 15,
|
|
224
224
|
edited_message: {
|
|
@@ -232,6 +232,21 @@ describe("parseUpdate", () => {
|
|
|
232
232
|
const inbound = parseUpdate(CH, update);
|
|
233
233
|
expect(inbound?.externalMessageId).toBe("16");
|
|
234
234
|
expect(inbound?.parts).toEqual([{ kind: "text", text: "fixed typo" }]);
|
|
235
|
+
expect(inbound?.edited).toBe(true);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("обычное message не помечается edited", () => {
|
|
239
|
+
const update: TgUpdate = {
|
|
240
|
+
update_id: 18,
|
|
241
|
+
message: {
|
|
242
|
+
message_id: 19,
|
|
243
|
+
chat: { id: 901, type: "private" },
|
|
244
|
+
from: { id: 901 },
|
|
245
|
+
date: 1700000002,
|
|
246
|
+
text: "hi",
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
expect(parseUpdate(CH, update)?.edited).toBeUndefined();
|
|
235
250
|
});
|
|
236
251
|
|
|
237
252
|
it("callback_query без data → null", () => {
|
|
@@ -97,6 +97,11 @@ export function parseUpdate(channelId: string, update: TgUpdate): Inbound | null
|
|
|
97
97
|
if (!msg) return null;
|
|
98
98
|
if (!msg.from) return null;
|
|
99
99
|
|
|
100
|
+
// Правка ранее отправленного сообщения (message_id совпадает с исходным).
|
|
101
|
+
// conversation-engine на edited обновит сохранённое сообщение и переответит,
|
|
102
|
+
// а не дедупит как ретрай.
|
|
103
|
+
const isEdit = !update.message && Boolean(update.edited_message);
|
|
104
|
+
|
|
100
105
|
const parts = partsFromMessage(channelId, msg);
|
|
101
106
|
if (parts.length === 0) return null;
|
|
102
107
|
|
|
@@ -107,6 +112,7 @@ export function parseUpdate(channelId: string, update: TgUpdate): Inbound | null
|
|
|
107
112
|
...(msg.from.username ? { externalUsername: msg.from.username } : {}),
|
|
108
113
|
parts,
|
|
109
114
|
receivedAt: msg.date,
|
|
115
|
+
...(isEdit ? { edited: true } : {}),
|
|
110
116
|
raw: update,
|
|
111
117
|
};
|
|
112
118
|
}
|