@mtkruto/node 0.1.500 → 0.1.700

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 (179) hide show
  1. package/esm/3_types.d.ts +6 -1
  2. package/esm/3_types.js +6 -1
  3. package/esm/4_errors.js +2 -4
  4. package/esm/5_client.d.ts +1 -1
  5. package/esm/5_client.js +1 -1
  6. package/esm/client/0_params.d.ts +33 -7
  7. package/esm/client/0_storage_operations.d.ts +182 -0
  8. package/esm/client/0_storage_operations.js +611 -0
  9. package/esm/client/1_composer.d.ts +2 -0
  10. package/esm/client/1_composer.js +28 -0
  11. package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
  12. package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
  13. package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
  14. package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  15. package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
  16. package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
  17. package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  18. package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
  19. package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
  20. package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  21. package/esm/client/3_video_chat_manager.d.ts +43 -0
  22. package/esm/client/3_video_chat_manager.js +194 -0
  23. package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  24. package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  25. package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
  26. package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
  27. package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  28. package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  29. package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  30. package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
  31. package/esm/client/{4_client.js → 5_client.js} +172 -73
  32. package/esm/connection/0_connection.d.ts +6 -15
  33. package/esm/connection/0_connection.js +1 -38
  34. package/esm/connection/1_connection_web_socket.d.ts +3 -2
  35. package/esm/connection/1_connection_web_socket.js +7 -3
  36. package/esm/mod.d.ts +1 -1
  37. package/esm/mod.js +1 -1
  38. package/esm/storage/0_storage.d.ts +9 -145
  39. package/esm/storage/0_storage.js +1 -526
  40. package/esm/storage/2_storage_indexed_db.d.ts +3 -2
  41. package/esm/storage/2_storage_indexed_db.js +9 -8
  42. package/esm/storage/2_storage_local_storage.d.ts +3 -2
  43. package/esm/storage/2_storage_local_storage.js +5 -4
  44. package/esm/storage/2_storage_memory.d.ts +4 -4
  45. package/esm/storage/2_storage_memory.js +12 -19
  46. package/esm/storage/2_storage_session_storage.d.ts +2 -1
  47. package/esm/storage/2_storage_session_storage.js +5 -4
  48. package/esm/tl/3_utilities.d.ts +1 -1
  49. package/esm/tl/3_utilities.js +3 -3
  50. package/esm/types/0_birthday.d.ts +27 -0
  51. package/esm/types/0_birthday.js +26 -0
  52. package/esm/types/0_giveaway_parameters.d.ts +1 -1
  53. package/esm/types/0_id.d.ts +1 -1
  54. package/esm/types/0_live_stream_channel.d.ts +30 -0
  55. package/esm/types/0_live_stream_channel.js +26 -0
  56. package/esm/types/0_opening_hours.d.ts +25 -0
  57. package/esm/types/0_opening_hours.js +25 -0
  58. package/esm/types/0_video_chat.d.ts +60 -0
  59. package/esm/types/0_video_chat.js +53 -0
  60. package/esm/types/1_chat_p.d.ts +4 -0
  61. package/esm/types/1_chat_p.js +1 -0
  62. package/esm/types/2_business_connection.d.ts +6 -0
  63. package/esm/types/2_chat.d.ts +62 -0
  64. package/esm/types/2_chat.js +66 -0
  65. package/esm/types/2_inactive_chat.d.ts +1 -1
  66. package/esm/types/2_invite_link.d.ts +1 -1
  67. package/esm/types/2_message_reaction_count.d.ts +1 -1
  68. package/esm/types/2_message_reactions.d.ts +1 -1
  69. package/esm/types/3_chat_member_updated.d.ts +1 -1
  70. package/esm/types/4_message.d.ts +3 -3
  71. package/esm/types/5_chat_list_item.d.ts +35 -0
  72. package/esm/types/5_chat_list_item.js +86 -0
  73. package/esm/types/6_update.d.ts +14 -5
  74. package/esm/types/_file_id.d.ts +1 -0
  75. package/esm/utilities/0_bigint.d.ts +1 -0
  76. package/esm/utilities/0_bigint.js +7 -3
  77. package/package.json +1 -1
  78. package/script/3_types.d.ts +6 -1
  79. package/script/3_types.js +6 -1
  80. package/script/4_errors.js +2 -4
  81. package/script/5_client.d.ts +1 -1
  82. package/script/5_client.js +1 -1
  83. package/script/client/0_params.d.ts +33 -7
  84. package/script/client/0_storage_operations.d.ts +182 -0
  85. package/script/client/0_storage_operations.js +615 -0
  86. package/script/client/1_composer.d.ts +2 -0
  87. package/script/client/1_composer.js +28 -0
  88. package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
  89. package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
  90. package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
  91. package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  92. package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
  93. package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
  94. package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  95. package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
  96. package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
  97. package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  98. package/script/client/3_video_chat_manager.d.ts +43 -0
  99. package/script/client/3_video_chat_manager.js +198 -0
  100. package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  101. package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  102. package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
  103. package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
  104. package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  105. package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  106. package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  107. package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
  108. package/script/client/{4_client.js → 5_client.js} +192 -93
  109. package/script/connection/0_connection.d.ts +6 -15
  110. package/script/connection/0_connection.js +0 -41
  111. package/script/connection/1_connection_web_socket.d.ts +3 -2
  112. package/script/connection/1_connection_web_socket.js +7 -3
  113. package/script/mod.d.ts +1 -1
  114. package/script/mod.js +1 -1
  115. package/script/storage/0_storage.d.ts +9 -145
  116. package/script/storage/0_storage.js +0 -528
  117. package/script/storage/2_storage_indexed_db.d.ts +3 -2
  118. package/script/storage/2_storage_indexed_db.js +9 -8
  119. package/script/storage/2_storage_local_storage.d.ts +3 -2
  120. package/script/storage/2_storage_local_storage.js +5 -4
  121. package/script/storage/2_storage_memory.d.ts +4 -4
  122. package/script/storage/2_storage_memory.js +12 -19
  123. package/script/storage/2_storage_session_storage.d.ts +2 -1
  124. package/script/storage/2_storage_session_storage.js +5 -4
  125. package/script/tl/3_utilities.d.ts +1 -1
  126. package/script/tl/3_utilities.js +3 -3
  127. package/script/types/0_birthday.d.ts +27 -0
  128. package/script/types/0_birthday.js +30 -0
  129. package/script/types/0_giveaway_parameters.d.ts +1 -1
  130. package/script/types/0_id.d.ts +1 -1
  131. package/script/types/0_live_stream_channel.d.ts +30 -0
  132. package/script/types/0_live_stream_channel.js +30 -0
  133. package/script/types/0_opening_hours.d.ts +25 -0
  134. package/script/types/0_opening_hours.js +29 -0
  135. package/script/types/0_video_chat.d.ts +60 -0
  136. package/script/types/0_video_chat.js +57 -0
  137. package/script/types/1_chat_p.d.ts +4 -0
  138. package/script/types/1_chat_p.js +1 -0
  139. package/script/types/2_business_connection.d.ts +6 -0
  140. package/script/types/2_chat.d.ts +62 -0
  141. package/script/types/2_chat.js +70 -0
  142. package/script/types/2_inactive_chat.d.ts +1 -1
  143. package/script/types/2_invite_link.d.ts +1 -1
  144. package/script/types/2_message_reaction_count.d.ts +1 -1
  145. package/script/types/2_message_reactions.d.ts +1 -1
  146. package/script/types/3_chat_member_updated.d.ts +1 -1
  147. package/script/types/4_message.d.ts +3 -3
  148. package/script/types/5_chat_list_item.d.ts +35 -0
  149. package/script/types/5_chat_list_item.js +94 -0
  150. package/script/types/6_update.d.ts +14 -5
  151. package/script/types/_file_id.d.ts +1 -0
  152. package/script/utilities/0_bigint.d.ts +1 -0
  153. package/script/utilities/0_bigint.js +7 -3
  154. package/esm/types/5_chat.d.ts +0 -59
  155. package/esm/types/5_chat.js +0 -126
  156. package/script/types/5_chat.d.ts +0 -59
  157. package/script/types/5_chat.js +0 -134
  158. /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  159. /package/esm/{3_storage.js → 2_storage.js} +0 -0
  160. /package/esm/client/{0_types.js → 1_types.js} +0 -0
  161. /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  162. /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  163. /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  164. /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  165. /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  166. /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  167. /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  168. /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
  169. /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  170. /package/script/{3_storage.js → 2_storage.js} +0 -0
  171. /package/script/client/{0_types.js → 1_types.js} +0 -0
  172. /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  173. /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  174. /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  175. /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  176. /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  177. /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  178. /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  179. /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
