@mtcute/core 0.23.3 → 0.24.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.
- package/client.cjs +9 -2
- package/client.js +9 -2
- package/highlevel/base.cjs +15 -3
- package/highlevel/base.d.cts +4 -1
- package/highlevel/base.d.ts +4 -1
- package/highlevel/base.js +15 -3
- package/highlevel/client.d.cts +12 -2
- package/highlevel/client.d.ts +12 -2
- package/highlevel/client.types.d.cts +2 -1
- package/highlevel/client.types.d.ts +2 -1
- package/highlevel/methods/files/download-iterable.cjs +1 -1
- package/highlevel/methods/files/download-iterable.js +1 -1
- package/highlevel/methods/premium/transfer-star-gift.cjs +2 -2
- package/highlevel/methods/premium/transfer-star-gift.d.cts +1 -1
- package/highlevel/methods/premium/transfer-star-gift.d.ts +1 -1
- package/highlevel/methods/premium/transfer-star-gift.js +2 -2
- package/highlevel/methods/users/resolve-peer.cjs +63 -70
- package/highlevel/methods/users/resolve-peer.d.cts +2 -1
- package/highlevel/methods/users/resolve-peer.d.ts +2 -1
- package/highlevel/methods/users/resolve-peer.js +61 -68
- package/highlevel/methods/users/resolve-phone-number.cjs +36 -0
- package/highlevel/methods/users/resolve-phone-number.d.cts +10 -0
- package/highlevel/methods/users/resolve-phone-number.d.ts +10 -0
- package/highlevel/methods/users/resolve-phone-number.js +31 -0
- package/highlevel/methods.d.cts +6 -4
- package/highlevel/methods.d.ts +6 -4
- package/highlevel/types/peers/peer.d.cts +2 -3
- package/highlevel/types/peers/peer.d.ts +2 -3
- package/highlevel/types/premium/stars-gift-unique.cjs +2 -1
- package/highlevel/types/premium/stars-gift-unique.d.cts +2 -2
- package/highlevel/types/premium/stars-gift-unique.d.ts +2 -2
- package/highlevel/types/premium/stars-gift-unique.js +2 -1
- package/highlevel/types/premium/stars-transaction.cjs +1 -1
- package/highlevel/types/premium/stars-transaction.d.cts +2 -2
- package/highlevel/types/premium/stars-transaction.d.ts +2 -2
- package/highlevel/types/premium/stars-transaction.js +1 -1
- package/highlevel/updates/manager.cjs +35 -26
- package/highlevel/updates/manager.d.cts +6 -6
- package/highlevel/updates/manager.d.ts +6 -6
- package/highlevel/updates/manager.js +35 -26
- package/highlevel/updates/types.d.cts +6 -6
- package/highlevel/updates/types.d.ts +6 -6
- package/highlevel/worker/port.cjs +7 -5
- package/highlevel/worker/port.d.cts +3 -2
- package/highlevel/worker/port.d.ts +3 -2
- package/highlevel/worker/port.js +7 -5
- package/methods.cjs +2 -0
- package/methods.js +2 -0
- package/network/client.cjs +12 -8
- package/network/client.d.cts +4 -1
- package/network/client.d.ts +4 -1
- package/network/client.js +12 -8
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/session-connection.cjs +1 -0
- package/network/session-connection.js +1 -0
- package/package.json +1 -1
- package/utils/index.d.cts +0 -1
- package/utils/index.d.ts +0 -1
- package/utils/sorted-array.cjs +6 -0
- package/utils/sorted-array.d.cts +2 -0
- package/utils/sorted-array.d.ts +2 -0
- package/utils/sorted-array.js +6 -0
- package/utils.cjs +0 -2
- package/utils.js +0 -2
- package/utils/linked-list.cjs +0 -65
- package/utils/linked-list.d.cts +0 -21
- package/utils/linked-list.d.ts +0 -21
- package/utils/linked-list.js +0 -60
- package/utils/linked-list.test.d.cts +0 -1
- package/utils/linked-list.test.d.ts +0 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { unreachable } from "@fuman/utils";
|
|
1
2
|
import { tl } from "@mtcute/tl";
|
|
2
3
|
import Long from "long";
|
|
3
|
-
import { MtTypeAssertionError } from "../../../types/errors.js";
|
|
4
|
+
import { MtArgumentError, MtTypeAssertionError } from "../../../types/errors.js";
|
|
4
5
|
import { parseMarkedPeerId, getMarkedPeerId, toggleChannelIdMark } from "../../../utils/peer-utils.js";
|
|
5
6
|
import { MtPeerNotFoundError } from "../../types/errors.js";
|
|
6
7
|
import { extractUsernames, toInputUser, toInputChannel, toInputPeer } from "../../utils/peer-utils.js";
|
|
7
8
|
import { _getChannelsBatched, _getUsersBatched } from "../chats/batched-queries.js";
|
|
9
|
+
import { resolvePhoneNumber } from "./resolve-phone-number.js";
|
|
8
10
|
function _normalizePeerId(peerId) {
|
|
9
11
|
if (typeof peerId === "object") {
|
|
10
12
|
if (tl.isAnyPeer(peerId)) {
|
|
@@ -27,6 +29,43 @@ function _normalizePeerId(peerId) {
|
|
|
27
29
|
}
|
|
28
30
|
return peerId;
|
|
29
31
|
}
|
|
32
|
+
function _handleContactsResolvedPeer(peerId, res) {
|
|
33
|
+
if (res.peer._ === "peerUser") {
|
|
34
|
+
const id = res.peer.userId;
|
|
35
|
+
const found = res.users.find((it) => it.id === id);
|
|
36
|
+
if (found && found._ === "user") {
|
|
37
|
+
if (!found.accessHash) {
|
|
38
|
+
throw new MtPeerNotFoundError(
|
|
39
|
+
`Peer (user) with username ${peerId} was found, but it has no access hash`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
_: "inputPeerUser",
|
|
44
|
+
userId: found.id,
|
|
45
|
+
accessHash: found.accessHash
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
} else if (res.peer._ === "peerChannel") {
|
|
49
|
+
const id = res.peer.channelId;
|
|
50
|
+
const found = res.chats.find((it) => it.id === id);
|
|
51
|
+
if (found) {
|
|
52
|
+
if (!(found._ === "channel" || found._ === "channelForbidden")) {
|
|
53
|
+
throw new MtTypeAssertionError("ResolvedPeer#chats", "channel", found._);
|
|
54
|
+
}
|
|
55
|
+
if (!found.accessHash) {
|
|
56
|
+
throw new MtPeerNotFoundError(`Peer (channel) with ${peerId} was found, but it has no access hash`);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
_: "inputPeerChannel",
|
|
60
|
+
channelId: found.id,
|
|
61
|
+
accessHash: found.accessHash
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
throw new MtTypeAssertionError("ResolvedPeer#peer", "user or channel", res.peer._);
|
|
66
|
+
}
|
|
67
|
+
unreachable();
|
|
68
|
+
}
|
|
30
69
|
async function resolvePeer(client, peerId, force = false) {
|
|
31
70
|
peerId = _normalizePeerId(peerId);
|
|
32
71
|
if (typeof peerId === "object") {
|
|
@@ -38,76 +77,29 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
38
77
|
}
|
|
39
78
|
if (typeof peerId === "string") {
|
|
40
79
|
if (peerId === "self" || peerId === "me") return { _: "inputPeerSelf" };
|
|
41
|
-
peerId = peerId.replace(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
peerId = peerId.replace(/^@/, "");
|
|
81
|
+
if (peerId.match(/^\d/)) {
|
|
82
|
+
throw new MtArgumentError(
|
|
83
|
+
`Invalid username: ${peerId}. If you wanted to resolve by user ID, pass a number instead. If you wanted to resolve by phone number, use resolvePhoneNumber instead.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (!force) {
|
|
87
|
+
const fromStorage = await client.storage.peers.getByUsername(peerId);
|
|
45
88
|
if (fromStorage) return fromStorage;
|
|
46
|
-
try {
|
|
47
|
-
res = await client.call({
|
|
48
|
-
_: "contacts.resolvePhone",
|
|
49
|
-
phone: peerId
|
|
50
|
-
});
|
|
51
|
-
} catch (e) {
|
|
52
|
-
if (tl.RpcError.is(e, "PHONE_NOT_OCCUPIED")) {
|
|
53
|
-
throw new MtPeerNotFoundError(`Peer with phone number ${peerId} was not found`);
|
|
54
|
-
} else {
|
|
55
|
-
throw e;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
if (!force) {
|
|
60
|
-
const fromStorage = await client.storage.peers.getByUsername(peerId);
|
|
61
|
-
if (fromStorage) return fromStorage;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
res = await client.call({
|
|
65
|
-
_: "contacts.resolveUsername",
|
|
66
|
-
username: peerId
|
|
67
|
-
});
|
|
68
|
-
} catch (e) {
|
|
69
|
-
if (tl.RpcError.is(e, "USERNAME_NOT_OCCUPIED")) {
|
|
70
|
-
throw new MtPeerNotFoundError(`Peer with username ${peerId} was not found`);
|
|
71
|
-
} else {
|
|
72
|
-
throw e;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
89
|
}
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
userId: found.id,
|
|
88
|
-
accessHash: found.accessHash
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
} else if (res.peer._ === "peerChannel") {
|
|
92
|
-
const id = res.peer.channelId;
|
|
93
|
-
const found = res.chats.find((it) => it.id === id);
|
|
94
|
-
if (found) {
|
|
95
|
-
if (!(found._ === "channel" || found._ === "channelForbidden")) {
|
|
96
|
-
throw new MtTypeAssertionError("contacts.resolveUsername#chats", "channel", found._);
|
|
97
|
-
}
|
|
98
|
-
if (!found.accessHash) {
|
|
99
|
-
throw new MtPeerNotFoundError(`Peer (channel) with ${peerId} was found, but it has no access hash`);
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
_: "inputPeerChannel",
|
|
103
|
-
channelId: found.id,
|
|
104
|
-
accessHash: found.accessHash
|
|
105
|
-
};
|
|
90
|
+
try {
|
|
91
|
+
const res = await client.call({
|
|
92
|
+
_: "contacts.resolveUsername",
|
|
93
|
+
username: peerId
|
|
94
|
+
});
|
|
95
|
+
return _handleContactsResolvedPeer(peerId, res);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if (tl.RpcError.is(e, "USERNAME_NOT_OCCUPIED") || tl.RpcError.is(e, "USERNAME_INVALID")) {
|
|
98
|
+
throw new MtPeerNotFoundError(`Peer with username ${peerId} was not found`);
|
|
99
|
+
} else {
|
|
100
|
+
throw e;
|
|
106
101
|
}
|
|
107
|
-
} else {
|
|
108
|
-
throw new MtTypeAssertionError("contacts.resolveUsername", "user or channel", res.peer._);
|
|
109
102
|
}
|
|
110
|
-
throw new MtPeerNotFoundError(`Could not find a peer by ${peerId}`);
|
|
111
103
|
}
|
|
112
104
|
const [peerType, bareId] = parseMarkedPeerId(peerId);
|
|
113
105
|
if (peerType === "chat") {
|
|
@@ -126,7 +118,7 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
126
118
|
}
|
|
127
119
|
}
|
|
128
120
|
if (cached._ === "user" && cached.phone) {
|
|
129
|
-
const resolved = await
|
|
121
|
+
const resolved = await resolvePhoneNumber(client, cached.phone, true);
|
|
130
122
|
if (getMarkedPeerId(resolved) === peerId) {
|
|
131
123
|
return resolved;
|
|
132
124
|
}
|
|
@@ -173,6 +165,7 @@ async function resolveChannel(client, peerId, force = false) {
|
|
|
173
165
|
return toInputChannel(await resolvePeer(client, peerId, force), peerId);
|
|
174
166
|
}
|
|
175
167
|
export {
|
|
168
|
+
_handleContactsResolvedPeer,
|
|
176
169
|
_normalizePeerId,
|
|
177
170
|
resolveChannel,
|
|
178
171
|
resolvePeer,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const tl = require("@mtcute/tl");
|
|
9
|
+
const errors = require("../../../types/errors.cjs");
|
|
10
|
+
const errors$1 = require("../../types/errors.cjs");
|
|
11
|
+
const resolvePeer = require("./resolve-peer.cjs");
|
|
12
|
+
async function resolvePhoneNumber(client, phone, force = false) {
|
|
13
|
+
phone = phone.replace(/[@+\s()]/g, "");
|
|
14
|
+
if (!phone.match(/^\d+$/)) {
|
|
15
|
+
throw new errors.MtArgumentError("phone should only contain digits");
|
|
16
|
+
}
|
|
17
|
+
if (!force) {
|
|
18
|
+
const fromStorage = await client.storage.peers.getByPhone(phone);
|
|
19
|
+
if (fromStorage) return fromStorage;
|
|
20
|
+
}
|
|
21
|
+
let res;
|
|
22
|
+
try {
|
|
23
|
+
res = await client.call({
|
|
24
|
+
_: "contacts.resolvePhone",
|
|
25
|
+
phone
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (tl.tl.RpcError.is(e, "PHONE_NOT_OCCUPIED")) {
|
|
29
|
+
throw new errors$1.MtPeerNotFoundError(`Peer with phone number ${phone} was not found`);
|
|
30
|
+
} else {
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return resolvePeer._handleContactsResolvedPeer(phone, res);
|
|
35
|
+
}
|
|
36
|
+
exports.resolvePhoneNumber = resolvePhoneNumber;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { tl } from '@mtcute/tl';
|
|
3
|
+
/**
|
|
4
|
+
* Get the `InputPeer` by user's phone number.
|
|
5
|
+
* Useful when an `InputPeer` is needed in Raw API.
|
|
6
|
+
*
|
|
7
|
+
* @param phone Phone number of the user
|
|
8
|
+
* @param force Whether to force re-fetch the peer from the server
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePhoneNumber(client: ITelegramClient, phone: string, force?: boolean): Promise<tl.TypeInputPeer>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { tl } from '@mtcute/tl';
|
|
3
|
+
/**
|
|
4
|
+
* Get the `InputPeer` by user's phone number.
|
|
5
|
+
* Useful when an `InputPeer` is needed in Raw API.
|
|
6
|
+
*
|
|
7
|
+
* @param phone Phone number of the user
|
|
8
|
+
* @param force Whether to force re-fetch the peer from the server
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePhoneNumber(client: ITelegramClient, phone: string, force?: boolean): Promise<tl.TypeInputPeer>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { tl } from "@mtcute/tl";
|
|
2
|
+
import { MtArgumentError } from "../../../types/errors.js";
|
|
3
|
+
import { MtPeerNotFoundError } from "../../types/errors.js";
|
|
4
|
+
import { _handleContactsResolvedPeer } from "./resolve-peer.js";
|
|
5
|
+
async function resolvePhoneNumber(client, phone, force = false) {
|
|
6
|
+
phone = phone.replace(/[@+\s()]/g, "");
|
|
7
|
+
if (!phone.match(/^\d+$/)) {
|
|
8
|
+
throw new MtArgumentError("phone should only contain digits");
|
|
9
|
+
}
|
|
10
|
+
if (!force) {
|
|
11
|
+
const fromStorage = await client.storage.peers.getByPhone(phone);
|
|
12
|
+
if (fromStorage) return fromStorage;
|
|
13
|
+
}
|
|
14
|
+
let res;
|
|
15
|
+
try {
|
|
16
|
+
res = await client.call({
|
|
17
|
+
_: "contacts.resolvePhone",
|
|
18
|
+
phone
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
if (tl.RpcError.is(e, "PHONE_NOT_OCCUPIED")) {
|
|
22
|
+
throw new MtPeerNotFoundError(`Peer with phone number ${phone} was not found`);
|
|
23
|
+
} else {
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return _handleContactsResolvedPeer(phone, res);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
resolvePhoneNumber
|
|
31
|
+
};
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -131,14 +131,14 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
131
131
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
132
132
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
133
133
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
134
|
-
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
135
134
|
export { deleteMessages } from './methods/messages/delete-messages.js';
|
|
135
|
+
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
136
136
|
export { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages.js';
|
|
137
137
|
export { editInlineMessage } from './methods/messages/edit-inline-message.js';
|
|
138
138
|
export { editMessage } from './methods/messages/edit-message.js';
|
|
139
139
|
export { forwardMessagesById } from './methods/messages/forward-messages.js';
|
|
140
|
-
export type { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
141
140
|
export { forwardMessages } from './methods/messages/forward-messages.js';
|
|
141
|
+
export type { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
142
142
|
export { getAllScheduledMessages } from './methods/messages/get-all-scheduled-messages.js';
|
|
143
143
|
export { getAvailableMessageEffects } from './methods/messages/get-available-effects.js';
|
|
144
144
|
export { getCallbackQueryMessage } from './methods/messages/get-callback-query-message.js';
|
|
@@ -167,8 +167,8 @@ export { readReactions } from './methods/messages/read-reactions.js';
|
|
|
167
167
|
export { searchGlobal } from './methods/messages/search-global.js';
|
|
168
168
|
export type { SearchGlobalOffset } from './methods/messages/search-global.js';
|
|
169
169
|
export { searchHashtag } from './methods/messages/search-hashtag.js';
|
|
170
|
-
export type { SearchHashtagOffset } from './methods/messages/search-hashtag.js';
|
|
171
170
|
export { iterSearchHashtag } from './methods/messages/search-hashtag.js';
|
|
171
|
+
export type { SearchHashtagOffset } from './methods/messages/search-hashtag.js';
|
|
172
172
|
export { searchMessages } from './methods/messages/search-messages.js';
|
|
173
173
|
export type { SearchMessagesOffset } from './methods/messages/search-messages.js';
|
|
174
174
|
export { answerText } from './methods/messages/send-answer.js';
|
|
@@ -177,6 +177,7 @@ export { answerMediaGroup } from './methods/messages/send-answer.js';
|
|
|
177
177
|
export { commentText } from './methods/messages/send-comment.js';
|
|
178
178
|
export { commentMedia } from './methods/messages/send-comment.js';
|
|
179
179
|
export { commentMediaGroup } from './methods/messages/send-comment.js';
|
|
180
|
+
export type { CommonSendParams } from './methods/messages/send-common.js';
|
|
180
181
|
export { sendCopyGroup } from './methods/messages/send-copy-group.js';
|
|
181
182
|
export type { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
182
183
|
export { sendCopy } from './methods/messages/send-copy.js';
|
|
@@ -185,9 +186,9 @@ export { sendMediaGroup } from './methods/messages/send-media-group.js';
|
|
|
185
186
|
export { sendMedia } from './methods/messages/send-media.js';
|
|
186
187
|
export { sendPaidReaction } from './methods/messages/send-paid-reaction.js';
|
|
187
188
|
export { quoteWithText } from './methods/messages/send-quote.js';
|
|
188
|
-
export type { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
189
189
|
export { quoteWithMedia } from './methods/messages/send-quote.js';
|
|
190
190
|
export { quoteWithMediaGroup } from './methods/messages/send-quote.js';
|
|
191
|
+
export type { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
191
192
|
export { sendReaction } from './methods/messages/send-reaction.js';
|
|
192
193
|
export { replyText } from './methods/messages/send-reply.js';
|
|
193
194
|
export { replyMedia } from './methods/messages/send-reply.js';
|
|
@@ -293,6 +294,7 @@ export { resolvePeerMany } from './methods/users/resolve-peer-many.js';
|
|
|
293
294
|
export { resolvePeer } from './methods/users/resolve-peer.js';
|
|
294
295
|
export { resolveUser } from './methods/users/resolve-peer.js';
|
|
295
296
|
export { resolveChannel } from './methods/users/resolve-peer.js';
|
|
297
|
+
export { resolvePhoneNumber } from './methods/users/resolve-phone-number.js';
|
|
296
298
|
export { setMyEmojiStatus } from './methods/users/set-emoji-status.js';
|
|
297
299
|
export { setEmojiStatus } from './methods/users/set-emoji-status.js';
|
|
298
300
|
export { setGlobalTtl } from './methods/users/set-global-ttl.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -131,14 +131,14 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
131
131
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
132
132
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
133
133
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
134
|
-
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
135
134
|
export { deleteMessages } from './methods/messages/delete-messages.js';
|
|
135
|
+
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
136
136
|
export { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages.js';
|
|
137
137
|
export { editInlineMessage } from './methods/messages/edit-inline-message.js';
|
|
138
138
|
export { editMessage } from './methods/messages/edit-message.js';
|
|
139
139
|
export { forwardMessagesById } from './methods/messages/forward-messages.js';
|
|
140
|
-
export type { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
141
140
|
export { forwardMessages } from './methods/messages/forward-messages.js';
|
|
141
|
+
export type { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
142
142
|
export { getAllScheduledMessages } from './methods/messages/get-all-scheduled-messages.js';
|
|
143
143
|
export { getAvailableMessageEffects } from './methods/messages/get-available-effects.js';
|
|
144
144
|
export { getCallbackQueryMessage } from './methods/messages/get-callback-query-message.js';
|
|
@@ -167,8 +167,8 @@ export { readReactions } from './methods/messages/read-reactions.js';
|
|
|
167
167
|
export { searchGlobal } from './methods/messages/search-global.js';
|
|
168
168
|
export type { SearchGlobalOffset } from './methods/messages/search-global.js';
|
|
169
169
|
export { searchHashtag } from './methods/messages/search-hashtag.js';
|
|
170
|
-
export type { SearchHashtagOffset } from './methods/messages/search-hashtag.js';
|
|
171
170
|
export { iterSearchHashtag } from './methods/messages/search-hashtag.js';
|
|
171
|
+
export type { SearchHashtagOffset } from './methods/messages/search-hashtag.js';
|
|
172
172
|
export { searchMessages } from './methods/messages/search-messages.js';
|
|
173
173
|
export type { SearchMessagesOffset } from './methods/messages/search-messages.js';
|
|
174
174
|
export { answerText } from './methods/messages/send-answer.js';
|
|
@@ -177,6 +177,7 @@ export { answerMediaGroup } from './methods/messages/send-answer.js';
|
|
|
177
177
|
export { commentText } from './methods/messages/send-comment.js';
|
|
178
178
|
export { commentMedia } from './methods/messages/send-comment.js';
|
|
179
179
|
export { commentMediaGroup } from './methods/messages/send-comment.js';
|
|
180
|
+
export type { CommonSendParams } from './methods/messages/send-common.js';
|
|
180
181
|
export { sendCopyGroup } from './methods/messages/send-copy-group.js';
|
|
181
182
|
export type { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
182
183
|
export { sendCopy } from './methods/messages/send-copy.js';
|
|
@@ -185,9 +186,9 @@ export { sendMediaGroup } from './methods/messages/send-media-group.js';
|
|
|
185
186
|
export { sendMedia } from './methods/messages/send-media.js';
|
|
186
187
|
export { sendPaidReaction } from './methods/messages/send-paid-reaction.js';
|
|
187
188
|
export { quoteWithText } from './methods/messages/send-quote.js';
|
|
188
|
-
export type { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
189
189
|
export { quoteWithMedia } from './methods/messages/send-quote.js';
|
|
190
190
|
export { quoteWithMediaGroup } from './methods/messages/send-quote.js';
|
|
191
|
+
export type { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
191
192
|
export { sendReaction } from './methods/messages/send-reaction.js';
|
|
192
193
|
export { replyText } from './methods/messages/send-reply.js';
|
|
193
194
|
export { replyMedia } from './methods/messages/send-reply.js';
|
|
@@ -293,6 +294,7 @@ export { resolvePeerMany } from './methods/users/resolve-peer-many.js';
|
|
|
293
294
|
export { resolvePeer } from './methods/users/resolve-peer.js';
|
|
294
295
|
export { resolveUser } from './methods/users/resolve-peer.js';
|
|
295
296
|
export { resolveChannel } from './methods/users/resolve-peer.js';
|
|
297
|
+
export { resolvePhoneNumber } from './methods/users/resolve-phone-number.js';
|
|
296
298
|
export { setMyEmojiStatus } from './methods/users/set-emoji-status.js';
|
|
297
299
|
export { setEmojiStatus } from './methods/users/set-emoji-status.js';
|
|
298
300
|
export { setGlobalTtl } from './methods/users/set-global-ttl.js';
|
|
@@ -10,8 +10,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
10
10
|
/**
|
|
11
11
|
* Type that can be used as an input peer to most of the high-level methods. Can be:
|
|
12
12
|
* - `number`, representing peer's marked ID*
|
|
13
|
-
* - `string`, representing
|
|
14
|
-
* - `string`, representing user's phone number
|
|
13
|
+
* - `string`, representing user's username
|
|
15
14
|
* - `"me"` and `"self"` which will be replaced with the current user/bot
|
|
16
15
|
* - Any object with `inputPeer: tl.TypeInputPeer` property
|
|
17
16
|
* - Raw TL object
|
|
@@ -19,7 +18,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
19
18
|
* > * Telegram has moved to int64 IDs. Though, Levin [has confirmed](https://t.me/tdlibchat/25071)
|
|
20
19
|
* > that new IDs *will* still fit into int53, meaning JS integers are fine.
|
|
21
20
|
*/
|
|
22
|
-
export type InputPeerLike = string | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
21
|
+
export type InputPeerLike = 'me' | 'self' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
23
22
|
inputPeer: tl.TypeInputPeer;
|
|
24
23
|
};
|
|
25
24
|
/**
|
|
@@ -10,8 +10,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
10
10
|
/**
|
|
11
11
|
* Type that can be used as an input peer to most of the high-level methods. Can be:
|
|
12
12
|
* - `number`, representing peer's marked ID*
|
|
13
|
-
* - `string`, representing
|
|
14
|
-
* - `string`, representing user's phone number
|
|
13
|
+
* - `string`, representing user's username
|
|
15
14
|
* - `"me"` and `"self"` which will be replaced with the current user/bot
|
|
16
15
|
* - Any object with `inputPeer: tl.TypeInputPeer` property
|
|
17
16
|
* - Raw TL object
|
|
@@ -19,7 +18,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
19
18
|
* > * Telegram has moved to int64 IDs. Though, Levin [has confirmed](https://t.me/tdlibchat/25071)
|
|
20
19
|
* > that new IDs *will* still fit into int53, meaning JS integers are fine.
|
|
21
20
|
*/
|
|
22
|
-
export type InputPeerLike = string | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
21
|
+
export type InputPeerLike = 'me' | 'self' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
23
22
|
inputPeer: tl.TypeInputPeer;
|
|
24
23
|
};
|
|
25
24
|
/**
|
|
@@ -85,10 +85,11 @@ class StarGiftUniqueOriginalDetails {
|
|
|
85
85
|
/**
|
|
86
86
|
* Peer who received the original star gift, if available
|
|
87
87
|
*
|
|
88
|
-
* > Note: {@link recipientId} is always available. If ID is available, but this field
|
|
88
|
+
* > Note: {@link recipientId} is always available. If ID is available, but this field is null,
|
|
89
89
|
* > you should try fetching the peer manually using {@link getPeer})
|
|
90
90
|
*/
|
|
91
91
|
get recipient() {
|
|
92
|
+
if (!this._peers.has(this.raw.recipientId)) return null;
|
|
92
93
|
return peer.parsePeer(this.raw.recipientId, this._peers);
|
|
93
94
|
}
|
|
94
95
|
/** ID of the peer who received the original star gift */
|
|
@@ -45,10 +45,10 @@ export declare class StarGiftUniqueOriginalDetails {
|
|
|
45
45
|
/**
|
|
46
46
|
* Peer who received the original star gift, if available
|
|
47
47
|
*
|
|
48
|
-
* > Note: {@link recipientId} is always available. If ID is available, but this field
|
|
48
|
+
* > Note: {@link recipientId} is always available. If ID is available, but this field is null,
|
|
49
49
|
* > you should try fetching the peer manually using {@link getPeer})
|
|
50
50
|
*/
|
|
51
|
-
get recipient(): Peer;
|
|
51
|
+
get recipient(): Peer | null;
|
|
52
52
|
/** ID of the peer who received the original star gift */
|
|
53
53
|
get recipientId(): number;
|
|
54
54
|
/** Date when the original star gift was sent */
|
|
@@ -45,10 +45,10 @@ export declare class StarGiftUniqueOriginalDetails {
|
|
|
45
45
|
/**
|
|
46
46
|
* Peer who received the original star gift, if available
|
|
47
47
|
*
|
|
48
|
-
* > Note: {@link recipientId} is always available. If ID is available, but this field
|
|
48
|
+
* > Note: {@link recipientId} is always available. If ID is available, but this field is null,
|
|
49
49
|
* > you should try fetching the peer manually using {@link getPeer})
|
|
50
50
|
*/
|
|
51
|
-
get recipient(): Peer;
|
|
51
|
+
get recipient(): Peer | null;
|
|
52
52
|
/** ID of the peer who received the original star gift */
|
|
53
53
|
get recipientId(): number;
|
|
54
54
|
/** Date when the original star gift was sent */
|
|
@@ -78,10 +78,11 @@ class StarGiftUniqueOriginalDetails {
|
|
|
78
78
|
/**
|
|
79
79
|
* Peer who received the original star gift, if available
|
|
80
80
|
*
|
|
81
|
-
* > Note: {@link recipientId} is always available. If ID is available, but this field
|
|
81
|
+
* > Note: {@link recipientId} is always available. If ID is available, but this field is null,
|
|
82
82
|
* > you should try fetching the peer manually using {@link getPeer})
|
|
83
83
|
*/
|
|
84
84
|
get recipient() {
|
|
85
|
+
if (!this._peers.has(this.raw.recipientId)) return null;
|
|
85
86
|
return parsePeer(this.raw.recipientId, this._peers);
|
|
86
87
|
}
|
|
87
88
|
/** ID of the peer who received the original star gift */
|
|
@@ -128,8 +128,8 @@ export type StarsTransactionType = {
|
|
|
128
128
|
gift: StarGiftUnique;
|
|
129
129
|
} | {
|
|
130
130
|
type: 'star_gift_transfer';
|
|
131
|
-
/**
|
|
132
|
-
|
|
131
|
+
/** Recipient peer */
|
|
132
|
+
recipient: Peer;
|
|
133
133
|
/** The upgraded gift */
|
|
134
134
|
gift: StarGiftUnique;
|
|
135
135
|
} | {
|
|
@@ -128,8 +128,8 @@ export type StarsTransactionType = {
|
|
|
128
128
|
gift: StarGiftUnique;
|
|
129
129
|
} | {
|
|
130
130
|
type: 'star_gift_transfer';
|
|
131
|
-
/**
|
|
132
|
-
|
|
131
|
+
/** Recipient peer */
|
|
132
|
+
recipient: Peer;
|
|
133
133
|
/** The upgraded gift */
|
|
134
134
|
gift: StarGiftUnique;
|
|
135
135
|
} | {
|