@mtcute/core 0.24.1 → 0.24.3
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 +7 -0
- package/client.js +8 -1
- package/highlevel/client.d.cts +17 -0
- package/highlevel/client.d.ts +17 -0
- package/highlevel/methods/chats/get-message-author.cjs +20 -0
- package/highlevel/methods/chats/get-message-author.d.cts +3 -0
- package/highlevel/methods/chats/get-message-author.d.ts +3 -0
- package/highlevel/methods/chats/get-message-author.js +15 -0
- package/highlevel/methods/forums/toggle-forum.cjs +12 -1
- package/highlevel/methods/forums/toggle-forum.d.cts +14 -0
- package/highlevel/methods/forums/toggle-forum.d.ts +14 -0
- package/highlevel/methods/forums/toggle-forum.js +13 -2
- package/highlevel/methods/messages/forward-messages.cjs +9 -2
- package/highlevel/methods/messages/forward-messages.d.cts +7 -0
- package/highlevel/methods/messages/forward-messages.d.ts +7 -0
- package/highlevel/methods/messages/forward-messages.js +9 -2
- package/highlevel/methods/messages/send-common.cjs +7 -1
- package/highlevel/methods/messages/send-common.d.cts +7 -0
- package/highlevel/methods/messages/send-common.d.ts +7 -0
- package/highlevel/methods/messages/send-common.js +7 -1
- package/highlevel/methods.d.cts +2 -0
- package/highlevel/methods.d.ts +2 -0
- package/highlevel/types/media/input-media/factories.cjs +1 -0
- package/highlevel/types/media/input-media/factories.js +1 -0
- package/highlevel/types/messages/message-action.d.cts +2 -0
- package/highlevel/types/messages/message-action.d.ts +2 -0
- package/highlevel/types/peers/chat.cjs +19 -0
- package/highlevel/types/peers/chat.d.cts +13 -1
- package/highlevel/types/peers/chat.d.ts +13 -1
- package/highlevel/types/peers/chat.js +19 -0
- package/highlevel/types/peers/full-chat.cjs +10 -0
- package/highlevel/types/peers/full-chat.d.cts +6 -0
- package/highlevel/types/peers/full-chat.d.ts +6 -0
- package/highlevel/types/peers/full-chat.js +10 -0
- package/highlevel/types/peers/peer.d.cts +1 -1
- package/highlevel/types/peers/peer.d.ts +1 -1
- package/highlevel/types/updates/history-read-update.cjs +21 -0
- package/highlevel/types/updates/history-read-update.d.cts +7 -2
- package/highlevel/types/updates/history-read-update.d.ts +7 -2
- package/highlevel/types/updates/history-read-update.js +21 -0
- package/highlevel/updates/manager.cjs +10 -1
- package/highlevel/updates/manager.js +12 -3
- package/methods.cjs +3 -0
- package/methods.js +4 -1
- package/network/middlewares/internal-errors.cjs +3 -0
- package/network/middlewares/internal-errors.js +3 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/persistent-connection.cjs +2 -1
- package/network/persistent-connection.js +3 -2
- package/network/server-salt.cjs +12 -2
- package/network/server-salt.js +12 -2
- package/package.json +7 -7
- package/utils/binary/compat.cjs +4 -0
- package/utils/binary/compat.js +4 -0
- package/utils/peer-utils.cjs +2 -8
- package/utils/peer-utils.js +3 -9
|
@@ -138,6 +138,12 @@ export declare class FullChat extends Chat {
|
|
|
138
138
|
* - for supergroups: the linked channel
|
|
139
139
|
*/
|
|
140
140
|
get linkedChat(): Chat | null;
|
|
141
|
+
/**
|
|
142
|
+
* Information about a linked monoforum chat:
|
|
143
|
+
* - for channels: the linked monoforum
|
|
144
|
+
* - for monoforums: the channel this monoforum is linked to
|
|
145
|
+
*/
|
|
146
|
+
get monoforumLinkedChat(): Chat | null;
|
|
141
147
|
/**
|
|
142
148
|
* TTL of all messages in this chat, in seconds
|
|
143
149
|
*/
|
|
@@ -246,6 +246,16 @@ class FullChat extends Chat$2 {
|
|
|
246
246
|
if (!this.full.linkedChatId) return null;
|
|
247
247
|
return new Chat$2(this.peers.chat(this.full.linkedChatId));
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Information about a linked monoforum chat:
|
|
251
|
+
* - for channels: the linked monoforum
|
|
252
|
+
* - for monoforums: the channel this monoforum is linked to
|
|
253
|
+
*/
|
|
254
|
+
get monoforumLinkedChat() {
|
|
255
|
+
if (this.raw._ !== "channel") return null;
|
|
256
|
+
if (!this.raw.linkedMonoforumId) return null;
|
|
257
|
+
return new Chat$2(this.peers.chat(this.raw.linkedMonoforumId));
|
|
258
|
+
}
|
|
249
259
|
/**
|
|
250
260
|
* TTL of all messages in this chat, in seconds
|
|
251
261
|
*/
|
|
@@ -18,7 +18,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
18
18
|
* > * Telegram has moved to int64 IDs. Though, Levin [has confirmed](https://t.me/tdlibchat/25071)
|
|
19
19
|
* > that new IDs *will* still fit into int53, meaning JS integers are fine.
|
|
20
20
|
*/
|
|
21
|
-
export type InputPeerLike = 'me' | 'self' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
21
|
+
export type InputPeerLike = 'me' | 'self' | 'some_username' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
22
22
|
inputPeer: tl.TypeInputPeer;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -18,7 +18,7 @@ export type PeerType = 'user' | 'bot' | 'group' | 'channel' | 'supergroup';
|
|
|
18
18
|
* > * Telegram has moved to int64 IDs. Though, Levin [has confirmed](https://t.me/tdlibchat/25071)
|
|
19
19
|
* > that new IDs *will* still fit into int53, meaning JS integers are fine.
|
|
20
20
|
*/
|
|
21
|
-
export type InputPeerLike = 'me' | 'self' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
21
|
+
export type InputPeerLike = 'me' | 'self' | 'some_username' | (string & {}) | number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel | {
|
|
22
22
|
inputPeer: tl.TypeInputPeer;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -38,6 +38,19 @@ class HistoryReadUpdate {
|
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether this update is about messages in a "monoforum"
|
|
43
|
+
* (i.e. a chat used for "direct channel messages")
|
|
44
|
+
*/
|
|
45
|
+
get isMonoForum() {
|
|
46
|
+
switch (this.raw._) {
|
|
47
|
+
case "updateReadMonoForumOutbox":
|
|
48
|
+
case "updateReadMonoForumInbox":
|
|
49
|
+
return true;
|
|
50
|
+
default:
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
41
54
|
/**
|
|
42
55
|
* Marked peer ID of the chat where the messages were read.
|
|
43
56
|
*/
|
|
@@ -50,6 +63,8 @@ class HistoryReadUpdate {
|
|
|
50
63
|
case "updateReadChannelInbox":
|
|
51
64
|
case "updateReadChannelDiscussionOutbox":
|
|
52
65
|
case "updateReadChannelDiscussionInbox":
|
|
66
|
+
case "updateReadMonoForumOutbox":
|
|
67
|
+
case "updateReadMonoForumInbox":
|
|
53
68
|
return peerUtils.toggleChannelIdMark(this.raw.channelId);
|
|
54
69
|
}
|
|
55
70
|
}
|
|
@@ -69,6 +84,8 @@ class HistoryReadUpdate {
|
|
|
69
84
|
case "updateReadHistoryOutbox":
|
|
70
85
|
case "updateReadChannelOutbox":
|
|
71
86
|
case "updateReadChannelDiscussionOutbox":
|
|
87
|
+
case "updateReadMonoForumOutbox":
|
|
88
|
+
case "updateReadMonoForumInbox":
|
|
72
89
|
return 0;
|
|
73
90
|
}
|
|
74
91
|
}
|
|
@@ -87,6 +104,8 @@ class HistoryReadUpdate {
|
|
|
87
104
|
return this.raw.maxId;
|
|
88
105
|
case "updateReadChannelDiscussionOutbox":
|
|
89
106
|
case "updateReadChannelDiscussionInbox":
|
|
107
|
+
case "updateReadMonoForumInbox":
|
|
108
|
+
case "updateReadMonoForumOutbox":
|
|
90
109
|
return this.raw.readMaxId;
|
|
91
110
|
}
|
|
92
111
|
}
|
|
@@ -101,6 +120,8 @@ class HistoryReadUpdate {
|
|
|
101
120
|
case "updateReadHistoryInbox":
|
|
102
121
|
case "updateReadChannelOutbox":
|
|
103
122
|
case "updateReadChannelInbox":
|
|
123
|
+
case "updateReadMonoForumInbox":
|
|
124
|
+
case "updateReadMonoForumOutbox":
|
|
104
125
|
return 0;
|
|
105
126
|
case "updateReadChannelDiscussionOutbox":
|
|
106
127
|
case "updateReadChannelDiscussionInbox":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tl } from '@mtcute/tl';
|
|
2
2
|
export declare class HistoryReadUpdate {
|
|
3
|
-
readonly raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox;
|
|
4
|
-
constructor(raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox);
|
|
3
|
+
readonly raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox | tl.RawUpdateReadMonoForumInbox | tl.RawUpdateReadMonoForumOutbox;
|
|
4
|
+
constructor(raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox | tl.RawUpdateReadMonoForumInbox | tl.RawUpdateReadMonoForumOutbox);
|
|
5
5
|
/**
|
|
6
6
|
* Whether this update is about an "outbox" read
|
|
7
7
|
* (i.e. a message you have sent earlier was read)
|
|
@@ -12,6 +12,11 @@ export declare class HistoryReadUpdate {
|
|
|
12
12
|
* (e.g. a comments thread or a topic in a forum)
|
|
13
13
|
*/
|
|
14
14
|
get isDiscussion(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether this update is about messages in a "monoforum"
|
|
17
|
+
* (i.e. a chat used for "direct channel messages")
|
|
18
|
+
*/
|
|
19
|
+
get isMonoForum(): boolean;
|
|
15
20
|
/**
|
|
16
21
|
* Marked peer ID of the chat where the messages were read.
|
|
17
22
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tl } from '@mtcute/tl';
|
|
2
2
|
export declare class HistoryReadUpdate {
|
|
3
|
-
readonly raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox;
|
|
4
|
-
constructor(raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox);
|
|
3
|
+
readonly raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox | tl.RawUpdateReadMonoForumInbox | tl.RawUpdateReadMonoForumOutbox;
|
|
4
|
+
constructor(raw: tl.RawUpdateReadHistoryInbox | tl.RawUpdateReadHistoryOutbox | tl.RawUpdateReadChannelInbox | tl.RawUpdateReadChannelOutbox | tl.RawUpdateReadChannelDiscussionInbox | tl.RawUpdateReadChannelDiscussionOutbox | tl.RawUpdateReadMonoForumInbox | tl.RawUpdateReadMonoForumOutbox);
|
|
5
5
|
/**
|
|
6
6
|
* Whether this update is about an "outbox" read
|
|
7
7
|
* (i.e. a message you have sent earlier was read)
|
|
@@ -12,6 +12,11 @@ export declare class HistoryReadUpdate {
|
|
|
12
12
|
* (e.g. a comments thread or a topic in a forum)
|
|
13
13
|
*/
|
|
14
14
|
get isDiscussion(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether this update is about messages in a "monoforum"
|
|
17
|
+
* (i.e. a chat used for "direct channel messages")
|
|
18
|
+
*/
|
|
19
|
+
get isMonoForum(): boolean;
|
|
15
20
|
/**
|
|
16
21
|
* Marked peer ID of the chat where the messages were read.
|
|
17
22
|
*/
|
|
@@ -31,6 +31,19 @@ class HistoryReadUpdate {
|
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether this update is about messages in a "monoforum"
|
|
36
|
+
* (i.e. a chat used for "direct channel messages")
|
|
37
|
+
*/
|
|
38
|
+
get isMonoForum() {
|
|
39
|
+
switch (this.raw._) {
|
|
40
|
+
case "updateReadMonoForumOutbox":
|
|
41
|
+
case "updateReadMonoForumInbox":
|
|
42
|
+
return true;
|
|
43
|
+
default:
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
/**
|
|
35
48
|
* Marked peer ID of the chat where the messages were read.
|
|
36
49
|
*/
|
|
@@ -43,6 +56,8 @@ class HistoryReadUpdate {
|
|
|
43
56
|
case "updateReadChannelInbox":
|
|
44
57
|
case "updateReadChannelDiscussionOutbox":
|
|
45
58
|
case "updateReadChannelDiscussionInbox":
|
|
59
|
+
case "updateReadMonoForumOutbox":
|
|
60
|
+
case "updateReadMonoForumInbox":
|
|
46
61
|
return toggleChannelIdMark(this.raw.channelId);
|
|
47
62
|
}
|
|
48
63
|
}
|
|
@@ -62,6 +77,8 @@ class HistoryReadUpdate {
|
|
|
62
77
|
case "updateReadHistoryOutbox":
|
|
63
78
|
case "updateReadChannelOutbox":
|
|
64
79
|
case "updateReadChannelDiscussionOutbox":
|
|
80
|
+
case "updateReadMonoForumOutbox":
|
|
81
|
+
case "updateReadMonoForumInbox":
|
|
65
82
|
return 0;
|
|
66
83
|
}
|
|
67
84
|
}
|
|
@@ -80,6 +97,8 @@ class HistoryReadUpdate {
|
|
|
80
97
|
return this.raw.maxId;
|
|
81
98
|
case "updateReadChannelDiscussionOutbox":
|
|
82
99
|
case "updateReadChannelDiscussionInbox":
|
|
100
|
+
case "updateReadMonoForumInbox":
|
|
101
|
+
case "updateReadMonoForumOutbox":
|
|
83
102
|
return this.raw.readMaxId;
|
|
84
103
|
}
|
|
85
104
|
}
|
|
@@ -94,6 +113,8 @@ class HistoryReadUpdate {
|
|
|
94
113
|
case "updateReadHistoryInbox":
|
|
95
114
|
case "updateReadChannelOutbox":
|
|
96
115
|
case "updateReadChannelInbox":
|
|
116
|
+
case "updateReadMonoForumInbox":
|
|
117
|
+
case "updateReadMonoForumOutbox":
|
|
97
118
|
return 0;
|
|
98
119
|
case "updateReadChannelDiscussionOutbox":
|
|
99
120
|
case "updateReadChannelDiscussionInbox":
|
|
@@ -216,7 +216,11 @@ class UpdatesManager {
|
|
|
216
216
|
utils$1.assertNever();
|
|
217
217
|
}
|
|
218
218
|
if (this.pendingUpdateContainers.length % WARN_EVERY === 0) {
|
|
219
|
-
|
|
219
|
+
if (this.updatesLoopActive) {
|
|
220
|
+
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
221
|
+
} else {
|
|
222
|
+
this.log.warn("%d pending update containers, can't keep up!", this.pendingUpdateContainers.length);
|
|
223
|
+
}
|
|
220
224
|
}
|
|
221
225
|
this.updatesLoopCv.notify();
|
|
222
226
|
}
|
|
@@ -946,6 +950,11 @@ class UpdatesManager {
|
|
|
946
950
|
this.log.warn("cannot fetch full peer %d - getPeerById returned null", id);
|
|
947
951
|
return;
|
|
948
952
|
}
|
|
953
|
+
if (peerUtils$1.isInputPeerChannel(peer)) {
|
|
954
|
+
return batchedQueries._getChannelsBatched(client, peerUtils$1.toInputChannel(peer));
|
|
955
|
+
} else if (peerUtils$1.isInputPeerUser(peer)) {
|
|
956
|
+
return batchedQueries._getUsersBatched(client, peerUtils$1.toInputUser(peer));
|
|
957
|
+
}
|
|
949
958
|
log.warn("cannot fetch full peer %d - unknown peer type %s", id, peer._);
|
|
950
959
|
}).catch((err) => {
|
|
951
960
|
log.warn("error fetching full peer %d: %e", id, err);
|
|
@@ -7,11 +7,11 @@ import { EarlyTimer } from "../../utils/early-timer.js";
|
|
|
7
7
|
import { toggleChannelIdMark, parseMarkedPeerId, getBarePeerId, getMarkedPeerId } from "../../utils/peer-utils.js";
|
|
8
8
|
import { SortedArray } from "../../utils/sorted-array.js";
|
|
9
9
|
import "@mtcute/tl-runtime";
|
|
10
|
-
import { _getChannelsBatched } from "../methods/chats/batched-queries.js";
|
|
10
|
+
import { _getChannelsBatched, _getUsersBatched } from "../methods/chats/batched-queries.js";
|
|
11
11
|
import { PeersIndex } from "../types/peers/peers-index.js";
|
|
12
12
|
import { RawUpdateInfo } from "./types.js";
|
|
13
13
|
import { toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate } from "./utils.js";
|
|
14
|
-
import { toInputChannel } from "../utils/peer-utils.js";
|
|
14
|
+
import { toInputChannel, isInputPeerChannel, isInputPeerUser, toInputUser } from "../utils/peer-utils.js";
|
|
15
15
|
const WARN_EVERY = 100;
|
|
16
16
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
17
17
|
const UPDATES_TOO_LONG = { _: "updatesTooLong" };
|
|
@@ -209,7 +209,11 @@ class UpdatesManager {
|
|
|
209
209
|
assertNever();
|
|
210
210
|
}
|
|
211
211
|
if (this.pendingUpdateContainers.length % WARN_EVERY === 0) {
|
|
212
|
-
|
|
212
|
+
if (this.updatesLoopActive) {
|
|
213
|
+
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
214
|
+
} else {
|
|
215
|
+
this.log.warn("%d pending update containers, can't keep up!", this.pendingUpdateContainers.length);
|
|
216
|
+
}
|
|
213
217
|
}
|
|
214
218
|
this.updatesLoopCv.notify();
|
|
215
219
|
}
|
|
@@ -939,6 +943,11 @@ class UpdatesManager {
|
|
|
939
943
|
this.log.warn("cannot fetch full peer %d - getPeerById returned null", id);
|
|
940
944
|
return;
|
|
941
945
|
}
|
|
946
|
+
if (isInputPeerChannel(peer)) {
|
|
947
|
+
return _getChannelsBatched(client, toInputChannel(peer));
|
|
948
|
+
} else if (isInputPeerUser(peer)) {
|
|
949
|
+
return _getUsersBatched(client, toInputUser(peer));
|
|
950
|
+
}
|
|
942
951
|
log.warn("cannot fetch full peer %d - unknown peer type %s", id, peer._);
|
|
943
952
|
}).catch((err) => {
|
|
944
953
|
log.warn("error fetching full peer %d: %e", id, err);
|
package/methods.cjs
CHANGED
|
@@ -55,6 +55,7 @@ const getChatPreview = require("./highlevel/methods/chats/get-chat-preview.cjs")
|
|
|
55
55
|
const getChat = require("./highlevel/methods/chats/get-chat.cjs");
|
|
56
56
|
const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
|
|
57
57
|
const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
|
|
58
|
+
const getMessageAuthor = require("./highlevel/methods/chats/get-message-author.cjs");
|
|
58
59
|
const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
|
|
59
60
|
const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
|
|
60
61
|
const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
|
|
@@ -322,6 +323,7 @@ exports.getChatPreview = getChatPreview.getChatPreview;
|
|
|
322
323
|
exports.getChat = getChat.getChat;
|
|
323
324
|
exports.getFullChat = getFullChat.getFullChat;
|
|
324
325
|
exports.getFullUser = getFullUser.getFullUser;
|
|
326
|
+
exports.getMessageAuthor = getMessageAuthor.getMessageAuthor;
|
|
325
327
|
exports.getNearbyChats = getNearbyChats.getNearbyChats;
|
|
326
328
|
exports.getPeer = getPeer.getPeer;
|
|
327
329
|
exports.getSimilarChannels = getSimilarChannels.getSimilarChannels;
|
|
@@ -383,6 +385,7 @@ exports.reorderPinnedForumTopics = reorderPinnedForumTopics.reorderPinnedForumTo
|
|
|
383
385
|
exports.toggleForumTopicClosed = toggleForumTopicClosed.toggleForumTopicClosed;
|
|
384
386
|
exports.toggleForumTopicPinned = toggleForumTopicPinned.toggleForumTopicPinned;
|
|
385
387
|
exports.toggleForum = toggleForum.toggleForum;
|
|
388
|
+
exports.updateForumSettings = toggleForum.updateForumSettings;
|
|
386
389
|
exports.toggleGeneralTopicHidden = toggleGeneralTopicHidden.toggleGeneralTopicHidden;
|
|
387
390
|
exports.createInviteLink = createInviteLink.createInviteLink;
|
|
388
391
|
exports.editInviteLink = editInviteLink.editInviteLink;
|
package/methods.js
CHANGED
|
@@ -48,6 +48,7 @@ import { getChatPreview } from "./highlevel/methods/chats/get-chat-preview.js";
|
|
|
48
48
|
import { getChat } from "./highlevel/methods/chats/get-chat.js";
|
|
49
49
|
import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
|
|
50
50
|
import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
|
|
51
|
+
import { getMessageAuthor } from "./highlevel/methods/chats/get-message-author.js";
|
|
51
52
|
import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
|
|
52
53
|
import { getPeer } from "./highlevel/methods/chats/get-peer.js";
|
|
53
54
|
import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
|
|
@@ -107,7 +108,7 @@ import { iterForumTopics } from "./highlevel/methods/forums/iter-forum-topics.js
|
|
|
107
108
|
import { reorderPinnedForumTopics } from "./highlevel/methods/forums/reorder-pinned-forum-topics.js";
|
|
108
109
|
import { toggleForumTopicClosed } from "./highlevel/methods/forums/toggle-forum-topic-closed.js";
|
|
109
110
|
import { toggleForumTopicPinned } from "./highlevel/methods/forums/toggle-forum-topic-pinned.js";
|
|
110
|
-
import { toggleForum } from "./highlevel/methods/forums/toggle-forum.js";
|
|
111
|
+
import { toggleForum, updateForumSettings } from "./highlevel/methods/forums/toggle-forum.js";
|
|
111
112
|
import { toggleGeneralTopicHidden } from "./highlevel/methods/forums/toggle-general-topic-hidden.js";
|
|
112
113
|
import { createInviteLink } from "./highlevel/methods/invite-links/create-invite-link.js";
|
|
113
114
|
import { editInviteLink } from "./highlevel/methods/invite-links/edit-invite-link.js";
|
|
@@ -374,6 +375,7 @@ export {
|
|
|
374
375
|
getInviteLinkMembers,
|
|
375
376
|
getInviteLinks,
|
|
376
377
|
getMe,
|
|
378
|
+
getMessageAuthor,
|
|
377
379
|
getMessageByLink,
|
|
378
380
|
getMessageGroup,
|
|
379
381
|
getMessageReactions,
|
|
@@ -547,6 +549,7 @@ export {
|
|
|
547
549
|
unblockUser,
|
|
548
550
|
unpinAllMessages,
|
|
549
551
|
unpinMessage,
|
|
552
|
+
updateForumSettings,
|
|
550
553
|
updateProfile,
|
|
551
554
|
upgradeStarGift,
|
|
552
555
|
uploadFile,
|
|
@@ -24,11 +24,13 @@ function internalErrorsHandler(params) {
|
|
|
24
24
|
const exceptErrorsSet = exceptErrors ? new Set(exceptErrors) : void 0;
|
|
25
25
|
return async (ctx, next) => {
|
|
26
26
|
const numRetries = ctx.params?.maxRetryCount ?? maxRetries;
|
|
27
|
+
let lastError;
|
|
27
28
|
for (let i = 0; i <= numRetries; i++) {
|
|
28
29
|
const res = await next(ctx);
|
|
29
30
|
if (!typeAssertions.isTlRpcError(res)) return res;
|
|
30
31
|
if (!CLIENT_ERRORS.has(res.errorCode)) {
|
|
31
32
|
if (exceptErrorsSet?.has(res.errorMessage)) return res;
|
|
33
|
+
lastError = res;
|
|
32
34
|
if (ctx.params?.throw503 && res.errorCode === -503) {
|
|
33
35
|
throw new errors.MtTimeoutError();
|
|
34
36
|
}
|
|
@@ -49,6 +51,7 @@ function internalErrorsHandler(params) {
|
|
|
49
51
|
}
|
|
50
52
|
return res;
|
|
51
53
|
}
|
|
54
|
+
return lastError;
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
exports.internalErrorsHandler = internalErrorsHandler;
|
|
@@ -17,11 +17,13 @@ function internalErrorsHandler(params) {
|
|
|
17
17
|
const exceptErrorsSet = exceptErrors ? new Set(exceptErrors) : void 0;
|
|
18
18
|
return async (ctx, next) => {
|
|
19
19
|
const numRetries = ctx.params?.maxRetryCount ?? maxRetries;
|
|
20
|
+
let lastError;
|
|
20
21
|
for (let i = 0; i <= numRetries; i++) {
|
|
21
22
|
const res = await next(ctx);
|
|
22
23
|
if (!isTlRpcError(res)) return res;
|
|
23
24
|
if (!CLIENT_ERRORS.has(res.errorCode)) {
|
|
24
25
|
if (exceptErrorsSet?.has(res.errorMessage)) return res;
|
|
26
|
+
lastError = res;
|
|
25
27
|
if (ctx.params?.throw503 && res.errorCode === -503) {
|
|
26
28
|
throw new MtTimeoutError();
|
|
27
29
|
}
|
|
@@ -42,6 +44,7 @@ function internalErrorsHandler(params) {
|
|
|
42
44
|
}
|
|
43
45
|
return res;
|
|
44
46
|
}
|
|
47
|
+
return lastError;
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
export {
|
|
@@ -54,7 +54,8 @@ class PersistentConnection {
|
|
|
54
54
|
const uidPrefix = `[UID ${this._uid}] `;
|
|
55
55
|
if (this._fuman.isConnected) {
|
|
56
56
|
const dc = this.params.dc;
|
|
57
|
-
|
|
57
|
+
const prettifiedIp = net.ip.prettify(dc.ipAddress, { encloseIpv6: true });
|
|
58
|
+
this.log.prefix = `${uidPrefix}[DC ${dc.id} @ ${prettifiedIp}:${dc.port}] `;
|
|
58
59
|
} else if (this._fuman.isConnecting) {
|
|
59
60
|
this.log.prefix = `${uidPrefix}[connecting] `;
|
|
60
61
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FramedReader, FramedWriter } from "@fuman/io";
|
|
2
|
-
import { PersistentConnection as PersistentConnection$1, ConnectionClosedError } from "@fuman/net";
|
|
2
|
+
import { PersistentConnection as PersistentConnection$1, ip, ConnectionClosedError } from "@fuman/net";
|
|
3
3
|
import { Emitter, timers } from "@fuman/utils";
|
|
4
4
|
let nextConnectionUid = 0;
|
|
5
5
|
class PersistentConnection {
|
|
@@ -47,7 +47,8 @@ class PersistentConnection {
|
|
|
47
47
|
const uidPrefix = `[UID ${this._uid}] `;
|
|
48
48
|
if (this._fuman.isConnected) {
|
|
49
49
|
const dc = this.params.dc;
|
|
50
|
-
|
|
50
|
+
const prettifiedIp = ip.prettify(dc.ipAddress, { encloseIpv6: true });
|
|
51
|
+
this.log.prefix = `${uidPrefix}[DC ${dc.id} @ ${prettifiedIp}:${dc.port}] `;
|
|
51
52
|
} else if (this._fuman.isConnecting) {
|
|
52
53
|
this.log.prefix = `${uidPrefix}[connecting] `;
|
|
53
54
|
} else {
|
package/network/server-salt.cjs
CHANGED
|
@@ -27,8 +27,18 @@ class ServerSaltManager {
|
|
|
27
27
|
_timer;
|
|
28
28
|
_scheduleNext() {
|
|
29
29
|
if (this._timer) utils.timers.clearTimeout(this._timer);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const now = Date.now() / 1e3;
|
|
31
|
+
let next;
|
|
32
|
+
while (this._futureSalts.length !== 0) {
|
|
33
|
+
const salt = this._futureSalts.shift();
|
|
34
|
+
if (salt.validSince <= now && now <= salt.validUntil) {
|
|
35
|
+
next = salt;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!next) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
32
42
|
this._timer = utils.timers.setTimeout(
|
|
33
43
|
() => {
|
|
34
44
|
this.currentSalt = next.salt;
|
package/network/server-salt.js
CHANGED
|
@@ -20,8 +20,18 @@ class ServerSaltManager {
|
|
|
20
20
|
_timer;
|
|
21
21
|
_scheduleNext() {
|
|
22
22
|
if (this._timer) timers.clearTimeout(this._timer);
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const now = Date.now() / 1e3;
|
|
24
|
+
let next;
|
|
25
|
+
while (this._futureSalts.length !== 0) {
|
|
26
|
+
const salt = this._futureSalts.shift();
|
|
27
|
+
if (salt.validSince <= now && now <= salt.validUntil) {
|
|
28
|
+
next = salt;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!next) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
25
35
|
this._timer = timers.setTimeout(
|
|
26
36
|
() => {
|
|
27
37
|
this.currentSalt = next.salt;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.24.
|
|
4
|
+
"version": "0.24.3",
|
|
5
5
|
"description": "Type-safe library for MTProto (Telegram API)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@fuman/io": "0.0.
|
|
10
|
-
"@fuman/net": "0.0.
|
|
11
|
-
"@fuman/utils": "0.0.
|
|
12
|
-
"@mtcute/file-id": "^0.
|
|
13
|
-
"@mtcute/tl": "^
|
|
14
|
-
"@mtcute/tl-runtime": "^0.
|
|
9
|
+
"@fuman/io": "0.0.15",
|
|
10
|
+
"@fuman/net": "0.0.15",
|
|
11
|
+
"@fuman/utils": "0.0.15",
|
|
12
|
+
"@mtcute/file-id": "^0.24.3",
|
|
13
|
+
"@mtcute/tl": "^204.0.0",
|
|
14
|
+
"@mtcute/tl-runtime": "^0.24.3",
|
|
15
15
|
"@types/events": "3.0.0",
|
|
16
16
|
"long": "5.2.3"
|
|
17
17
|
},
|
package/utils/binary/compat.cjs
CHANGED
|
@@ -73,6 +73,8 @@ function mapCompatMessageAction(obj) {
|
|
|
73
73
|
_: "messageActionStarGift",
|
|
74
74
|
gift: mapCompatStarGift(obj.gift)
|
|
75
75
|
};
|
|
76
|
+
case "messageActionPaidMessagesPrice_layer203":
|
|
77
|
+
return replaceType(obj, "messageActionPaidMessagesPrice");
|
|
76
78
|
default:
|
|
77
79
|
return obj;
|
|
78
80
|
}
|
|
@@ -93,6 +95,7 @@ function mapCompatObject(obj) {
|
|
|
93
95
|
case "messageActionStarGiftUnique_layer197":
|
|
94
96
|
case "messageActionStarGift_layer197":
|
|
95
97
|
case "messageActionStarGiftUnique_layer202":
|
|
98
|
+
case "messageActionPaidMessagesPrice_layer203":
|
|
96
99
|
return mapCompatMessageAction(obj);
|
|
97
100
|
case "userFull_layer199":
|
|
98
101
|
return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
|
|
@@ -105,6 +108,7 @@ function mapCompatObject(obj) {
|
|
|
105
108
|
emojiStatus: obj.emojiStatus ? mapCompatEmojiStatus(obj.emojiStatus) : void 0
|
|
106
109
|
};
|
|
107
110
|
case "channel_layer199":
|
|
111
|
+
case "channel_layer203":
|
|
108
112
|
return {
|
|
109
113
|
...obj,
|
|
110
114
|
_: "channel",
|
package/utils/binary/compat.js
CHANGED
|
@@ -66,6 +66,8 @@ function mapCompatMessageAction(obj) {
|
|
|
66
66
|
_: "messageActionStarGift",
|
|
67
67
|
gift: mapCompatStarGift(obj.gift)
|
|
68
68
|
};
|
|
69
|
+
case "messageActionPaidMessagesPrice_layer203":
|
|
70
|
+
return replaceType(obj, "messageActionPaidMessagesPrice");
|
|
69
71
|
default:
|
|
70
72
|
return obj;
|
|
71
73
|
}
|
|
@@ -86,6 +88,7 @@ function mapCompatObject(obj) {
|
|
|
86
88
|
case "messageActionStarGiftUnique_layer197":
|
|
87
89
|
case "messageActionStarGift_layer197":
|
|
88
90
|
case "messageActionStarGiftUnique_layer202":
|
|
91
|
+
case "messageActionPaidMessagesPrice_layer203":
|
|
89
92
|
return mapCompatMessageAction(obj);
|
|
90
93
|
case "userFull_layer199":
|
|
91
94
|
return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
|
|
@@ -98,6 +101,7 @@ function mapCompatObject(obj) {
|
|
|
98
101
|
emojiStatus: obj.emojiStatus ? mapCompatEmojiStatus(obj.emojiStatus) : void 0
|
|
99
102
|
};
|
|
100
103
|
case "channel_layer199":
|
|
104
|
+
case "channel_layer203":
|
|
101
105
|
return {
|
|
102
106
|
...obj,
|
|
103
107
|
_: "channel",
|
package/utils/peer-utils.cjs
CHANGED
|
@@ -8,11 +8,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
8
8
|
const errors = require("../types/errors.cjs");
|
|
9
9
|
const utils = require("../types/utils.cjs");
|
|
10
10
|
const ZERO_CHANNEL_ID = -1e12;
|
|
11
|
-
const ZERO_SECRET_CHAT_ID = -2e12;
|
|
12
|
-
const MAX_SECRET_CHAT_ID = -1997852516353;
|
|
13
11
|
const MIN_MARKED_CHAT_ID = -999999999999;
|
|
14
12
|
const MAX_USER_ID = 1099511627775;
|
|
15
|
-
const MIN_MARKED_CHANNEL_ID = -1997852516352;
|
|
16
13
|
function toggleChannelIdMark(id) {
|
|
17
14
|
return ZERO_CHANNEL_ID - id;
|
|
18
15
|
}
|
|
@@ -64,12 +61,9 @@ function parseMarkedPeerId(id) {
|
|
|
64
61
|
if (MIN_MARKED_CHAT_ID <= id) {
|
|
65
62
|
return ["chat", -id];
|
|
66
63
|
}
|
|
67
|
-
if (
|
|
64
|
+
if (id !== ZERO_CHANNEL_ID) {
|
|
68
65
|
return ["channel", ZERO_CHANNEL_ID - id];
|
|
69
66
|
}
|
|
70
|
-
if (MAX_SECRET_CHAT_ID >= id && id !== ZERO_SECRET_CHAT_ID) {
|
|
71
|
-
throw new errors.MtUnsupportedError("Secret chats are not supported");
|
|
72
|
-
}
|
|
73
67
|
} else if (id > 0 && id <= MAX_USER_ID) {
|
|
74
68
|
return ["user", id];
|
|
75
69
|
}
|
|
@@ -143,7 +137,7 @@ function getBasicPeerType(id) {
|
|
|
143
137
|
if (MIN_MARKED_CHAT_ID <= id) {
|
|
144
138
|
return "chat";
|
|
145
139
|
}
|
|
146
|
-
if (
|
|
140
|
+
if (id !== ZERO_CHANNEL_ID) {
|
|
147
141
|
return "channel";
|
|
148
142
|
}
|
|
149
143
|
} else if (id > 0 && id <= MAX_USER_ID) {
|
package/utils/peer-utils.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { MtArgumentError
|
|
1
|
+
import { MtArgumentError } from "../types/errors.js";
|
|
2
2
|
import { assertNever } from "../types/utils.js";
|
|
3
3
|
const ZERO_CHANNEL_ID = -1e12;
|
|
4
|
-
const ZERO_SECRET_CHAT_ID = -2e12;
|
|
5
|
-
const MAX_SECRET_CHAT_ID = -1997852516353;
|
|
6
4
|
const MIN_MARKED_CHAT_ID = -999999999999;
|
|
7
5
|
const MAX_USER_ID = 1099511627775;
|
|
8
|
-
const MIN_MARKED_CHANNEL_ID = -1997852516352;
|
|
9
6
|
function toggleChannelIdMark(id) {
|
|
10
7
|
return ZERO_CHANNEL_ID - id;
|
|
11
8
|
}
|
|
@@ -57,12 +54,9 @@ function parseMarkedPeerId(id) {
|
|
|
57
54
|
if (MIN_MARKED_CHAT_ID <= id) {
|
|
58
55
|
return ["chat", -id];
|
|
59
56
|
}
|
|
60
|
-
if (
|
|
57
|
+
if (id !== ZERO_CHANNEL_ID) {
|
|
61
58
|
return ["channel", ZERO_CHANNEL_ID - id];
|
|
62
59
|
}
|
|
63
|
-
if (MAX_SECRET_CHAT_ID >= id && id !== ZERO_SECRET_CHAT_ID) {
|
|
64
|
-
throw new MtUnsupportedError("Secret chats are not supported");
|
|
65
|
-
}
|
|
66
60
|
} else if (id > 0 && id <= MAX_USER_ID) {
|
|
67
61
|
return ["user", id];
|
|
68
62
|
}
|
|
@@ -136,7 +130,7 @@ function getBasicPeerType(id) {
|
|
|
136
130
|
if (MIN_MARKED_CHAT_ID <= id) {
|
|
137
131
|
return "chat";
|
|
138
132
|
}
|
|
139
|
-
if (
|
|
133
|
+
if (id !== ZERO_CHANNEL_ID) {
|
|
140
134
|
return "channel";
|
|
141
135
|
}
|
|
142
136
|
} else if (id > 0 && id <= MAX_USER_ID) {
|