@mtkruto/node 0.1.122 → 0.1.124

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.
Files changed (37) hide show
  1. package/esm/3_types.d.ts +1 -0
  2. package/esm/3_types.js +1 -0
  3. package/esm/4_constants.d.ts +1 -3
  4. package/esm/4_constants.js +1 -3
  5. package/esm/client/3_types.d.ts +3 -2
  6. package/esm/client/5_client.d.ts +1 -2
  7. package/esm/client/5_client.js +21 -13
  8. package/esm/storage/0_storage.js +1 -2
  9. package/esm/tl/3_utilities.js +1 -2
  10. package/esm/tl/4_tl_writer.js +1 -1
  11. package/esm/types/1_chat.js +1 -2
  12. package/esm/types/2_chosen_inline_result.d.ts +12 -0
  13. package/esm/types/2_chosen_inline_result.js +17 -0
  14. package/esm/types/3_message.js +1 -2
  15. package/esm/types/4_callback_query.d.ts +1 -1
  16. package/esm/types/4_callback_query.js +3 -3
  17. package/esm/utilities/1_misc.d.ts +2 -0
  18. package/esm/utilities/1_misc.js +2 -0
  19. package/package.json +1 -1
  20. package/script/3_types.d.ts +1 -0
  21. package/script/3_types.js +1 -0
  22. package/script/4_constants.d.ts +1 -3
  23. package/script/4_constants.js +2 -4
  24. package/script/client/3_types.d.ts +3 -2
  25. package/script/client/5_client.d.ts +1 -2
  26. package/script/client/5_client.js +21 -13
  27. package/script/storage/0_storage.js +1 -2
  28. package/script/tl/3_utilities.js +1 -2
  29. package/script/tl/4_tl_writer.js +2 -2
  30. package/script/types/1_chat.js +2 -3
  31. package/script/types/2_chosen_inline_result.d.ts +12 -0
  32. package/script/types/2_chosen_inline_result.js +21 -0
  33. package/script/types/3_message.js +1 -2
  34. package/script/types/4_callback_query.d.ts +1 -1
  35. package/script/types/4_callback_query.js +1 -1
  36. package/script/utilities/1_misc.d.ts +2 -0
  37. 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";
@@ -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.122";
7
+ export declare const APP_VERSION = "MTKruto 0.1.124";
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;
@@ -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.122";
56
+ export const APP_VERSION = "MTKruto 0.1.124";
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;
@@ -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: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
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
  /**
@@ -150,7 +150,6 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
150
150
  * Alias for `invoke` with its second parameter being `true`.
151
151
  */
152
152
  send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
153
- checkGap(pts: number, ptsCount: number): Promise<void>;
154
153
  getUserAccessHash(userId: bigint): Promise<bigint>;
155
154
  getInputPeer(id: ChatID): Promise<import("../tl/2_types.js").InputPeerChat_ | import("../tl/2_types.js").InputPeerUser_ | import("../tl/2_types.js").InputPeerChannel_>;
156
155
  private [getEntity];
@@ -9,13 +9,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
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;
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_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _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, ZERO_CHANNEL_ID } from "../4_constants.js";
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";
@@ -337,6 +337,7 @@ export class Client extends ClientAbstract {
337
337
  });
338
338
  _Client_handleUpdateQueue.set(this, new Queue("handleUpdate"));
339
339
  _Client_processUpdatesQueue.set(this, new Queue("processUpdates"));
340
+ _Client_lastUpdates.set(this, new Date());
340
341
  _Client_lastGetMe.set(this, null);
341
342
  _Client_usernameResolver.set(this, async (v) => {
342
343
  const inputPeer = await this.getInputPeer(v).then((v) => v[as](types.InputPeerUser));
@@ -465,7 +466,7 @@ export class Client extends ClientAbstract {
465
466
  release();
466
467
  }
467
468
  }
468
- async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
469
+ async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
469
470
  __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
470
471
  await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), resolve);
471
472
  });
