@mtkruto/node 0.1.122 → 0.1.123
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/3_types.d.ts +1 -0
- package/esm/3_types.js +1 -0
- package/esm/4_constants.d.ts +1 -3
- package/esm/4_constants.js +1 -3
- package/esm/client/3_types.d.ts +3 -2
- package/esm/client/5_client.d.ts +1 -1
- package/esm/client/5_client.js +6 -3
- package/esm/storage/0_storage.js +1 -2
- package/esm/tl/3_utilities.js +1 -2
- package/esm/tl/4_tl_writer.js +1 -1
- package/esm/types/1_chat.js +1 -2
- package/esm/types/2_chosen_inline_result.d.ts +12 -0
- package/esm/types/2_chosen_inline_result.js +17 -0
- package/esm/types/3_message.js +1 -2
- package/esm/types/4_callback_query.d.ts +1 -1
- package/esm/types/4_callback_query.js +3 -3
- package/esm/utilities/1_misc.d.ts +2 -0
- package/esm/utilities/1_misc.js +2 -0
- package/package.json +1 -1
- package/script/3_types.d.ts +1 -0
- package/script/3_types.js +1 -0
- package/script/4_constants.d.ts +1 -3
- package/script/4_constants.js +2 -4
- package/script/client/3_types.d.ts +3 -2
- package/script/client/5_client.d.ts +1 -1
- package/script/client/5_client.js +6 -3
- package/script/storage/0_storage.js +1 -2
- package/script/tl/3_utilities.js +1 -2
- package/script/tl/4_tl_writer.js +2 -2
- package/script/types/1_chat.js +2 -3
- package/script/types/2_chosen_inline_result.d.ts +12 -0
- package/script/types/2_chosen_inline_result.js +21 -0
- package/script/types/3_message.js +1 -2
- package/script/types/4_callback_query.d.ts +1 -1
- package/script/types/4_callback_query.js +1 -1
- package/script/utilities/1_misc.d.ts +2 -0
- package/script/utilities/1_misc.js +3 -1
package/esm/3_types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./types/1_sticker.js";
|
|
|
40
40
|
export * from "./types/1_user.js";
|
|
41
41
|
export * from "./types/1_video_note.js";
|
|
42
42
|
export * from "./types/1_video.js";
|
|
43
|
+
export * from "./types/2_chosen_inline_result.js";
|
|
43
44
|
export * from "./types/2_game.js";
|
|
44
45
|
export * from "./types/2_inline_keyboard_button.js";
|
|
45
46
|
export * from "./types/2_inline_query.js";
|
package/esm/3_types.js
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./types/1_sticker.js";
|
|
|
40
40
|
export * from "./types/1_user.js";
|
|
41
41
|
export * from "./types/1_video_note.js";
|
|
42
42
|
export * from "./types/1_video.js";
|
|
43
|
+
export * from "./types/2_chosen_inline_result.js";
|
|
43
44
|
export * from "./types/2_game.js";
|
|
44
45
|
export * from "./types/2_inline_keyboard_button.js";
|
|
45
46
|
export * from "./types/2_inline_query.js";
|
package/esm/4_constants.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ import { DC } from "./3_transport.js";
|
|
|
2
2
|
export declare const ACK_THRESHOLD = 10;
|
|
3
3
|
export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
|
-
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
5
|
export declare const INITIAL_DC: DC;
|
|
7
6
|
export declare const LAYER = 167;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.123";
|
|
9
8
|
export declare const DEVICE_MODEL: string;
|
|
10
9
|
export declare const LANG_CODE: string;
|
|
11
10
|
export declare const LANG_PACK = "";
|
|
@@ -15,6 +14,5 @@ export declare const USERNAME_TTL = 86400;
|
|
|
15
14
|
export declare const STICKER_SET_NAME_TTL = 172800;
|
|
16
15
|
export declare const MAX_CHAT_ID = 999999999999;
|
|
17
16
|
export declare const MAX_CHANNEL_ID = 997852516352;
|
|
18
|
-
export declare const ZERO_CHANNEL_ID = -1000000000000;
|
|
19
17
|
export declare const CHANNEL_DIFFERENCE_LIMIT_USER = 100;
|
|
20
18
|
export declare const CHANNEL_DIFFERENCE_LIMIT_BOT = 100000;
|
package/esm/4_constants.js
CHANGED
|
@@ -51,10 +51,9 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
51
51
|
],
|
|
52
52
|
],
|
|
53
53
|
]);
|
|
54
|
-
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
55
54
|
export const INITIAL_DC = "2";
|
|
56
55
|
export const LAYER = 167;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
56
|
+
export const APP_VERSION = "MTKruto 0.1.123";
|
|
58
57
|
// @ts-ignore: lib
|
|
59
58
|
export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
60
59
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -66,6 +65,5 @@ export const USERNAME_TTL = 86400;
|
|
|
66
65
|
export const STICKER_SET_NAME_TTL = 172800;
|
|
67
66
|
export const MAX_CHAT_ID = 999999999999;
|
|
68
67
|
export const MAX_CHANNEL_ID = 997852516352;
|
|
69
|
-
export const ZERO_CHANNEL_ID = -1000000000000;
|
|
70
68
|
export const CHANNEL_DIFFERENCE_LIMIT_USER = 100;
|
|
71
69
|
export const CHANNEL_DIFFERENCE_LIMIT_BOT = 100000;
|
package/esm/client/3_types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { functions, types } from "../2_tl.js";
|
|
3
|
-
import { BotCommandScope, CallbackQuery, ChatID, ForceReply, InlineKeyboardMarkup, InlineQuery, InlineQueryResultButton, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
3
|
+
import { BotCommandScope, CallbackQuery, ChatID, ChosenInlineResult, ForceReply, InlineKeyboardMarkup, InlineQuery, InlineQueryResultButton, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
4
4
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
5
5
|
import { ParseMode } from "../3_types.js";
|
|
6
6
|
export interface ClientParams extends ClientPlainParams {
|
|
@@ -295,7 +295,7 @@ export interface ReplyParams {
|
|
|
295
295
|
/** Whether to quote the message that is to be replied. Enabled by default for non-private chats. */
|
|
296
296
|
quote?: boolean;
|
|
297
297
|
}
|
|
298
|
-
export type FilterableUpdates = "message" | "editedMessage" | "callbackQuery";
|
|
298
|
+
export type FilterableUpdates = "message" | "editedMessage" | "callbackQuery" | "inlineQuery" | "chosenInlineResult";
|
|
299
299
|
export interface Update {
|
|
300
300
|
message?: Message;
|
|
301
301
|
editedMessage?: Message;
|
|
@@ -304,6 +304,7 @@ export interface Update {
|
|
|
304
304
|
deletedMessages?: [Message, ...Message[]];
|
|
305
305
|
callbackQuery?: CallbackQuery;
|
|
306
306
|
inlineQuery?: InlineQuery;
|
|
307
|
+
chosenInlineResult?: ChosenInlineResult;
|
|
307
308
|
}
|
|
308
309
|
export type NextFn<T = void> = () => Promise<T>;
|
|
309
310
|
export interface Handler<C> {
|
package/esm/client/5_client.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
94
94
|
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
95
95
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
|
|
96
96
|
*/
|
|
97
|
-
constructor(storage
|
|
97
|
+
constructor(storage?: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
|
|
98
98
|
api: Api;
|
|
99
99
|
protected stateChangeHandler: (connected: boolean) => void;
|
|
100
100
|
/**
|
package/esm/client/5_client.js
CHANGED
|
@@ -11,11 +11,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo;
|
|
13
13
|
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
14
|
-
import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
14
|
+
import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
15
15
|
import { as, functions, getChannelChatId, Message_, MessageContainer, name, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
|
|
16
16
|
import { StorageMemory } from "../3_storage.js";
|
|
17
|
-
import { botCommandScopeToTlObject, constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
|
|
18
|
-
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL
|
|
17
|
+
import { botCommandScopeToTlObject, constructCallbackQuery, constructChosenInlineResult, constructInlineQuery, constructMessage, constructUser, FileID, FileType, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
|
|
18
|
+
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL } from "../4_constants.js";
|
|
19
19
|
import { AuthKeyUnregistered, FloodWait, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded, upgradeInstance } from "../4_errors.js";
|
|
20
20
|
import { parseHtml } from "./0_html.js";
|
|
21
21
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
@@ -2294,6 +2294,9 @@ async function _Client_handleUpdate(update) {
|
|
|
2294
2294
|
else if (update instanceof types.UpdateBotInlineQuery) {
|
|
2295
2295
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { inlineQuery: await constructInlineQuery(update, this[getEntity].bind(this)) }), resolve);
|
|
2296
2296
|
}
|
|
2297
|
+
else if (update instanceof types.UpdateBotInlineSend) {
|
|
2298
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { chosenInlineResult: await constructChosenInlineResult(update, this[getEntity].bind(this)) }), resolve);
|
|
2299
|
+
}
|
|
2297
2300
|
}, _Client_constructReplyMarkup = async function _Client_constructReplyMarkup(params) {
|
|
2298
2301
|
if (params?.replyMarkup) {
|
|
2299
2302
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "replyMarkup");
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -10,9 +10,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _Storage_instances, _Storage__authKeyId, _Storage_resetAuthKeyId;
|
|
13
|
-
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
13
|
+
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
14
14
|
import { serialize, TLReader, types } from "../2_tl.js";
|
|
15
|
-
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
16
15
|
const KPARTS__DC = ["dc"];
|
|
17
16
|
const KPARTS__AUTH_KEY = ["authKey"];
|
|
18
17
|
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
package/esm/tl/3_utilities.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
|
-
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
1
|
+
import { UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
3
2
|
import { types } from "./2_types.js";
|
|
4
3
|
export function getChannelChatId(channelId) {
|
|
5
4
|
return ZERO_CHANNEL_ID + -Number(channelId);
|
package/esm/tl/4_tl_writer.js
CHANGED
package/esm/types/1_chat.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { cleanObject, getColorFromPeerId, UNREACHABLE } from "../1_utilities.js";
|
|
1
|
+
import { cleanObject, getColorFromPeerId, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
|
-
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
4
3
|
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
5
4
|
import { constructRestrictionReason } from "./0_restriction_reason.js";
|
|
6
5
|
export function constructChat(chat) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
|
+
import { Location } from "./0_location.js";
|
|
3
|
+
import { EntityGetter } from "./1__getters.js";
|
|
4
|
+
import { User } from "./1_user.js";
|
|
5
|
+
export interface ChosenInlineResult {
|
|
6
|
+
resultId: string;
|
|
7
|
+
from: User;
|
|
8
|
+
location?: Location;
|
|
9
|
+
inlineMessageId?: string;
|
|
10
|
+
query: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function constructChosenInlineResult(ubis: types.UpdateBotInlineSend, getEntity: EntityGetter): Promise<ChosenInlineResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { base64EncodeUrlSafe, cleanObject, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { serialize, types } from "../2_tl.js";
|
|
3
|
+
import { constructLocation } from "./0_location.js";
|
|
4
|
+
import { constructUser } from "./1_user.js";
|
|
5
|
+
export async function constructChosenInlineResult(ubis, getEntity) {
|
|
6
|
+
const entity = await getEntity(new types.PeerUser(ubis));
|
|
7
|
+
if (!entity || !(entity instanceof types.User)) {
|
|
8
|
+
UNREACHABLE();
|
|
9
|
+
}
|
|
10
|
+
return cleanObject({
|
|
11
|
+
resultId: ubis.id,
|
|
12
|
+
from: constructUser(entity),
|
|
13
|
+
location: ubis.geo instanceof types.GeoPoint ? constructLocation(ubis.geo) : undefined,
|
|
14
|
+
inlineMessageId: ubis.msg_id === undefined ? undefined : base64EncodeUrlSafe(ubis.msg_id[serialize]()),
|
|
15
|
+
query: ubis.query,
|
|
16
|
+
});
|
|
17
|
+
}
|
package/esm/types/3_message.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { debug } from "../0_deps.js";
|
|
2
|
-
import { cleanObject, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { cleanObject, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
3
3
|
import { as, types } from "../2_tl.js";
|
|
4
|
-
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
5
4
|
import { FileID, FileType, FileUniqueID, FileUniqueType } from "./0__file_id.js";
|
|
6
5
|
import { constructAudio } from "./0_audio.js";
|
|
7
6
|
import { constructContact } from "./0_contact.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cleanObject, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
-
import { peerToChatId, types } from "../2_tl.js";
|
|
1
|
+
import { base64EncodeUrlSafe, cleanObject, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { peerToChatId, serialize, types } from "../2_tl.js";
|
|
3
3
|
import { constructUser } from "./1_user.js";
|
|
4
4
|
export async function constructCallbackQuery(callbackQuery, getEntity, getMessage) {
|
|
5
5
|
const user_ = await getEntity(new types.PeerUser({ user_id: callbackQuery.user_id }));
|
|
@@ -19,6 +19,6 @@ export async function constructCallbackQuery(callbackQuery, getEntity, getMessag
|
|
|
19
19
|
return cleanObject({ id, from: user, message, chatInstance, data, gameShortName });
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
return cleanObject({ id, from: user, inlineMessageId:
|
|
22
|
+
return cleanObject({ id, from: user, inlineMessageId: base64EncodeUrlSafe(callbackQuery.msg_id[serialize]()), chatInstance, data, gameShortName });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -2,3 +2,5 @@ export declare function drop<T>(promise: Promise<T>): void;
|
|
|
2
2
|
export declare function mustPrompt(message: string): string;
|
|
3
3
|
export declare function mustPromptNumber(message: string): number;
|
|
4
4
|
export declare function mustPromptOneOf<T extends readonly string[]>(message: string, choices: T): T[number];
|
|
5
|
+
export declare const ZERO_CHANNEL_ID = -1000000000000;
|
|
6
|
+
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
package/esm/utilities/1_misc.js
CHANGED
package/package.json
CHANGED
package/script/3_types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./types/1_sticker.js";
|
|
|
40
40
|
export * from "./types/1_user.js";
|
|
41
41
|
export * from "./types/1_video_note.js";
|
|
42
42
|
export * from "./types/1_video.js";
|
|
43
|
+
export * from "./types/2_chosen_inline_result.js";
|
|
43
44
|
export * from "./types/2_game.js";
|
|
44
45
|
export * from "./types/2_inline_keyboard_button.js";
|
|
45
46
|
export * from "./types/2_inline_query.js";
|
package/script/3_types.js
CHANGED
|
@@ -56,6 +56,7 @@ __exportStar(require("./types/1_sticker.js"), exports);
|
|
|
56
56
|
__exportStar(require("./types/1_user.js"), exports);
|
|
57
57
|
__exportStar(require("./types/1_video_note.js"), exports);
|
|
58
58
|
__exportStar(require("./types/1_video.js"), exports);
|
|
59
|
+
__exportStar(require("./types/2_chosen_inline_result.js"), exports);
|
|
59
60
|
__exportStar(require("./types/2_game.js"), exports);
|
|
60
61
|
__exportStar(require("./types/2_inline_keyboard_button.js"), exports);
|
|
61
62
|
__exportStar(require("./types/2_inline_query.js"), exports);
|
package/script/4_constants.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ import { DC } from "./3_transport.js";
|
|
|
2
2
|
export declare const ACK_THRESHOLD = 10;
|
|
3
3
|
export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
|
-
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
5
|
export declare const INITIAL_DC: DC;
|
|
7
6
|
export declare const LAYER = 167;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.123";
|
|
9
8
|
export declare const DEVICE_MODEL: string;
|
|
10
9
|
export declare const LANG_CODE: string;
|
|
11
10
|
export declare const LANG_PACK = "";
|
|
@@ -15,6 +14,5 @@ export declare const USERNAME_TTL = 86400;
|
|
|
15
14
|
export declare const STICKER_SET_NAME_TTL = 172800;
|
|
16
15
|
export declare const MAX_CHAT_ID = 999999999999;
|
|
17
16
|
export declare const MAX_CHANNEL_ID = 997852516352;
|
|
18
|
-
export declare const ZERO_CHANNEL_ID = -1000000000000;
|
|
19
17
|
export declare const CHANNEL_DIFFERENCE_LIMIT_USER = 100;
|
|
20
18
|
export declare const CHANNEL_DIFFERENCE_LIMIT_BOT = 100000;
|
package/script/4_constants.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CHANNEL_DIFFERENCE_LIMIT_BOT = exports.CHANNEL_DIFFERENCE_LIMIT_USER = exports.
|
|
26
|
+
exports.CHANNEL_DIFFERENCE_LIMIT_BOT = exports.CHANNEL_DIFFERENCE_LIMIT_USER = exports.MAX_CHANNEL_ID = exports.MAX_CHAT_ID = exports.STICKER_SET_NAME_TTL = exports.USERNAME_TTL = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LANG_PACK = exports.LANG_CODE = exports.DEVICE_MODEL = exports.APP_VERSION = exports.LAYER = exports.INITIAL_DC = exports.PUBLIC_KEYS = exports.ACK_THRESHOLD = void 0;
|
|
27
27
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
28
|
exports.ACK_THRESHOLD = 10;
|
|
29
29
|
exports.PUBLIC_KEYS = Object.freeze([
|
|
@@ -77,10 +77,9 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
77
77
|
],
|
|
78
78
|
],
|
|
79
79
|
]);
|
|
80
|
-
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
80
|
exports.INITIAL_DC = "2";
|
|
82
81
|
exports.LAYER = 167;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
82
|
+
exports.APP_VERSION = "MTKruto 0.1.123";
|
|
84
83
|
// @ts-ignore: lib
|
|
85
84
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
86
85
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -92,6 +91,5 @@ exports.USERNAME_TTL = 86400;
|
|
|
92
91
|
exports.STICKER_SET_NAME_TTL = 172800;
|
|
93
92
|
exports.MAX_CHAT_ID = 999999999999;
|
|
94
93
|
exports.MAX_CHANNEL_ID = 997852516352;
|
|
95
|
-
exports.ZERO_CHANNEL_ID = -1000000000000;
|
|
96
94
|
exports.CHANNEL_DIFFERENCE_LIMIT_USER = 100;
|
|
97
95
|
exports.CHANNEL_DIFFERENCE_LIMIT_BOT = 100000;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { functions, types } from "../2_tl.js";
|
|
3
|
-
import { BotCommandScope, CallbackQuery, ChatID, ForceReply, InlineKeyboardMarkup, InlineQuery, InlineQueryResultButton, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
3
|
+
import { BotCommandScope, CallbackQuery, ChatID, ChosenInlineResult, ForceReply, InlineKeyboardMarkup, InlineQuery, InlineQueryResultButton, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
4
4
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
5
5
|
import { ParseMode } from "../3_types.js";
|
|
6
6
|
export interface ClientParams extends ClientPlainParams {
|
|
@@ -295,7 +295,7 @@ export interface ReplyParams {
|
|
|
295
295
|
/** Whether to quote the message that is to be replied. Enabled by default for non-private chats. */
|
|
296
296
|
quote?: boolean;
|
|
297
297
|
}
|
|
298
|
-
export type FilterableUpdates = "message" | "editedMessage" | "callbackQuery";
|
|
298
|
+
export type FilterableUpdates = "message" | "editedMessage" | "callbackQuery" | "inlineQuery" | "chosenInlineResult";
|
|
299
299
|
export interface Update {
|
|
300
300
|
message?: Message;
|
|
301
301
|
editedMessage?: Message;
|
|
@@ -304,6 +304,7 @@ export interface Update {
|
|
|
304
304
|
deletedMessages?: [Message, ...Message[]];
|
|
305
305
|
callbackQuery?: CallbackQuery;
|
|
306
306
|
inlineQuery?: InlineQuery;
|
|
307
|
+
chosenInlineResult?: ChosenInlineResult;
|
|
307
308
|
}
|
|
308
309
|
export type NextFn<T = void> = () => Promise<T>;
|
|
309
310
|
export interface Handler<C> {
|
|
@@ -94,7 +94,7 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
94
94
|
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
95
95
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
|
|
96
96
|
*/
|
|
97
|
-
constructor(storage
|
|
97
|
+
constructor(storage?: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
|
|
98
98
|
api: Api;
|
|
99
99
|
protected stateChangeHandler: (connected: boolean) => void;
|
|
100
100
|
/**
|
|
@@ -1224,7 +1224,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1224
1224
|
const pts_ = await this.storage.getChannelPts(channelId);
|
|
1225
1225
|
let pts = pts_ == null ? 1 : pts_;
|
|
1226
1226
|
while (true) {
|
|
1227
|
-
const { access_hash } = await this.getInputPeer(
|
|
1227
|
+
const { access_hash } = await this.getInputPeer(_1_utilities_js_1.ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerChannel));
|
|
1228
1228
|
const difference = await this.invoke(new _2_tl_js_1.functions.updates.getChannelDifference({
|
|
1229
1229
|
pts,
|
|
1230
1230
|
channel: new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash }),
|
|
@@ -1318,8 +1318,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1318
1318
|
else if (-_4_constants_js_1.MAX_CHAT_ID <= id) {
|
|
1319
1319
|
return new _2_tl_js_1.types.InputPeerChat({ chat_id: BigInt(Math.abs(id)) });
|
|
1320
1320
|
}
|
|
1321
|
-
else if (
|
|
1322
|
-
const id_ = BigInt(Math.abs(id -
|
|
1321
|
+
else if (_1_utilities_js_1.ZERO_CHANNEL_ID - _4_constants_js_1.MAX_CHANNEL_ID <= id && id != _1_utilities_js_1.ZERO_CHANNEL_ID) {
|
|
1322
|
+
const id_ = BigInt(Math.abs(id - _1_utilities_js_1.ZERO_CHANNEL_ID));
|
|
1323
1323
|
const accessHash = await this.storage.getChannelAccessHash(id_);
|
|
1324
1324
|
return new _2_tl_js_1.types.InputPeerChannel({ channel_id: id_, access_hash: accessHash ?? 0n });
|
|
1325
1325
|
}
|
|
@@ -2300,6 +2300,9 @@ async function _Client_handleUpdate(update) {
|
|
|
2300
2300
|
else if (update instanceof _2_tl_js_1.types.UpdateBotInlineQuery) {
|
|
2301
2301
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { inlineQuery: await (0, _3_types_js_1.constructInlineQuery)(update, this[getEntity].bind(this)) }), _0_utilities_js_1.resolve);
|
|
2302
2302
|
}
|
|
2303
|
+
else if (update instanceof _2_tl_js_1.types.UpdateBotInlineSend) {
|
|
2304
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { chosenInlineResult: await (0, _3_types_js_1.constructChosenInlineResult)(update, this[getEntity].bind(this)) }), _0_utilities_js_1.resolve);
|
|
2305
|
+
}
|
|
2303
2306
|
}, _Client_constructReplyMarkup = async function _Client_constructReplyMarkup(params) {
|
|
2304
2307
|
if (params?.replyMarkup) {
|
|
2305
2308
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "replyMarkup");
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.Storage = void 0;
|
|
16
16
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
17
17
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
18
|
-
const _4_constants_js_1 = require("../4_constants.js");
|
|
19
18
|
const KPARTS__DC = ["dc"];
|
|
20
19
|
const KPARTS__AUTH_KEY = ["authKey"];
|
|
21
20
|
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
|
@@ -97,7 +96,7 @@ class Storage {
|
|
|
97
96
|
return await this.getTLObject(KPARTS__STATE);
|
|
98
97
|
}
|
|
99
98
|
async setMessage(chatId, messageId, message) {
|
|
100
|
-
if (chatId >
|
|
99
|
+
if (chatId > _1_utilities_js_1.ZERO_CHANNEL_ID) {
|
|
101
100
|
await this.set(KPARTS_MESSAGE_REF(messageId), message == null ? null : chatId);
|
|
102
101
|
}
|
|
103
102
|
await this.setTlObject(KPARTS_MESSAGE(chatId, messageId), message);
|
package/script/tl/3_utilities.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.peerToChatId = exports.getChannelChatId = void 0;
|
|
4
4
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
|
-
const _4_constants_js_1 = require("../4_constants.js");
|
|
6
5
|
const _2_types_js_1 = require("./2_types.js");
|
|
7
6
|
function getChannelChatId(channelId) {
|
|
8
|
-
return
|
|
7
|
+
return _1_utilities_js_1.ZERO_CHANNEL_ID + -Number(channelId);
|
|
9
8
|
}
|
|
10
9
|
exports.getChannelChatId = getChannelChatId;
|
|
11
10
|
function peerToChatId(peer) {
|
package/script/tl/4_tl_writer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TLWriter = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
5
|
const _0_tl_raw_writer_js_1 = require("./0_tl_raw_writer.js");
|
|
6
6
|
const _1_tl_object_js_1 = require("./1_tl_object.js");
|
|
7
7
|
class TLWriter extends _0_tl_raw_writer_js_1.TLRawWriter {
|
|
8
8
|
writeObject(object) {
|
|
9
9
|
if (Array.isArray(object)) {
|
|
10
|
-
this.writeInt32(
|
|
10
|
+
this.writeInt32(_1_utilities_js_1.VECTOR_CONSTRUCTOR, false);
|
|
11
11
|
this.writeInt32(object.length);
|
|
12
12
|
for (const item of object) {
|
|
13
13
|
this.writeObject(item);
|
package/script/types/1_chat.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.constructChat = void 0;
|
|
4
4
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
5
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
|
-
const _4_constants_js_1 = require("../4_constants.js");
|
|
7
6
|
const _0_chat_photo_js_1 = require("./0_chat_photo.js");
|
|
8
7
|
const _0_restriction_reason_js_1 = require("./0_restriction_reason.js");
|
|
9
8
|
function constructChat(chat) {
|
|
@@ -47,7 +46,7 @@ function constructChat(chat) {
|
|
|
47
46
|
else if (chat instanceof _2_tl_js_1.types.Channel) {
|
|
48
47
|
let chat_;
|
|
49
48
|
const { title, scam: isScam = false, fake: isFake = false, verified: isVerified = false, restricted: isRestricted = false, } = chat;
|
|
50
|
-
const id =
|
|
49
|
+
const id = _1_utilities_js_1.ZERO_CHANNEL_ID + -Number(chat.id);
|
|
51
50
|
if (chat.megagroup) {
|
|
52
51
|
chat_ = {
|
|
53
52
|
id,
|
|
@@ -62,7 +61,7 @@ function constructChat(chat) {
|
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
|
-
const id =
|
|
64
|
+
const id = _1_utilities_js_1.ZERO_CHANNEL_ID + -Number(chat.id);
|
|
66
65
|
chat_ = {
|
|
67
66
|
id,
|
|
68
67
|
color: chat.color?.color !== undefined ? chat.color.color : (0, _1_utilities_js_1.getColorFromPeerId)(id),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
|
+
import { Location } from "./0_location.js";
|
|
3
|
+
import { EntityGetter } from "./1__getters.js";
|
|
4
|
+
import { User } from "./1_user.js";
|
|
5
|
+
export interface ChosenInlineResult {
|
|
6
|
+
resultId: string;
|
|
7
|
+
from: User;
|
|
8
|
+
location?: Location;
|
|
9
|
+
inlineMessageId?: string;
|
|
10
|
+
query: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function constructChosenInlineResult(ubis: types.UpdateBotInlineSend, getEntity: EntityGetter): Promise<ChosenInlineResult>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.constructChosenInlineResult = void 0;
|
|
4
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
|
+
const _0_location_js_1 = require("./0_location.js");
|
|
7
|
+
const _1_user_js_1 = require("./1_user.js");
|
|
8
|
+
async function constructChosenInlineResult(ubis, getEntity) {
|
|
9
|
+
const entity = await getEntity(new _2_tl_js_1.types.PeerUser(ubis));
|
|
10
|
+
if (!entity || !(entity instanceof _2_tl_js_1.types.User)) {
|
|
11
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
12
|
+
}
|
|
13
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
14
|
+
resultId: ubis.id,
|
|
15
|
+
from: (0, _1_user_js_1.constructUser)(entity),
|
|
16
|
+
location: ubis.geo instanceof _2_tl_js_1.types.GeoPoint ? (0, _0_location_js_1.constructLocation)(ubis.geo) : undefined,
|
|
17
|
+
inlineMessageId: ubis.msg_id === undefined ? undefined : (0, _1_utilities_js_1.base64EncodeUrlSafe)(ubis.msg_id[_2_tl_js_1.serialize]()),
|
|
18
|
+
query: ubis.query,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.constructChosenInlineResult = constructChosenInlineResult;
|
|
@@ -4,7 +4,6 @@ exports.constructMessage = void 0;
|
|
|
4
4
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
5
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
6
6
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
7
|
-
const _4_constants_js_1 = require("../4_constants.js");
|
|
8
7
|
const _0__file_id_js_1 = require("./0__file_id.js");
|
|
9
8
|
const _0_audio_js_1 = require("./0_audio.js");
|
|
10
9
|
const _0_contact_js_1 = require("./0_contact.js");
|
|
@@ -131,7 +130,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
else if (message_.action instanceof _2_tl_js_1.types.MessageActionChatMigrateTo) {
|
|
134
|
-
message.chatMigratedTo =
|
|
133
|
+
message.chatMigratedTo = _1_utilities_js_1.ZERO_CHANNEL_ID + Number(-message_.action.channel_id);
|
|
135
134
|
}
|
|
136
135
|
else if (message_.action instanceof _2_tl_js_1.types.MessageActionChannelMigrateFrom) {
|
|
137
136
|
message.chatMigratedFrom = Number(-message_.action.chat_id);
|
|
@@ -22,7 +22,7 @@ async function constructCallbackQuery(callbackQuery, getEntity, getMessage) {
|
|
|
22
22
|
return (0, _1_utilities_js_1.cleanObject)({ id, from: user, message, chatInstance, data, gameShortName });
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
return (0, _1_utilities_js_1.cleanObject)({ id, from: user, inlineMessageId:
|
|
25
|
+
return (0, _1_utilities_js_1.cleanObject)({ id, from: user, inlineMessageId: (0, _1_utilities_js_1.base64EncodeUrlSafe)(callbackQuery.msg_id[_2_tl_js_1.serialize]()), chatInstance, data, gameShortName });
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
exports.constructCallbackQuery = constructCallbackQuery;
|
|
@@ -2,3 +2,5 @@ export declare function drop<T>(promise: Promise<T>): void;
|
|
|
2
2
|
export declare function mustPrompt(message: string): string;
|
|
3
3
|
export declare function mustPromptNumber(message: string): number;
|
|
4
4
|
export declare function mustPromptOneOf<T extends readonly string[]>(message: string, choices: T): T[number];
|
|
5
|
+
export declare const ZERO_CHANNEL_ID = -1000000000000;
|
|
6
|
+
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mustPromptOneOf = exports.mustPromptNumber = exports.mustPrompt = exports.drop = void 0;
|
|
3
|
+
exports.VECTOR_CONSTRUCTOR = exports.ZERO_CHANNEL_ID = exports.mustPromptOneOf = exports.mustPromptNumber = exports.mustPrompt = exports.drop = void 0;
|
|
4
4
|
const _0_control_js_1 = require("./0_control.js");
|
|
5
5
|
function drop(promise) {
|
|
6
6
|
promise.catch(() => { });
|
|
@@ -33,3 +33,5 @@ function mustPromptOneOf(message, choices) {
|
|
|
33
33
|
return result;
|
|
34
34
|
}
|
|
35
35
|
exports.mustPromptOneOf = mustPromptOneOf;
|
|
36
|
+
exports.ZERO_CHANNEL_ID = -1000000000000;
|
|
37
|
+
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|