@@ -18,25 +18,23 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
22
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
23
+ 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");
24
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
25
+ };
21
26
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
27
  if (kind === "m") throw new TypeError("Private method is not writable");
23
28
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
29
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
30
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
31
  };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- 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");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_authString, _StorageMemory_fixKey, _StorageMemory_getEntries;
32
+ var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_fixKey, _StorageMemory_getEntries;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.StorageMemory = void 0;
35
- const _0_storage_js_1 = require("./0_storage.js");
36
35
  const _1_utilities_js_1 = require("./1_utilities.js");
37
- class StorageMemory extends _0_storage_js_1.Storage {
38
- constructor(authString) {
39
- super();
36
+ class StorageMemory {
37
+ constructor() {
40
38
  _StorageMemory_instances.add(this);
41
39
  Object.defineProperty(this, "map", {
42
40
  enumerable: true,
@@ -45,16 +43,11 @@ class StorageMemory extends _0_storage_js_1.Storage {
45
43
  value: new Map()
46
44
  });
47
45
  _StorageMemory_id.set(this, null);
48
- _StorageMemory_authString.set(this, void 0);
49
- __classPrivateFieldSet(this, _StorageMemory_authString, authString, "f");
50
46
  }
51
- get isMemoryStorage() {
52
- return true;
47
+ get mustSerialize() {
48
+ return false;
53
49
  }
54
- async initialize() {
55
- if (__classPrivateFieldGet(this, _StorageMemory_authString, "f")) {
56
- await this.importAuthString(__classPrivateFieldGet(this, _StorageMemory_authString, "f"));
57
- }
50
+ initialize() {
58
51
  }
59
52
  branch(id) {
60
53
  const storage = new StorageMemory();
@@ -110,7 +103,7 @@ class StorageMemory extends _0_storage_js_1.Storage {
110
103
  }
111
104
  }
112
105
  exports.StorageMemory = StorageMemory;
113
- _StorageMemory_id = new WeakMap(), _StorageMemory_authString = new WeakMap(), _StorageMemory_instances = new WeakSet(), _StorageMemory_fixKey = function _StorageMemory_fixKey(key) {
106
+ _StorageMemory_id = new WeakMap(), _StorageMemory_instances = new WeakSet(), _StorageMemory_fixKey = function _StorageMemory_fixKey(key) {
114
107
  if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null) {
115
108
  return ["__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"), ...key];
116
109
  }
@@ -19,9 +19,10 @@
19
19
  */
20
20
  import { MaybePromise } from "../1_utilities.js";
21
21
  import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
22
- export declare class StorageSessionStorage extends Storage implements Storage {
22
+ export declare class StorageSessionStorage implements Storage {
23
23
  #private;
24
24
  constructor(prefix: string);
25
+ get mustSerialize(): boolean;
25
26
  get prefix(): string;
26
27
  branch(id: string): StorageSessionStorage;
27
28
  initialize(): void;
@@ -32,20 +32,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
32
32
  var _StorageSessionStorage_prefix;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.StorageSessionStorage = void 0;
35
- const _0_storage_js_1 = require("./0_storage.js");
36
35
  const _1_utilities_js_1 = require("./1_utilities.js");
37
- class StorageSessionStorage extends _0_storage_js_1.Storage {
36
+ class StorageSessionStorage {
38
37
  constructor(prefix) {
38
+ _StorageSessionStorage_prefix.set(this, void 0);
39
39
  if (typeof sessionStorage === "undefined") {
40
40
  throw new Error("Unavailable in current environment");
41
41
  }
42
42
  if (prefix.length <= 0) {
43
43
  throw new Error("Empty prefix");
44
44
  }
45
- super();
46
- _StorageSessionStorage_prefix.set(this, void 0);
47
45
  __classPrivateFieldSet(this, _StorageSessionStorage_prefix, prefix, "f");
48
46
  }
47
+ get mustSerialize() {
48
+ return true;
49
+ }
49
50
  get prefix() {
50
51
  return __classPrivateFieldGet(this, _StorageSessionStorage_prefix, "f");
51
52
  }
@@ -20,7 +20,7 @@
20
20
  import { enums, types } from "./2_types.js";
21
21
  export declare function getChannelChatId(channelId: bigint): number;
22
22
  export type AnyEntity = types.User | types.Channel | types.ChannelForbidden | types.Chat | types.ChatForbidden;
23
- export declare function peerToChatId(peer: enums.Peer | enums.InputPeer | AnyEntity | {
23
+ export declare function peerToChatId(peer: enums.Peer | enums.InputPeer | AnyEntity | types.ChannelFull | types.UserFull | types.ChatFull | {
24
24
  channel_id: bigint;
25
25
  } | {
26
26
  user_id: bigint;
@@ -28,13 +28,13 @@ function getChannelChatId(channelId) {
28
28
  }
29
29
  exports.getChannelChatId = getChannelChatId;
30
30
  function peerToChatId(peer) {
31
- if (peer instanceof _2_types_js_1.types.PeerUser || peer instanceof _2_types_js_1.types.InputPeerUser || peer instanceof _2_types_js_1.types.User || "user_id" in peer) {
31
+ if (peer instanceof _2_types_js_1.types.PeerUser || peer instanceof _2_types_js_1.types.InputPeerUser || peer instanceof _2_types_js_1.types.User || peer instanceof _2_types_js_1.types.UserFull || "user_id" in peer) {
32
32
  return Number("id" in peer ? peer.id : peer.user_id);
33
33
  }
34
- else if (peer instanceof _2_types_js_1.types.PeerChat || peer instanceof _2_types_js_1.types.InputPeerChat || peer instanceof _2_types_js_1.types.Chat || peer instanceof _2_types_js_1.types.ChatForbidden || "chat_id" in peer) {
34
+ else if (peer instanceof _2_types_js_1.types.PeerChat || peer instanceof _2_types_js_1.types.InputPeerChat || peer instanceof _2_types_js_1.types.Chat || peer instanceof _2_types_js_1.types.ChatForbidden || peer instanceof _2_types_js_1.types.ChatFull || "chat_id" in peer) {
35
35
  return -Number("id" in peer ? peer.id : peer.chat_id);
36
36
  }
37
- else if (peer instanceof _2_types_js_1.types.PeerChannel || peer instanceof _2_types_js_1.types.InputPeerChannel || peer instanceof _2_types_js_1.types.Channel || peer instanceof _2_types_js_1.types.ChannelForbidden || "channel_id" in peer) {
37
+ else if (peer instanceof _2_types_js_1.types.PeerChannel || peer instanceof _2_types_js_1.types.InputPeerChannel || peer instanceof _2_types_js_1.types.Channel || peer instanceof _2_types_js_1.types.ChannelForbidden || peer instanceof _2_types_js_1.types.ChannelFull || "channel_id" in peer) {
38
38
  return getChannelChatId("id" in peer ? peer.id : peer.channel_id);
39
39
  }
40
40
  else {
@@ -0,0 +1,27 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { types } from "../2_tl.js";
21
+ /** A user's birthday. */
22
+ export interface Birthday {
23
+ day: number;
24
+ month: number;
25
+ year?: number;
26
+ }
27
+ export declare function constructBirthday(birthday: types.Birthday): Birthday;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructBirthday = void 0;
23
+ function constructBirthday(birthday) {
24
+ return {
25
+ day: birthday.day,
26
+ month: birthday.month,
27
+ year: birthday.year,
28
+ };
29
+ }
30
+ exports.constructBirthday = constructBirthday;
@@ -24,7 +24,7 @@ export interface GiveawayParameters {
24
24
  boostedChatId: number;
25
25
  /** The identifiers of additional chats that the user must subscribe to in order to be eligible for the prizes. */
26
26
  additionalChatIds: number[];
27
- /** The point of time in which the winners will be chosen. */
27
+ /** A point in time within the future in which the winners will be selected. */
28
28
  winnerSelectionDate: Date;
29
29
  /** Whether only new members of the chats will be eligible for the prizes. */
30
30
  onlyNewMembers: boolean;
@@ -18,6 +18,6 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  /**
21
- * The identifier of a channel, a group, or a user (as provided by MTKruto), a username, or a chat link (e.g., https://mtkruto.t.me, https://telegram.me/mtkruto). `"me"` resolves to the currently authorized account.
21
+ * The identifier of a channel, a group, or a user (as provided by MTKruto), a username, or a chat link (e.g., https://mtkruto.t.me, https://telegram.me/mtkruto). `"me"` resolves to current the account.
22
22
  */
23
23
  export type ID = number | string | "me";
@@ -0,0 +1,30 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { types } from "../2_tl.js";
21
+ /** A live stream channel. */
22
+ export interface LiveStreamChannel {
23
+ /** The live stream channel's unique identifier. */
24
+ id: number;
25
+ /** The scale of the live stream channel's chunks. Duration of each chunk is equal to 1000 / 2 ^ scale. ` */
26
+ scale: number;
27
+ /** The live stream channel's last timestamp. */
28
+ timestamp: number;
29
+ }
30
+ export declare function constructLiveStreamChannel(channel: types.GroupCallStreamChannel): LiveStreamChannel;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructLiveStreamChannel = void 0;
23
+ function constructLiveStreamChannel(channel) {
24
+ return {
25
+ id: channel.channel,
26
+ scale: channel.scale,
27
+ timestamp: Number(channel.last_timestamp_ms),
28
+ };
29
+ }
30
+ exports.constructLiveStreamChannel = constructLiveStreamChannel;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { types } from "../2_tl.js";
21
+ export interface OpeningHours {
22
+ timezone: string;
23
+ intervals: [number, number][];
24
+ }
25
+ export declare function constructOpeningHours(hours: types.BusinessWorkHours): OpeningHours;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructOpeningHours = void 0;
23
+ function constructOpeningHours(hours) {
24
+ return {
25
+ timezone: hours.timezone_id,
26
+ intervals: hours.weekly_open.map((v) => [v.start_minute, v.end_minute]),
27
+ };
28
+ }
29
+ exports.constructOpeningHours = constructOpeningHours;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { enums } from "../2_tl.js";
21
+ /** @unlisted */
22
+ export interface _VideoChatCommon {
23
+ /** The video chat's unique identifier. */
24
+ id: string;
25
+ }
26
+ /** @unlisted */
27
+ export interface _VideoChatNotEndedCommon {
28
+ /** The video chat's title. */
29
+ title: string;
30
+ /** Whether it is a live stream. */
31
+ liveStream: boolean;
32
+ /** The number of current participants. */
33
+ participantCount: number;
34
+ }
35
+ /**
36
+ * An ongoing video chat.
37
+ * @unlisted
38
+ */
39
+ export interface VideoChatActive extends _VideoChatCommon, _VideoChatNotEndedCommon {
40
+ /** Whether the video chat is being recorded. */
41
+ recording: boolean;
42
+ }
43
+ /**
44
+ * A scheduled video chat.
45
+ * @unlisted
46
+ */
47
+ export interface VideoChatScheduled extends _VideoChatCommon, _VideoChatNotEndedCommon {
48
+ /** The point in time in which the video chat will be started. */
49
+ scheduledFor: Date;
50
+ }
51
+ /**
52
+ * An ended video chat.
53
+ * @unlisted
54
+ */
55
+ export interface VideoChatEnded extends _VideoChatCommon {
56
+ /** The duration of the video chat in seconds. */
57
+ duration: number;
58
+ }
59
+ export type VideoChat = VideoChatActive | VideoChatScheduled | VideoChatEnded;
60
+ export declare function constructVideoChat(call: enums.GroupCall): VideoChat;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructVideoChat = void 0;
23
+ const _1_utilities_js_1 = require("../1_utilities.js");
24
+ const _2_tl_js_1 = require("../2_tl.js");
25
+ function constructVideoChat(call) {
26
+ const id = String(call.id);
27
+ if (call instanceof _2_tl_js_1.types.GroupCallDiscarded) {
28
+ return {
29
+ id,
30
+ duration: call.duration,
31
+ };
32
+ }
33
+ else {
34
+ const title = call.title ?? "";
35
+ const liveStream = call.rtmp_stream ? true : false;
36
+ const participantCount = call.participants_count;
37
+ if (call.schedule_date) {
38
+ return {
39
+ id,
40
+ title,
41
+ scheduledFor: (0, _1_utilities_js_1.fromUnixTimestamp)(call.schedule_date),
42
+ liveStream,
43
+ participantCount,
44
+ };
45
+ }
46
+ else {
47
+ return {
48
+ id,
49
+ title,
50
+ liveStream,
51
+ recording: call.record_video_active ? true : false,
52
+ participantCount,
53
+ };
54
+ }
55
+ }
56
+ }
57
+ exports.constructVideoChat = constructVideoChat;
@@ -41,6 +41,8 @@ export interface ChatPPrivate extends _ChatPBase {
41
41
  lastName?: string;
42
42
  /** The user's main username. */
43
43
  username?: string;
44
+ /** The user's additional usernames. */
45
+ also?: string[];
44
46
  /** Whether the user has been identified as scam. */
45
47
  isScam: boolean;
46
48
  /** Whether the user has been identified as an impersonator. */
@@ -68,6 +70,8 @@ export interface ChatPChannelBase extends _ChatPBase {
68
70
  title: string;
69
71
  /** The main username of the chat or channel. */
70
72
  username?: string;
73
+ /** The chat or channel's additional usernames. */
74
+ also?: string[];
71
75
  /** Whether the chat or channel has been identified as scam. */
72
76
  isScam: boolean;
73
77
  /** Whether the chat or channel has been identified as an impersonator. */
@@ -99,6 +99,7 @@ function constructChatP(chat) {
99
99
  };
100
100
  }
101
101
  chat_.username = chat.username ?? chat.usernames?.[0].username;
102
+ chat_.also = chat.usernames?.map((v) => v.username).filter((v) => v != chat_.username);
102
103
  if (chat_.isRestricted) {
103
104
  chat_.restrictionReason = (chat.restriction_reason ?? []).map(_0_restriction_reason_js_1.constructRestrictionReason);
104
105
  }
@@ -20,11 +20,17 @@
20
20
  import { types } from "../2_tl.js";
21
21
  import { EntityGetter } from "./_getters.js";
22
22
  import { User } from "./1_user.js";
23
+ /** A business connection. */
23
24
  export interface BusinessConnection {
25
+ /** The business connection's unique identifier. */
24
26
  id: string;
27
+ /** The business account that the connection is made with. */
25
28
  user: User;
29
+ /** The point in time in which the connection was recently updated. */
26
30
  date: Date;
31
+ /** Whether the bot can reply to older chats. */
27
32
  canReply: boolean;
33
+ /** Whether the connection is active. */
28
34
  isEnabled: boolean;
29
35
  }
30
36
  export declare function constructBusinessConnection(connection: types.BotBusinessConnection, getEntity: EntityGetter): Promise<BusinessConnection>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { types } from "../2_tl.js";
21
+ import { EntityGetter } from "./_getters.js";
22
+ import { OpeningHours } from "./0_opening_hours.js";
23
+ import { ChatPChannel, ChatPGroup, ChatPPrivate, ChatPSupergroup } from "./1_chat_p.js";
24
+ import { Photo } from "./1_photo.js";
25
+ import { Location } from "./0_location.js";
26
+ import { Birthday } from "./0_birthday.js";
27
+ /** @unlisted */
28
+ export interface ChatBase {
29
+ /** The chat's photo. */
30
+ photo?: Photo;
31
+ }
32
+ /** @unlisted */
33
+ export interface ChatChannel extends ChatBase, ChatPChannel {
34
+ /** The channel's video chat ID. */
35
+ videoChatId?: string;
36
+ }
37
+ /** @unlisted */
38
+ export interface ChatSupergroup extends ChatBase, ChatPSupergroup {
39
+ /** The chat's video chat ID. */
40
+ videoChatId?: string;
41
+ }
42
+ /** @unlisted */
43
+ export interface ChatGroup extends ChatBase, ChatPGroup {
44
+ /** The chat's video chat ID. */
45
+ videoChatId?: string;
46
+ }
47
+ /** @unlisted */
48
+ export interface ChatPrivate extends ChatBase, ChatPPrivate {
49
+ /** The user's birthday. */
50
+ birthday?: Birthday;
51
+ /** The written address of the business. */
52
+ address?: string;
53
+ /** The exact location of the business. */
54
+ location?: Location;
55
+ /** The opening hours of the business. */
56
+ openingHours?: OpeningHours;
57
+ }
58
+ /**
59
+ * A chat with more fields.
60
+ */
61
+ export type Chat = ChatChannel | ChatSupergroup | ChatGroup | ChatPrivate;
62
+ export declare function constructChat(fullChat: types.UserFull | types.ChatFull | types.ChannelFull, getEntity: EntityGetter): Promise<Chat>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructChat = void 0;
23
+ const _0_deps_js_1 = require("../0_deps.js");
24
+ const _2_tl_js_1 = require("../2_tl.js");
25
+ const _0_opening_hours_js_1 = require("./0_opening_hours.js");
26
+ const _1_chat_p_js_1 = require("./1_chat_p.js");
27
+ const _1_photo_js_1 = require("./1_photo.js");
28
+ const _0_location_js_1 = require("./0_location.js");
29
+ const _0_birthday_js_1 = require("./0_birthday.js");
30
+ const _1_utilities_js_1 = require("../1_utilities.js");
31
+ async function constructChat(fullChat, getEntity) {
32
+ if (fullChat instanceof _2_tl_js_1.types.UserFull) {
33
+ const user = await getEntity(new _2_tl_js_1.types.PeerUser({ user_id: fullChat.id }));
34
+ if (user == null)
35
+ (0, _0_deps_js_1.unreachable)();
36
+ const chatP = (0, _1_chat_p_js_1.constructChatP)(user);
37
+ return (0, _1_utilities_js_1.cleanObject)({
38
+ ...chatP,
39
+ birthday: fullChat.birthday ? (0, _0_birthday_js_1.constructBirthday)(fullChat.birthday) : undefined,
40
+ photo: fullChat.profile_photo && fullChat.profile_photo instanceof _2_tl_js_1.types.Photo ? (0, _1_photo_js_1.constructPhoto)(fullChat.profile_photo) : undefined,
41
+ address: fullChat.business_location?.address,
42
+ location: fullChat.business_location?.geo_point && fullChat.business_location.geo_point instanceof _2_tl_js_1.types.GeoPoint ? (0, _0_location_js_1.constructLocation)(fullChat.business_location.geo_point) : undefined,
43
+ openingHours: fullChat.business_work_hours ? (0, _0_opening_hours_js_1.constructOpeningHours)(fullChat.business_work_hours) : undefined,
44
+ });
45
+ }
46
+ else if (fullChat instanceof _2_tl_js_1.types.ChatFull) {
47
+ const chat = await getEntity(new _2_tl_js_1.types.PeerChat({ chat_id: fullChat.id }));
48
+ if (chat == null)
49
+ (0, _0_deps_js_1.unreachable)();
50
+ const chatP = (0, _1_chat_p_js_1.constructChatP)(chat);
51
+ return (0, _1_utilities_js_1.cleanObject)({
52
+ ...chatP,
53
+ photo: fullChat.chat_photo && fullChat.chat_photo instanceof _2_tl_js_1.types.Photo ? (0, _1_photo_js_1.constructPhoto)(fullChat.chat_photo) : undefined,
54
+ videoChatId: fullChat.call ? String(fullChat.call.id) : undefined,
55
+ });
56
+ }
57
+ else if (fullChat instanceof _2_tl_js_1.types.ChannelFull) {
58
+ const chat = await getEntity(new _2_tl_js_1.types.PeerChannel({ channel_id: fullChat.id }));
59
+ if (chat == null)
60
+ (0, _0_deps_js_1.unreachable)();
61
+ const chatP = (0, _1_chat_p_js_1.constructChatP)(chat);
62
+ return (0, _1_utilities_js_1.cleanObject)({
63
+ ...chatP,
64
+ photo: fullChat.chat_photo && fullChat.chat_photo instanceof _2_tl_js_1.types.Photo ? (0, _1_photo_js_1.constructPhoto)(fullChat.chat_photo) : undefined,
65
+ videoChatId: fullChat.call ? String(fullChat.call.id) : undefined,
66
+ });
67
+ }
68
+ (0, _0_deps_js_1.unreachable)();
69
+ }
70
+ exports.constructChat = constructChat;
@@ -21,7 +21,7 @@ import { enums } from "../2_tl.js";
21
21
  import { ChatP } from "./1_chat_p.js";
22
22
  /** An inactive chat. */
23
23
  export interface InactiveChat {
24
- /** The point of time in which the chat was last active. */
24
+ /** The time which the chat was last active. */
25
25
  lastActivity: Date;
26
26
  /** The chat that has been marked as inactive. */
27
27
  chat: ChatP;
@@ -32,7 +32,7 @@ export interface InviteLink {
32
32
  revoked: boolean;
33
33
  /** An optional title. */
34
34
  title?: string;
35
- /** The point of time in which the invite link is expired at. */
35
+ /** A point in time within the future in which the ban will be reverted. */
36
36
  expiresAt?: Date;
37
37
  /** The times the invite link can be used. */
38
38
  limit?: number;