@@ -682,6 +683,7 @@ export class Client extends ClientAbstract {
682
683
  await this.connect();
683
684
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
684
685
  if (!__classPrivateFieldGet(this, _Client_authKeyWasCreated, "f")) {
686
+ drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_fetchState).call(this, "start"));
685
687
  return;
686
688
  }
687
689
  try {
@@ -703,12 +705,6 @@ export class Client extends ClientAbstract {
703
705
  send(function_) {
704
706
  return this.invoke(function_, true);
705
707
  }
706
- async checkGap(pts, ptsCount) {
707
- const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
708
- if (localState.pts + ptsCount < pts) {
709
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
710
- }
711
- }
712
708
  async getUserAccessHash(userId) {
713
709
  const users = await this.invoke(new functions.users.getUsers({ id: [new types.InputUser({ user_id: userId, access_hash: 0n })] }));
714
710
  return users[0]?.[as](types.User).access_hash ?? 0n;
@@ -868,7 +864,10 @@ export class Client extends ClientAbstract {
868
864
  while (this.connected) {
869
865
  await new Promise((r) => setTimeout(r, __classPrivateFieldGet(this, _Client_pingInterval, "f")));
870
866
  try {
871
- await this.invoke(new functions.ping_delay_disconnect({ ping_id: getRandomBigInt(8, true, false), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") + 15 }));
867
+ await this.invoke(new functions.ping_delay_disconnect({ ping_id: getRandomId(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 }));
868
+ if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
869
+ drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
870
+ }
872
871
  }
873
872
  catch (err) {
874
873
  d("ping loop error: %o", err);
@@ -970,6 +969,11 @@ export class Client extends ClientAbstract {
970
969
  }
971
970
  }
972
971
  }
972
+ }, _Client_checkGap = async function _Client_checkGap(pts, ptsCount) {
973
+ const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
974
+ if (localState.pts + ptsCount < pts) {
975
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
976
+ }
973
977
  }, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount) {
974
978
  let localPts = await this.storage.getChannelPts(channelId);
975
979
  if (!localPts) {
@@ -979,6 +983,7 @@ export class Client extends ClientAbstract {
979
983
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
980
984
  }
981
985
  }, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
986
+ __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
982
987
  /// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
983
988
  ///
984
989
  /// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
@@ -1049,7 +1054,7 @@ export class Client extends ClientAbstract {
1049
1054
  continue;
1050
1055
  }
1051
1056
  if (checkGap) {
1052
- await this.checkGap(update.pts, update.pts_count);
1057
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1053
1058
  }
1054
1059
  localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1055
1060
  originalPts ??= localState.pts;
@@ -2294,6 +2299,9 @@ async function _Client_handleUpdate(update) {
2294
2299
  else if (update instanceof types.UpdateBotInlineQuery) {
2295
2300
  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
2301
  }
2302
+ else if (update instanceof types.UpdateBotInlineSend) {
2303
+ 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);
2304
+ }
2297
2305
  }, _Client_constructReplyMarkup = async function _Client_constructReplyMarkup(params) {
2298
2306
  if (params?.replyMarkup) {
2299
2307
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "replyMarkup");
@@ -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];
@@ -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);
@@ -1,4 +1,4 @@
1
- import { VECTOR_CONSTRUCTOR } from "../4_constants.js";
1
+ import { VECTOR_CONSTRUCTOR } from "../1_utilities.js";
2
2
  import { TLRawWriter } from "./0_tl_raw_writer.js";
3
3
  import { serialize } from "./1_tl_object.js";
4
4
  export class TLWriter extends TLRawWriter {
@@ -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
+ }
@@ -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";
@@ -6,7 +6,7 @@ export interface CallbackQuery {
6
6
  id: string;
7
7
  from: User;
8
8
  message?: Message;
9
- inlineMessageId?: number;
9
+ inlineMessageId?: string;
10
10
  chatInstance?: string;
11
11
  data?: string;
12
12
  gameShortName?: string;
@@ -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: Number(callbackQuery.msg_id.id), chatInstance, data, gameShortName });
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;
@@ -26,3 +26,5 @@ export function mustPromptOneOf(message, choices) {
26
26
  }
27
27
  return result;
28
28
  }
29
+ export const ZERO_CHANNEL_ID = -1000000000000;
30
+ export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.122",
3
+ "version": "0.1.124",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -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);
@@ -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.122";
7
+ export declare const APP_VERSION = "MTKruto 0.1.124";
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;
@@ -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.ZERO_CHANNEL_ID = 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.VECTOR_CONSTRUCTOR = exports.PUBLIC_KEYS = exports.ACK_THRESHOLD = void 0;
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.122";
82
+ exports.APP_VERSION = "MTKruto 0.1.124";
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: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
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
  /**
@@ -150,7 +150,6 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
150
150
  * Alias for `invoke` with its second parameter being `true`.
151
151
  */
152
152
  send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
153
- checkGap(pts: number, ptsCount: number): Promise<void>;
154
153
  getUserAccessHash(userId: bigint): Promise<bigint>;
155
154
  getInputPeer(id: ChatID): Promise<import("../tl/2_types.js").InputPeerChat_ | import("../tl/2_types.js").InputPeerUser_ | import("../tl/2_types.js").InputPeerChannel_>;
156
155
  private [getEntity];
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- 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
+ 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_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _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;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Client = exports.ConnectionError = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
16
16
  const _0_deps_js_1 = require("../0_deps.js");
@@ -342,6 +342,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
342
342
  });
