@imessaging/telegram-mtproto 0.7.0 → 0.7.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/package.json +2 -2
- package/src/incoming.ts +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imessaging/telegram-mtproto",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Telegram MTProto user-account transport for imessaging",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"messaging",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "bun test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@imessaging/core": "0.7.
|
|
34
|
+
"@imessaging/core": "^0.7.1",
|
|
35
35
|
"big-integer": "^1.6.52"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
package/src/incoming.ts
CHANGED
|
@@ -18,6 +18,12 @@ export type MtprotoMessageLike = {
|
|
|
18
18
|
fromId?: MtprotoPeerLike;
|
|
19
19
|
media?: MtprotoMediaLike;
|
|
20
20
|
replyTo?: { replyToMsgId?: number | string };
|
|
21
|
+
/** Заголовок форварда. Пусто — сообщение своё, не пересланное. */
|
|
22
|
+
fwdFrom?: {
|
|
23
|
+
fromId?: MtprotoPeerLike;
|
|
24
|
+
fromName?: string;
|
|
25
|
+
channelPost?: number;
|
|
26
|
+
};
|
|
21
27
|
/**
|
|
22
28
|
* Отправитель целиком — его приносит обновление вместе с `accessHash`.
|
|
23
29
|
*
|
|
@@ -84,6 +90,25 @@ export function unmarkPeerId(chatId: string): string {
|
|
|
84
90
|
return chatId;
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Источник форварда → общий вид.
|
|
95
|
+
*
|
|
96
|
+
* Пир источника МОЖЕТ отсутствовать: автор форварда вправе скрыть его. Тогда остаётся имя, а
|
|
97
|
+
* иногда и оно пустое — и это честнее выдумывания, чем подстановка чата, в котором сообщение лежит.
|
|
98
|
+
*/
|
|
99
|
+
function toForwardedFrom(
|
|
100
|
+
fwdFrom: MtprotoMessageLike["fwdFrom"],
|
|
101
|
+
): IncomingMessage["forwardedFrom"] {
|
|
102
|
+
if (!fwdFrom) return undefined;
|
|
103
|
+
const peer = fwdFrom.fromId ? peerToChat(fwdFrom.fromId) : null;
|
|
104
|
+
return {
|
|
105
|
+
chatId: peer?.chatId,
|
|
106
|
+
chatType: peer?.chatType,
|
|
107
|
+
title: fwdFrom.fromName,
|
|
108
|
+
messageId: fwdFrom.channelPost === undefined ? undefined : String(fwdFrom.channelPost),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
87
112
|
/**
|
|
88
113
|
* Что приехало файлом.
|
|
89
114
|
*
|
|
@@ -157,6 +182,7 @@ export function toIncomingMessage(
|
|
|
157
182
|
message.replyTo?.replyToMsgId === undefined
|
|
158
183
|
? undefined
|
|
159
184
|
: String(message.replyTo.replyToMsgId),
|
|
185
|
+
forwardedFrom: toForwardedFrom(message.fwdFrom),
|
|
160
186
|
};
|
|
161
187
|
}
|
|
162
188
|
|