@mtkruto/node 0.0.957 → 0.0.960
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/esm/client/0_utilities.d.ts +3 -0
- package/esm/client/0_utilities.js +20 -0
- package/esm/client/3_client.d.ts +2 -2
- package/esm/client/3_client.js +57 -16
- package/esm/constants.d.ts +1 -1
- package/esm/constants.js +1 -1
- package/esm/storage/0_storage.d.ts +16 -17
- package/esm/storage/0_storage.js +65 -131
- package/esm/storage/0_utilities.d.ts +13 -0
- package/esm/storage/0_utilities.js +62 -0
- package/esm/storage/1_storage_indexed_db.d.ts +3 -3
- package/esm/storage/1_storage_indexed_db.js +4 -3
- package/esm/storage/1_storage_local_storage.d.ts +3 -3
- package/esm/storage/1_storage_local_storage.js +13 -6
- package/esm/storage/1_storage_memory.d.ts +4 -4
- package/esm/storage/1_storage_memory.js +4 -2
- package/esm/storage/1_storage_session_storage.d.ts +3 -3
- package/esm/storage/1_storage_session_storage.js +13 -6
- package/esm/types/0_audio.d.ts +9 -0
- package/esm/types/0_chat_administrator_rights.d.ts +4 -4
- package/esm/types/0_contact.d.ts +6 -0
- package/esm/types/0_dice.d.ts +3 -0
- package/esm/types/0_force_reply.d.ts +1 -1
- package/esm/types/0_keyboard_button_poll_type.d.ts +1 -1
- package/esm/types/0_location.d.ts +7 -0
- package/esm/types/0_login_url.d.ts +3 -3
- package/esm/types/0_mask_position.d.ts +5 -0
- package/esm/types/0_message_entity.d.ts +4 -4
- package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
- package/esm/types/0_thumbnail.d.ts +2 -1
- package/esm/types/0_venue.d.ts +6 -0
- package/esm/types/0_voice.d.ts +6 -0
- package/esm/types/1_animation.d.ts +10 -0
- package/esm/types/1_chat.d.ts +18 -18
- package/esm/types/1_document.d.ts +7 -0
- package/esm/types/1_inline_keyboard_button.d.ts +7 -7
- package/esm/types/1_keyboard_button.d.ts +14 -14
- package/esm/types/1_photo.d.ts +2 -1
- package/esm/types/1_sticker.d.ts +16 -0
- package/esm/types/1_user.d.ts +7 -7
- package/esm/types/1_video.d.ts +10 -0
- package/esm/types/1_video_note.d.ts +8 -0
- package/esm/types/2_game.d.ts +7 -0
- package/esm/types/2_reply_keyboard_markup.d.ts +5 -5
- package/esm/types/3_message.d.ts +57 -25
- package/esm/types/3_message.js +0 -1
- package/package.json +1 -1
- package/script/client/0_utilities.d.ts +3 -0
- package/script/client/0_utilities.js +48 -0
- package/script/client/3_client.d.ts +2 -2
- package/script/client/3_client.js +57 -16
- package/script/constants.d.ts +1 -1
- package/script/constants.js +1 -1
- package/script/storage/0_storage.d.ts +16 -17
- package/script/storage/0_storage.js +65 -131
- package/script/storage/0_utilities.d.ts +13 -0
- package/script/storage/0_utilities.js +68 -0
- package/script/storage/1_storage_indexed_db.d.ts +3 -3
- package/script/storage/1_storage_indexed_db.js +4 -3
- package/script/storage/1_storage_local_storage.d.ts +3 -3
- package/script/storage/1_storage_local_storage.js +13 -6
- package/script/storage/1_storage_memory.d.ts +4 -4
- package/script/storage/1_storage_memory.js +4 -2
- package/script/storage/1_storage_session_storage.d.ts +3 -3
- package/script/storage/1_storage_session_storage.js +13 -6
- package/script/types/0_audio.d.ts +9 -0
- package/script/types/0_chat_administrator_rights.d.ts +4 -4
- package/script/types/0_contact.d.ts +6 -0
- package/script/types/0_dice.d.ts +3 -0
- package/script/types/0_force_reply.d.ts +1 -1
- package/script/types/0_keyboard_button_poll_type.d.ts +1 -1
- package/script/types/0_location.d.ts +7 -0
- package/script/types/0_login_url.d.ts +3 -3
- package/script/types/0_mask_position.d.ts +5 -0
- package/script/types/0_message_entity.d.ts +4 -4
- package/script/types/0_reply_keyboard_remove.d.ts +1 -1
- package/script/types/0_thumbnail.d.ts +2 -1
- package/script/types/0_venue.d.ts +6 -0
- package/script/types/0_voice.d.ts +6 -0
- package/script/types/1_animation.d.ts +10 -0
- package/script/types/1_chat.d.ts +18 -18
- package/script/types/1_document.d.ts +7 -0
- package/script/types/1_inline_keyboard_button.d.ts +7 -7
- package/script/types/1_keyboard_button.d.ts +14 -14
- package/script/types/1_photo.d.ts +2 -1
- package/script/types/1_sticker.d.ts +16 -0
- package/script/types/1_user.d.ts +7 -7
- package/script/types/1_video.d.ts +10 -0
- package/script/types/1_video_note.d.ts +8 -0
- package/script/types/2_game.d.ts +7 -0
- package/script/types/2_reply_keyboard_markup.d.ts +5 -5
- package/script/types/3_message.d.ts +57 -25
- package/script/types/3_message.js +0 -1
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Storage = void 0;
|
|
27
|
-
const deps_js_1 = require("../deps.js");
|
|
28
27
|
const _0_control_js_1 = require("../utilities/0_control.js");
|
|
29
28
|
const _0_hash_js_1 = require("../utilities/0_hash.js");
|
|
30
29
|
const _0_bigint_js_1 = require("../utilities/0_bigint.js");
|
|
@@ -32,6 +31,19 @@ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
|
|
|
32
31
|
const types = __importStar(require("../tl/2_types.js"));
|
|
33
32
|
const _3_tl_reader_js_1 = require("../tl/3_tl_reader.js");
|
|
34
33
|
const _0_rle_js_1 = require("../utilities/0_rle.js");
|
|
34
|
+
const constants_js_1 = require("../constants.js");
|
|
35
|
+
const KPARTS__DC = ["dc"];
|
|
36
|
+
const KPARTS__AUTH_KEY = ["authKey"];
|
|
37
|
+
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
|
38
|
+
const KPARTS__USER_ACCESS_HASH = (v) => ["userAccessHash", v];
|
|
39
|
+
const KPARTS__USERNAME = (v) => ["username", v];
|
|
40
|
+
const KPARTS__STATE = ["state"];
|
|
41
|
+
const KPARTS__CHANNEL_PTS = (v) => ["channelPts", v];
|
|
42
|
+
const KPARTS__PEER = (type, id) => ["peer", type, id];
|
|
43
|
+
const KPARTS__ACCOUNT_TYPE = ["accountType"];
|
|
44
|
+
const KPARTS__STICKER_SET_NAME = (id, accessHash) => ["stickerSetName", id, accessHash];
|
|
45
|
+
const KPARTS_MESSAGE = (chatId, messageId) => ["messages", chatId, messageId];
|
|
46
|
+
const KPARTS_MESSAGE_REF = (messageId) => ["messageRefs", messageId];
|
|
35
47
|
class Storage {
|
|
36
48
|
constructor() {
|
|
37
49
|
Object.defineProperty(this, "_authKeyId", {
|
|
@@ -40,60 +52,12 @@ class Storage {
|
|
|
40
52
|
writable: true,
|
|
41
53
|
value: null
|
|
42
54
|
});
|
|
43
|
-
Object.defineProperty(this, "channelAccessHash__", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: "channelAccessHash__"
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "userAccessHash__", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: "userAccessHash__"
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(this, "username__", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
writable: true,
|
|
59
|
-
value: "username__"
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(this, "state__", {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true,
|
|
65
|
-
value: "state__"
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(this, "channelPts__", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: "channelPts__"
|
|
72
|
-
});
|
|
73
|
-
Object.defineProperty(this, "peer__", {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true,
|
|
76
|
-
writable: true,
|
|
77
|
-
value: "peer__"
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(this, "accountType__", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: "accountType__"
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(this, "stickerSetName__", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true,
|
|
89
|
-
value: "stickerSetName__"
|
|
90
|
-
});
|
|
91
55
|
}
|
|
92
56
|
setDc(dc) {
|
|
93
|
-
return this.set(
|
|
57
|
+
return this.set(KPARTS__DC, dc);
|
|
94
58
|
}
|
|
95
|
-
|
|
96
|
-
return
|
|
59
|
+
getDc() {
|
|
60
|
+
return this.get(KPARTS__DC);
|
|
97
61
|
}
|
|
98
62
|
async resetAuthKeyId(authKey) {
|
|
99
63
|
if (authKey != null) {
|
|
@@ -104,105 +68,88 @@ class Storage {
|
|
|
104
68
|
}
|
|
105
69
|
}
|
|
106
70
|
async getAuthKey() {
|
|
107
|
-
const
|
|
108
|
-
const authKey = authKey_ == null ? null : new Uint8Array(authKey_.split(/([0-9a-f]{2})/).filter((v) => v).map((v) => parseInt(v, 16)));
|
|
71
|
+
const authKey = await this.get(KPARTS__AUTH_KEY);
|
|
109
72
|
await this.resetAuthKeyId(authKey);
|
|
110
73
|
return authKey;
|
|
111
74
|
}
|
|
112
75
|
async setAuthKey(authKey) {
|
|
113
|
-
await this.set(
|
|
76
|
+
await this.set(KPARTS__AUTH_KEY, authKey);
|
|
114
77
|
await this.resetAuthKeyId(authKey);
|
|
115
78
|
}
|
|
116
79
|
get authKeyId() {
|
|
117
80
|
return this._authKeyId;
|
|
118
81
|
}
|
|
119
82
|
setChannelAccessHash(id, accessHash) {
|
|
120
|
-
return this.set(
|
|
83
|
+
return this.set(KPARTS__CHANNEL_ACCESS_HASH(id), accessHash);
|
|
121
84
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (accessHash != null) {
|
|
125
|
-
return BigInt(accessHash);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
85
|
+
getChannelAccessHash(id) {
|
|
86
|
+
return this.get(KPARTS__CHANNEL_ACCESS_HASH(id));
|
|
130
87
|
}
|
|
131
88
|
setUserAccessHash(id, accessHash) {
|
|
132
|
-
return this.set(
|
|
89
|
+
return this.set(KPARTS__USER_ACCESS_HASH(id), accessHash);
|
|
133
90
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (accessHash != null) {
|
|
137
|
-
return BigInt(accessHash);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
91
|
+
getUserAccessHash(id) {
|
|
92
|
+
return this.get(KPARTS__USER_ACCESS_HASH(id));
|
|
142
93
|
}
|
|
143
94
|
async updateUsernames(type, id, usernames) {
|
|
144
95
|
for (let username of usernames) {
|
|
145
96
|
username = username.toLowerCase();
|
|
146
|
-
await this.set(
|
|
97
|
+
await this.set(KPARTS__USERNAME(username), [type, String(id), new Date()]);
|
|
147
98
|
}
|
|
148
99
|
}
|
|
149
|
-
|
|
100
|
+
getUsername(username) {
|
|
150
101
|
username = username.toLowerCase();
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
102
|
+
return this.get(KPARTS__USERNAME(username));
|
|
103
|
+
}
|
|
104
|
+
async setTlObject(key, value) {
|
|
105
|
+
if (value == null) {
|
|
106
|
+
await this.set(key, null);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await this.set(key, (0, _0_rle_js_1.rleEncode)(value[_1_tl_object_js_1.serialize]()));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async getTLObject(key) {
|
|
113
|
+
const buffer = await this.get(key);
|
|
114
|
+
if (buffer != null) {
|
|
115
|
+
return new _3_tl_reader_js_1.TLReader((0, _0_rle_js_1.rleDecode)(buffer)).readObject();
|
|
155
116
|
}
|
|
156
117
|
else {
|
|
157
118
|
return null;
|
|
158
119
|
}
|
|
159
120
|
}
|
|
160
121
|
async setState(state) {
|
|
161
|
-
await this.
|
|
162
|
-
date: state.date,
|
|
163
|
-
pts: state.pts,
|
|
164
|
-
qts: state.qts,
|
|
165
|
-
seq: state.seq,
|
|
166
|
-
unreadCount: state.unreadCount,
|
|
167
|
-
}));
|
|
122
|
+
await this.setTlObject(KPARTS__STATE, state);
|
|
168
123
|
}
|
|
169
124
|
async getState() {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
pts: state_.pts,
|
|
176
|
-
qts: state_.qts,
|
|
177
|
-
seq: state_.seq,
|
|
178
|
-
unreadCount: state_.unreadCount,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return null;
|
|
125
|
+
return await this.getTLObject(KPARTS__STATE);
|
|
126
|
+
}
|
|
127
|
+
async setMessage(chatId, messageId, message) {
|
|
128
|
+
if (chatId > constants_js_1.ZERO_CHANNEL_ID) {
|
|
129
|
+
await this.set(KPARTS_MESSAGE_REF(messageId), message == null ? null : chatId);
|
|
183
130
|
}
|
|
131
|
+
await this.setTlObject(KPARTS_MESSAGE(chatId, messageId), message);
|
|
132
|
+
}
|
|
133
|
+
getMessageChat(messageId) {
|
|
134
|
+
return this.get(KPARTS_MESSAGE_REF(messageId));
|
|
135
|
+
}
|
|
136
|
+
async getMessage(chatId, messageId) {
|
|
137
|
+
return await this.getTLObject(KPARTS_MESSAGE(chatId, messageId));
|
|
184
138
|
}
|
|
185
139
|
async setChannelPts(channelId, pts) {
|
|
186
|
-
await this.set(
|
|
140
|
+
await this.set(KPARTS__CHANNEL_PTS(channelId), pts);
|
|
187
141
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (pts != null) {
|
|
191
|
-
return Number(pts);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
142
|
+
getChannelPts(channelId) {
|
|
143
|
+
return this.get(KPARTS__CHANNEL_PTS(channelId));
|
|
196
144
|
}
|
|
197
145
|
async setEntity(peer) {
|
|
198
146
|
const type = peer instanceof types.Channel ? "channel" : peer instanceof types.Chat ? "chat" : peer instanceof types.User ? "user" : (0, _0_control_js_1.UNREACHABLE)();
|
|
199
|
-
await this.set(
|
|
147
|
+
await this.set(KPARTS__PEER(type, peer.id), peer[_1_tl_object_js_1.serialize]());
|
|
200
148
|
}
|
|
201
149
|
async getEntity(type, id) {
|
|
202
|
-
const peer_ = await this.get(
|
|
150
|
+
const peer_ = await this.get(KPARTS__PEER(type, id));
|
|
203
151
|
if (peer_ != null) {
|
|
204
|
-
|
|
205
|
-
return reader.readObject();
|
|
152
|
+
return new _3_tl_reader_js_1.TLReader(peer_).readObject();
|
|
206
153
|
}
|
|
207
154
|
else {
|
|
208
155
|
return null;
|
|
@@ -218,31 +165,18 @@ class Storage {
|
|
|
218
165
|
throw err;
|
|
219
166
|
}
|
|
220
167
|
else {
|
|
221
|
-
await this.set(
|
|
168
|
+
await this.set(KPARTS__ACCOUNT_TYPE, type);
|
|
222
169
|
}
|
|
223
170
|
}
|
|
224
171
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (accountType != null) {
|
|
228
|
-
return accountType;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
(0, _0_control_js_1.UNREACHABLE)();
|
|
232
|
-
}
|
|
172
|
+
getAccountType() {
|
|
173
|
+
return this.get(KPARTS__ACCOUNT_TYPE);
|
|
233
174
|
}
|
|
234
175
|
async updateStickerSetName(id, accessHash, name) {
|
|
235
|
-
await this.set(
|
|
176
|
+
await this.set(KPARTS__STICKER_SET_NAME(id, accessHash), [name, new Date()]);
|
|
236
177
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (stickerSetName_ != null) {
|
|
240
|
-
const [name, updatedAt] = JSON.parse(stickerSetName_);
|
|
241
|
-
return [name, new Date(updatedAt)];
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
178
|
+
getStickerSetName(id, accessHash) {
|
|
179
|
+
return this.get(KPARTS__STICKER_SET_NAME(id, accessHash));
|
|
246
180
|
}
|
|
247
181
|
}
|
|
248
182
|
exports.Storage = Storage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StorageKeyPart } from "./0_storage.js";
|
|
2
|
+
export declare enum ValueType {
|
|
3
|
+
Boolean = 0,
|
|
4
|
+
Number = 1,
|
|
5
|
+
String = 2,
|
|
6
|
+
BigInt = 3,
|
|
7
|
+
Date = 4,
|
|
8
|
+
Uint8Array = 5,
|
|
9
|
+
Array = 6
|
|
10
|
+
}
|
|
11
|
+
export declare function toString(value: unknown): string;
|
|
12
|
+
export declare function fromString<T>(string: string): any;
|
|
13
|
+
export declare function fixKey(key: StorageKeyPart[]): (string | number | Uint8Array)[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixKey = exports.fromString = exports.toString = exports.ValueType = void 0;
|
|
4
|
+
const deps_js_1 = require("../deps.js");
|
|
5
|
+
const _0_control_js_1 = require("../utilities/0_control.js");
|
|
6
|
+
var ValueType;
|
|
7
|
+
(function (ValueType) {
|
|
8
|
+
ValueType[ValueType["Boolean"] = 0] = "Boolean";
|
|
9
|
+
ValueType[ValueType["Number"] = 1] = "Number";
|
|
10
|
+
ValueType[ValueType["String"] = 2] = "String";
|
|
11
|
+
ValueType[ValueType["BigInt"] = 3] = "BigInt";
|
|
12
|
+
ValueType[ValueType["Date"] = 4] = "Date";
|
|
13
|
+
ValueType[ValueType["Uint8Array"] = 5] = "Uint8Array";
|
|
14
|
+
ValueType[ValueType["Array"] = 6] = "Array";
|
|
15
|
+
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
16
|
+
function toString(value) {
|
|
17
|
+
if (typeof value === "boolean") {
|
|
18
|
+
return JSON.stringify([ValueType.Boolean, value]);
|
|
19
|
+
}
|
|
20
|
+
else if (typeof value === "number") {
|
|
21
|
+
return JSON.stringify([ValueType.Number, value]);
|
|
22
|
+
}
|
|
23
|
+
else if (typeof value === "string") {
|
|
24
|
+
return JSON.stringify([ValueType.String, value]);
|
|
25
|
+
}
|
|
26
|
+
else if (typeof value == "bigint") {
|
|
27
|
+
return JSON.stringify([ValueType.BigInt, String(value)]);
|
|
28
|
+
}
|
|
29
|
+
else if (value instanceof Date) {
|
|
30
|
+
return JSON.stringify([ValueType.Date, value.getTime()]);
|
|
31
|
+
}
|
|
32
|
+
else if (value instanceof Uint8Array) {
|
|
33
|
+
return JSON.stringify([ValueType.Uint8Array, (0, deps_js_1.base64Encode)(value)]);
|
|
34
|
+
}
|
|
35
|
+
else if (Array.isArray(value)) {
|
|
36
|
+
return JSON.stringify([ValueType.Array, value.map(toString)]);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
(0, _0_control_js_1.UNREACHABLE)();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.toString = toString;
|
|
43
|
+
function fromString(string) {
|
|
44
|
+
const [type, value] = JSON.parse(string);
|
|
45
|
+
if (type == ValueType.Boolean || type == ValueType.Number || type == ValueType.String) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
else if (type == ValueType.BigInt) {
|
|
49
|
+
return BigInt(value);
|
|
50
|
+
}
|
|
51
|
+
else if (type == ValueType.Date) {
|
|
52
|
+
return new Date(value);
|
|
53
|
+
}
|
|
54
|
+
else if (type == ValueType.Uint8Array) {
|
|
55
|
+
return (0, deps_js_1.base64Decode)(value);
|
|
56
|
+
}
|
|
57
|
+
else if (type == ValueType.Array) {
|
|
58
|
+
return value.map(fromString);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
(0, _0_control_js_1.UNREACHABLE)();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.fromString = fromString;
|
|
65
|
+
function fixKey(key) {
|
|
66
|
+
return key.map((v) => typeof v === "bigint" ? String(v) : v);
|
|
67
|
+
}
|
|
68
|
+
exports.fixKey = fixKey;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Storage } from "./0_storage.js";
|
|
1
|
+
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
2
2
|
export declare class StorageIndexedDB extends Storage {
|
|
3
3
|
readonly name: string;
|
|
4
4
|
database: IDBDatabase | null;
|
|
5
5
|
constructor(name: string);
|
|
6
6
|
init(): Promise<void>;
|
|
7
|
-
set(k:
|
|
8
|
-
get(k:
|
|
7
|
+
set(k: StorageKeyPart[], v: unknown): Promise<void>;
|
|
8
|
+
get<T>(k: StorageKeyPart[]): Promise<T | null>;
|
|
9
9
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageIndexedDB = void 0;
|
|
4
4
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
5
|
+
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
5
6
|
const VERSION = 1;
|
|
6
7
|
const KV_OBJECT_STORE = "kv";
|
|
7
8
|
class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
@@ -47,10 +48,10 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
47
48
|
// deno-lint-ignore no-explicit-any
|
|
48
49
|
let tx;
|
|
49
50
|
if (v == null) {
|
|
50
|
-
tx = store.delete(k);
|
|
51
|
+
tx = store.delete((0, _0_utilities_js_1.fixKey)(k));
|
|
51
52
|
}
|
|
52
53
|
else {
|
|
53
|
-
tx = store.put(v, k);
|
|
54
|
+
tx = store.put(v, (0, _0_utilities_js_1.fixKey)(k));
|
|
54
55
|
}
|
|
55
56
|
return new Promise((res, rej) => {
|
|
56
57
|
tx.onerror = rej;
|
|
@@ -66,7 +67,7 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
66
67
|
const tx = this.database
|
|
67
68
|
.transaction(KV_OBJECT_STORE, "readonly")
|
|
68
69
|
.objectStore(KV_OBJECT_STORE)
|
|
69
|
-
.get(k);
|
|
70
|
+
.get((0, _0_utilities_js_1.fixKey)(k));
|
|
70
71
|
return new Promise((res, rej) => {
|
|
71
72
|
tx.onerror = rej;
|
|
72
73
|
tx.onsuccess = () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
|
-
import { Storage } from "./0_storage.js";
|
|
2
|
+
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
|
5
5
|
constructor(prefix: string);
|
|
6
6
|
init(): void;
|
|
7
|
-
get(
|
|
8
|
-
set(
|
|
7
|
+
get(key_: readonly StorageKeyPart[]): any;
|
|
8
|
+
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
9
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageLocalStorage = void 0;
|
|
4
4
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
5
|
+
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
5
6
|
class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
6
7
|
constructor(prefix) {
|
|
7
8
|
if (typeof localStorage === "undefined") {
|
|
@@ -23,14 +24,20 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
|
23
24
|
}
|
|
24
25
|
init() {
|
|
25
26
|
}
|
|
26
|
-
get(
|
|
27
|
-
key = this.prefix +
|
|
28
|
-
|
|
27
|
+
get(key_) {
|
|
28
|
+
const key = this.prefix + (0, _0_utilities_js_1.toString)(key_);
|
|
29
|
+
const value = localStorage.getItem(key);
|
|
30
|
+
if (value != null) {
|
|
31
|
+
return (0, _0_utilities_js_1.fromString)(value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
|
-
set(
|
|
31
|
-
key = this.prefix +
|
|
37
|
+
set(key_, value) {
|
|
38
|
+
const key = this.prefix + (0, _0_utilities_js_1.toString)(key_);
|
|
32
39
|
if (value != null) {
|
|
33
|
-
localStorage.setItem(key, value);
|
|
40
|
+
localStorage.setItem(key, (0, _0_utilities_js_1.toString)(value));
|
|
34
41
|
}
|
|
35
42
|
else {
|
|
36
43
|
localStorage.removeItem(key);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
|
-
import { Storage } from "./0_storage.js";
|
|
2
|
+
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
|
-
protected map: Map<string,
|
|
4
|
+
protected map: Map<string, unknown>;
|
|
5
5
|
init(): void;
|
|
6
|
-
get(key:
|
|
7
|
-
set(
|
|
6
|
+
get<T>(key: readonly StorageKeyPart[]): NonNullable<T> | null;
|
|
7
|
+
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
8
8
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageMemory = void 0;
|
|
4
4
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
5
|
+
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
5
6
|
class StorageMemory extends _0_storage_js_1.Storage {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
@@ -15,9 +16,10 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
15
16
|
init() {
|
|
16
17
|
}
|
|
17
18
|
get(key) {
|
|
18
|
-
return this.map.get(key) ?? null;
|
|
19
|
+
return this.map.get((0, _0_utilities_js_1.toString)(key)) ?? null;
|
|
19
20
|
}
|
|
20
|
-
set(
|
|
21
|
+
set(key_, value) {
|
|
22
|
+
const key = (0, _0_utilities_js_1.toString)(key_);
|
|
21
23
|
if (value != null) {
|
|
22
24
|
this.map.set(key, value);
|
|
23
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
|
-
import { Storage } from "./0_storage.js";
|
|
2
|
+
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageSessionStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
|
5
5
|
constructor(prefix: string);
|
|
6
6
|
init(): void;
|
|
7
|
-
get(
|
|
8
|
-
set(
|
|
7
|
+
get(key_: readonly StorageKeyPart[]): any;
|
|
8
|
+
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
9
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageSessionStorage = void 0;
|
|
4
4
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
5
|
+
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
5
6
|
class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
6
7
|
constructor(prefix) {
|
|
7
8
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -23,14 +24,20 @@ class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
|
23
24
|
}
|
|
24
25
|
init() {
|
|
25
26
|
}
|
|
26
|
-
get(
|
|
27
|
-
key = this.prefix +
|
|
28
|
-
|
|
27
|
+
get(key_) {
|
|
28
|
+
const key = this.prefix + (0, _0_utilities_js_1.toString)(key_);
|
|
29
|
+
const value = sessionStorage.getItem(key);
|
|
30
|
+
if (value != null) {
|
|
31
|
+
return (0, _0_utilities_js_1.fromString)(value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
|
-
set(
|
|
31
|
-
key = this.prefix +
|
|
37
|
+
set(key_, value) {
|
|
38
|
+
const key = this.prefix + (0, _0_utilities_js_1.toString)(key_);
|
|
32
39
|
if (value != null) {
|
|
33
|
-
sessionStorage.setItem(key, value);
|
|
40
|
+
sessionStorage.setItem(key, (0, _0_utilities_js_1.toString)(value));
|
|
34
41
|
}
|
|
35
42
|
else {
|
|
36
43
|
sessionStorage.removeItem(key);
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as types from "../tl/2_types.js";
|
|
2
2
|
import { Thumbnail } from "./0_thumbnail.js";
|
|
3
|
+
/** This object represents an audio file to be treated as music by the Telegram clients. */
|
|
3
4
|
export interface Audio {
|
|
5
|
+
/** Identifier for this file, which can be used to download or reuse the file */
|
|
4
6
|
fileId: string;
|
|
7
|
+
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
|
|
5
8
|
fileUniqueId: string;
|
|
9
|
+
/** Duration of the audio in seconds as defined by sender */
|
|
6
10
|
duration: number;
|
|
11
|
+
/** Performer of the audio as defined by sender or by audio tags */
|
|
7
12
|
performer?: string;
|
|
13
|
+
/** Title of the audio as defined by sender or by audio tags */
|
|
8
14
|
title?: string;
|
|
15
|
+
/** MIME type of the file as defined by sender */
|
|
9
16
|
mimeType: string;
|
|
17
|
+
/** File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */
|
|
10
18
|
fileSize: number;
|
|
19
|
+
/** Thumbnail of the album cover to which the music file belongs */
|
|
11
20
|
thumbnails: Thumbnail[];
|
|
12
21
|
}
|
|
13
22
|
export declare function constructAudio(document: types.Document, audioAttribute: types.DocumentAttributeAudio | undefined, fileId: string, fileUniqueId: string): Audio;
|
|
@@ -17,13 +17,13 @@ export interface ChatAdministratorRights {
|
|
|
17
17
|
canChangeInfo: boolean;
|
|
18
18
|
/** True, if the user is allowed to invite new users to the chat */
|
|
19
19
|
canInviteUsers: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** True, if the administrator can post in the channel; channels only */
|
|
21
21
|
canPostMessages?: boolean;
|
|
22
|
-
/**
|
|
22
|
+
/** True, if the administrator can edit messages of other users and can pin messages; channels only */
|
|
23
23
|
canEditMessages?: boolean;
|
|
24
|
-
/**
|
|
24
|
+
/** True, if the user is allowed to pin messages; groups and supergroups only */
|
|
25
25
|
canPinMessages?: boolean;
|
|
26
|
-
/**
|
|
26
|
+
/** True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only */
|
|
27
27
|
canManageTopics?: boolean;
|
|
28
28
|
}
|
|
29
29
|
export declare function constructChatAdministratorRights(rights_: types.ChatAdminRights): ChatAdministratorRights;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as types from "../tl/2_types.js";
|
|
2
|
+
/** This object represents a phone contact. */
|
|
2
3
|
export interface Contact {
|
|
4
|
+
/** Contact's phone number */
|
|
3
5
|
phoneNumber: string;
|
|
6
|
+
/** Contact's first name */
|
|
4
7
|
firstName: string;
|
|
8
|
+
/** Contact's last name */
|
|
5
9
|
lastName?: string;
|
|
10
|
+
/** Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */
|
|
6
11
|
userId?: number;
|
|
12
|
+
/** Additional data about the contact in the form of a [vCard](https://en.wikipedia.org/wiki/VCard) */
|
|
7
13
|
vcard?: string;
|
|
8
14
|
}
|
|
9
15
|
export declare function constructContact(contact: types.MessageMediaContact): Contact;
|
package/script/types/0_dice.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as types from "../tl/2_types.js";
|
|
2
|
+
/** This object represents an animated emoji that displays a random value. */
|
|
2
3
|
export interface Dice {
|
|
4
|
+
/** Emoji on which the dice throw animation is based */
|
|
3
5
|
emoji: string;
|
|
6
|
+
/** Value of the dice, 1-6 for "🎲", "🎯" and "🎳" base emoji, 1-5 for "🏀" and "⚽" base emoji, 1-64 for "🎰" base emoji */
|
|
4
7
|
value: number;
|
|
5
8
|
}
|
|
6
9
|
export declare function constructDice(dice_: types.MessageMediaDice): Dice;
|
|
@@ -5,7 +5,7 @@ export interface ForceReply {
|
|
|
5
5
|
forceReply: true;
|
|
6
6
|
/** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */
|
|
7
7
|
inputFieldPlaceholder?: string;
|
|
8
|
-
/**
|
|
8
|
+
/** Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. */
|
|
9
9
|
selective?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function constructForceReply(replyMarkup_: types.ReplyKeyboardForceReply): ForceReply;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */
|
|
2
2
|
export interface KeyboardButtonPollType {
|
|
3
|
-
/**
|
|
3
|
+
/** If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. */
|
|
4
4
|
type?: string;
|
|
5
5
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as types from "../tl/2_types.js";
|
|
2
|
+
/** This object represents a point on the map. */
|
|
2
3
|
export interface Location {
|
|
4
|
+
/** Latitude as defined by sender */
|
|
3
5
|
latitude: number;
|
|
6
|
+
/** Longitude as defined by sender */
|
|
4
7
|
longitude: number;
|
|
8
|
+
/** The radius of uncertainty for the location, measured in meters; 0-1500 */
|
|
5
9
|
horizontalAccuracy?: number;
|
|
10
|
+
/** Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only. */
|
|
6
11
|
livePeriod?: number;
|
|
12
|
+
/** The direction in which user is moving, in degrees; 1-360. For active live locations only. */
|
|
7
13
|
heading?: number;
|
|
14
|
+
/** The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */
|
|
8
15
|
proximityAlertRadius?: number;
|
|
9
16
|
}
|
|
10
17
|
export declare function constructLocation(geo_: types.MessageMediaGeo | types.MessageMediaGeoLive | types.GeoPoint): Location;
|