343
343
  _Client_handleUpdateQueue.set(this, new _1_utilities_js_1.Queue("handleUpdate"));
344
344
  _Client_processUpdatesQueue.set(this, new _1_utilities_js_1.Queue("processUpdates"));
345
+ _Client_lastUpdates.set(this, new Date());
345
346
  _Client_lastGetMe.set(this, null);
346
347
  _Client_usernameResolver.set(this, async (v) => {
347
348
  const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
@@ -470,7 +471,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
470
471
  release();
471
472
  }
472
473
  }
473
- async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
474
+ async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
474
475
  __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
475
476
  await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), _0_utilities_js_1.resolve);
476
477
  });
@@ -687,6 +688,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
687
688
  await this.connect();
688
689
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
689
690
  if (!__classPrivateFieldGet(this, _Client_authKeyWasCreated, "f")) {
691
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_fetchState).call(this, "start"));
690
692
  return;
691
693
  }
692
694
  try {
@@ -708,12 +710,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
708
710
  send(function_) {
709
711
  return this.invoke(function_, true);
710
712
  }
711
- async checkGap(pts, ptsCount) {
712
- const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
713
- if (localState.pts + ptsCount < pts) {
714
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
715
- }
716
- }
717
713
  async getUserAccessHash(userId) {
718
714
  const users = await this.invoke(new _2_tl_js_1.functions.users.getUsers({ id: [new _2_tl_js_1.types.InputUser({ user_id: userId, access_hash: 0n })] }));
719
715
  return users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User).access_hash ?? 0n;
@@ -873,7 +869,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
873
869
  while (this.connected) {
874
870
  await new Promise((r) => setTimeout(r, __classPrivateFieldGet(this, _Client_pingInterval, "f")));
875
871
  try {
876
- await this.invoke(new _2_tl_js_1.functions.ping_delay_disconnect({ ping_id: (0, _1_utilities_js_1.getRandomBigInt)(8, true, false), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") + 15 }));
872
+ await this.invoke(new _2_tl_js_1.functions.ping_delay_disconnect({ ping_id: (0, _1_utilities_js_1.getRandomId)(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 }));
873
+ if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
874
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
875
+ }
877
876
  }
878
877
  catch (err) {
879
878
  d("ping loop error: %o", err);
@@ -975,6 +974,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
975
974
  }
976
975
  }
977
976
  }
977
+ }, _Client_checkGap = async function _Client_checkGap(pts, ptsCount) {
978
+ const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
979
+ if (localState.pts + ptsCount < pts) {
980
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
981
+ }
978
982
  }, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount) {
979
983
  let localPts = await this.storage.getChannelPts(channelId);
980
984
  if (!localPts) {
@@ -984,6 +988,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
984
988
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
985
989
  }
986
990
  }, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
991
+ __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
987
992
  /// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
988
993
  ///
989
994
  /// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
@@ -1054,7 +1059,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1054
1059
  continue;
1055
1060
  }
