@imessaging/telegram-mtproto 0.8.13 → 0.8.14
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imessaging/telegram-mtproto",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.14",
|
|
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.8.
|
|
34
|
+
"@imessaging/core": "^0.8.12",
|
|
35
35
|
"big-integer": "^1.6.52"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -29,6 +29,8 @@ import type {
|
|
|
29
29
|
OutboundMessage,
|
|
30
30
|
ReactionTransport,
|
|
31
31
|
ResolvedPeer,
|
|
32
|
+
SelfAccount,
|
|
33
|
+
SelfAwareTransport,
|
|
32
34
|
SendResult,
|
|
33
35
|
TelegramPeerStore,
|
|
34
36
|
TelegramRecipient,
|
|
@@ -163,6 +165,7 @@ export class TelegramMtprotoTransport
|
|
|
163
165
|
PeerInfoTransport,
|
|
164
166
|
PhoneLookupTransport,
|
|
165
167
|
ReactionTransport,
|
|
168
|
+
SelfAwareTransport,
|
|
166
169
|
ReadReceiptTransport,
|
|
167
170
|
TypingTransport
|
|
168
171
|
{
|
|
@@ -191,6 +194,8 @@ export class TelegramMtprotoTransport
|
|
|
191
194
|
private readonly ownEdited = new Map<string, number>();
|
|
192
195
|
/** Идущие send/edit: обновление о своём сообщении может прийти раньше, чем вызов вернёт его номер. */
|
|
193
196
|
private readonly ownPending = new Set<Promise<unknown>>();
|
|
197
|
+
/** Своя учётка: не меняется за жизнь сессии, спрашивается один раз. */
|
|
198
|
+
private selfAccount?: Promise<SelfAccount>;
|
|
194
199
|
/** Отметка жизни подписки: срабатывает на любом обновлении, включая служебные. */
|
|
195
200
|
private activityListener: ((event: unknown) => void) | null = null;
|
|
196
201
|
|
|
@@ -733,6 +738,26 @@ export class TelegramMtprotoTransport
|
|
|
733
738
|
this.lastActivityAt = new Date();
|
|
734
739
|
}
|
|
735
740
|
|
|
741
|
+
/** Своя учётка — users.GetUsers(InputUserSelf); удачный ответ кэшируется, отказ — нет. */
|
|
742
|
+
async self(): Promise<SelfAccount> {
|
|
743
|
+
this.assertConnected();
|
|
744
|
+
this.selfAccount ??= this.client
|
|
745
|
+
.invoke(new Api.users.GetUsers({ id: [new Api.InputUserSelf()] }))
|
|
746
|
+
.then(([user]) => {
|
|
747
|
+
if (!user || !isUser(user)) throw new Error("users.GetUsers(self) returned no user");
|
|
748
|
+
return {
|
|
749
|
+
id: user.id.toString(),
|
|
750
|
+
...(user.username ? { username: user.username } : {}),
|
|
751
|
+
isBot: user.bot === true,
|
|
752
|
+
};
|
|
753
|
+
})
|
|
754
|
+
.catch((error: unknown) => {
|
|
755
|
+
this.selfAccount = undefined;
|
|
756
|
+
throw error;
|
|
757
|
+
});
|
|
758
|
+
return this.selfAccount;
|
|
759
|
+
}
|
|
760
|
+
|
|
736
761
|
/**
|
|
737
762
|
* Контакт ли собеседник и взаимно ли. Пир берётся из хранилища и кэша клиента, иначе по @username;
|
|
738
763
|
* по телефону не ищет — это findByPhone.
|