1056
1061
  if (checkGap) {
1057
- await this.checkGap(update.pts, update.pts_count);
1062
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1058
1063
  }
1059
1064
  localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1060
1065
  originalPts ??= localState.pts;
@@ -1224,7 +1229,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1224
1229
  const pts_ = await this.storage.getChannelPts(channelId);
1225
1230
  let pts = pts_ == null ? 1 : pts_;
1226
1231
  while (true) {
1227
- const { access_hash } = await this.getInputPeer(_4_constants_js_1.ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerChannel));
1232
+ 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
1233
  const difference = await this.invoke(new _2_tl_js_1.functions.updates.getChannelDifference({
1229
1234
  pts,
1230
1235
  channel: new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash }),
@@ -1318,8 +1323,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1318
1323
  else if (-_4_constants_js_1.MAX_CHAT_ID <= id) {
1319
1324
  return new _2_tl_js_1.types.InputPeerChat({ chat_id: BigInt(Math.abs(id)) });
1320
1325
  }
1321
- else if (_4_constants_js_1.ZERO_CHANNEL_ID - _4_constants_js_1.MAX_CHANNEL_ID <= id && id != _4_constants_js_1.ZERO_CHANNEL_ID) {
1322
- const id_ = BigInt(Math.abs(id - _4_constants_js_1.ZERO_CHANNEL_ID));
1326
+ 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) {
1327
+ const id_ = BigInt(Math.abs(id - _1_utilities_js_1.ZERO_CHANNEL_ID));
1323
1328
  const accessHash = await this.storage.getChannelAccessHash(id_);
1324
1329
  return new _2_tl_js_1.types.InputPeerChannel({ channel_id: id_, access_hash: accessHash ?? 0n });
1325
1330
  }
@@ -2300,6 +2305,9 @@ async function _Client_handleUpdate(update) {
2300
2305
  else if (update instanceof _2_tl_js_1.types.UpdateBotInlineQuery) {
2301
2306
  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
2307
  }
2308
+ else if (update instanceof _2_tl_js_1.types.UpdateBotInlineSend) {
2309
+ 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);
2310
+ }
2303
2311
  }, _Client_constructReplyMarkup = async function _Client_constructReplyMarkup(params) {
2304
2312
  if (params?.replyMarkup) {
2305
2313
  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 > _4_constants_js_1.ZERO_CHANNEL_ID) {
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);
@@ -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 _4_constants_js_1.ZERO_CHANNEL_ID + -Number(channelId);
7
+ return _1_utilities_js_1.ZERO_CHANNEL_ID + -Number(channelId);
9
8
  }
10
9
  exports.getChannelChatId = getChannelChatId;
11
10
  function peerToChatId(peer) {
@@ -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_constants_js_1 = require("../4_constants.js");
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(_4_constants_js_1.VECTOR_CONSTRUCTOR, false);
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);
@@ -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 = _4_constants_js_1.ZERO_CHANNEL_ID + -Number(chat.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 = _4_constants_js_1.ZERO_CHANNEL_ID + -Number(chat.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 = _4_constants_js_1.ZERO_CHANNEL_ID + Number(-message_.action.channel_id);
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);
@@ -6,7 +6,7 @@ export interface CallbackQuery {
6
6
  id: string;
7
7
  from: User;
8
8
  message?: Message;
9
- inlineMessageId?: number;
9
+ inlineMessageId?: string;
10
10
  chatInstance?: string;
11
11
  data?: string;
12
12
  gameShortName?: string;
@@ -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: Number(callbackQuery.msg_id.id), chatInstance, data, gameShortName });
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;