@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
@@ -17,23 +17,21 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
+ 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");
23
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
+ };
20
25
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
26
  if (kind === "m") throw new TypeError("Private method is not writable");
22
27
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
28
  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");
24
29
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
30
  };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- 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");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_authString, _StorageMemory_fixKey, _StorageMemory_getEntries;
32
- import { Storage } from "./0_storage.js";
31
+ var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_fixKey, _StorageMemory_getEntries;
33
32
  import { fromString, isInRange, toString } from "./1_utilities.js";
34
- export class StorageMemory extends Storage {
35
- constructor(authString) {
36
- super();
33
+ export class StorageMemory {
34
+ constructor() {
37
35
  _StorageMemory_instances.add(this);
38
36
  Object.defineProperty(this, "map", {
39
37
  enumerable: true,
@@ -42,16 +40,11 @@ export class StorageMemory extends Storage {
42
40
  value: new Map()
43
41
  });
44
42
  _StorageMemory_id.set(this, null);
45
- _StorageMemory_authString.set(this, void 0);
46
- __classPrivateFieldSet(this, _StorageMemory_authString, authString, "f");
47
43
  }
48
- get isMemoryStorage() {
49
- return true;
44
+ get mustSerialize() {
45
+ return false;
50
46
  }
51
- async initialize() {
52
- if (__classPrivateFieldGet(this, _StorageMemory_authString, "f")) {
53
- await this.importAuthString(__classPrivateFieldGet(this, _StorageMemory_authString, "f"));
54
- }
47
+ initialize() {
55
48
  }
56
49
  branch(id) {
57
50
  const storage = new StorageMemory();
@@ -106,7 +99,7 @@ export class StorageMemory extends Storage {
106
99
  this.set(key, (this.get(key) || 0) + by);
107
100
  }
108
101
  }
109
- _StorageMemory_id = new WeakMap(), _StorageMemory_authString = new WeakMap(), _StorageMemory_instances = new WeakSet(), _StorageMemory_fixKey = function _StorageMemory_fixKey(key) {
102
+ _StorageMemory_id = new WeakMap(), _StorageMemory_instances = new WeakSet(), _StorageMemory_fixKey = function _StorageMemory_fixKey(key) {
110
103
  if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null) {
111
104
  return ["__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"), ...key];
112
105
  }
@@ -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;
@@ -29,20 +29,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
29
29
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
30
  };
31
31
  var _StorageSessionStorage_prefix;
32
- import { Storage } from "./0_storage.js";
33
32
  import { fromString, isInRange, toString } from "./1_utilities.js";
34
- export class StorageSessionStorage extends Storage {
33
+ export class StorageSessionStorage {
35
34
  constructor(prefix) {
35
+ _StorageSessionStorage_prefix.set(this, void 0);
36
36
  if (typeof sessionStorage === "undefined") {
37
37
  throw new Error("Unavailable in current environment");
38
38
  }
39
39
  if (prefix.length <= 0) {
40
40
  throw new Error("Empty prefix");
41
41
  }
42
- super();
43
- _StorageSessionStorage_prefix.set(this, void 0);
44
42
  __classPrivateFieldSet(this, _StorageSessionStorage_prefix, prefix, "f");
45
43
  }
44
+ get mustSerialize() {
45
+ return true;
46
+ }
46
47
  get prefix() {
47
48
  return __classPrivateFieldGet(this, _StorageSessionStorage_prefix, "f");
48
49
  }
@@ -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;
@@ -24,13 +24,13 @@ export function getChannelChatId(channelId) {
24
24
  return ZERO_CHANNEL_ID + -Number(channelId);
25
25
  }
26
26
  export function peerToChatId(peer) {
27
- if (peer instanceof types.PeerUser || peer instanceof types.InputPeerUser || peer instanceof types.User || "user_id" in peer) {
27
+ if (peer instanceof types.PeerUser || peer instanceof types.InputPeerUser || peer instanceof types.User || peer instanceof types.UserFull || "user_id" in peer) {
28
28
  return Number("id" in peer ? peer.id : peer.user_id);
29
29
  }
30
- else if (peer instanceof types.PeerChat || peer instanceof types.InputPeerChat || peer instanceof types.Chat || peer instanceof types.ChatForbidden || "chat_id" in peer) {
30
+ else if (peer instanceof types.PeerChat || peer instanceof types.InputPeerChat || peer instanceof types.Chat || peer instanceof types.ChatForbidden || peer instanceof types.ChatFull || "chat_id" in peer) {
31
31
  return -Number("id" in peer ? peer.id : peer.chat_id);
32
32
  }
33
- else if (peer instanceof types.PeerChannel || peer instanceof types.InputPeerChannel || peer instanceof types.Channel || peer instanceof types.ChannelForbidden || "channel_id" in peer) {
33
+ else if (peer instanceof types.PeerChannel || peer instanceof types.InputPeerChannel || peer instanceof types.Channel || peer instanceof types.ChannelForbidden || peer instanceof types.ChannelFull || "channel_id" in peer) {
34
34
  return getChannelChatId("id" in peer ? peer.id : peer.channel_id);
35
35
  }
36
36
  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,26 @@
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
+ export function constructBirthday(birthday) {
21
+ return {
22
+ day: birthday.day,
23
+ month: birthday.month,
24
+ year: birthday.year,
25
+ };
26
+ }
@@ -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,26 @@
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
+ export function constructLiveStreamChannel(channel) {
21
+ return {
22
+ id: channel.channel,
23
+ scale: channel.scale,
24
+ timestamp: Number(channel.last_timestamp_ms),
25
+ };
26
+ }
@@ -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,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
+ export function constructOpeningHours(hours) {
21
+ return {
22
+ timezone: hours.timezone_id,
23
+ intervals: hours.weekly_open.map((v) => [v.start_minute, v.end_minute]),
24
+ };
25
+ }
@@ -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,53 @@
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 { fromUnixTimestamp } from "../1_utilities.js";
21
+ import { types } from "../2_tl.js";
22
+ export function constructVideoChat(call) {
23
+ const id = String(call.id);
24
+ if (call instanceof types.GroupCallDiscarded) {
25
+ return {
26
+ id,
27
+ duration: call.duration,
28
+ };
29
+ }
30
+ else {
31
+ const title = call.title ?? "";
32
+ const liveStream = call.rtmp_stream ? true : false;
33
+ const participantCount = call.participants_count;
34
+ if (call.schedule_date) {
35
+ return {
36
+ id,
37
+ title,
38
+ scheduledFor: fromUnixTimestamp(call.schedule_date),
39
+ liveStream,
40
+ participantCount,
41
+ };
42
+ }
43
+ else {
44
+ return {
45
+ id,
46
+ title,
47
+ liveStream,
48
+ recording: call.record_video_active ? true : false,
49
+ participantCount,
50
+ };
51
+ }
52
+ }
53
+ }
@@ -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. */
@@ -96,6 +96,7 @@ export function constructChatP(chat) {
96
96
  };
97
97
  }
98
98
  chat_.username = chat.username ?? chat.usernames?.[0].username;
99
+ chat_.also = chat.usernames?.map((v) => v.username).filter((v) => v != chat_.username);
99
100
  if (chat_.isRestricted) {
100
101
  chat_.restrictionReason = (chat.restriction_reason ?? []).map(constructRestrictionReason);
101
102
  }
@@ -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,66 @@
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 { unreachable } from "../0_deps.js";
21
+ import { types } from "../2_tl.js";
22
+ import { constructOpeningHours } from "./0_opening_hours.js";
23
+ import { constructChatP } from "./1_chat_p.js";
24
+ import { constructPhoto } from "./1_photo.js";
25
+ import { constructLocation } from "./0_location.js";
26
+ import { constructBirthday } from "./0_birthday.js";
27
+ import { cleanObject } from "../1_utilities.js";
28
+ export async function constructChat(fullChat, getEntity) {
29
+ if (fullChat instanceof types.UserFull) {
30
+ const user = await getEntity(new types.PeerUser({ user_id: fullChat.id }));
31
+ if (user == null)
32
+ unreachable();
33
+ const chatP = constructChatP(user);
34
+ return cleanObject({
35
+ ...chatP,
36
+ birthday: fullChat.birthday ? constructBirthday(fullChat.birthday) : undefined,
37
+ photo: fullChat.profile_photo && fullChat.profile_photo instanceof types.Photo ? constructPhoto(fullChat.profile_photo) : undefined,
38
+ address: fullChat.business_location?.address,
39
+ location: fullChat.business_location?.geo_point && fullChat.business_location.geo_point instanceof types.GeoPoint ? constructLocation(fullChat.business_location.geo_point) : undefined,
40
+ openingHours: fullChat.business_work_hours ? constructOpeningHours(fullChat.business_work_hours) : undefined,
41
+ });
42
+ }
43
+ else if (fullChat instanceof types.ChatFull) {
44
+ const chat = await getEntity(new types.PeerChat({ chat_id: fullChat.id }));
45
+ if (chat == null)
46
+ unreachable();
47
+ const chatP = constructChatP(chat);
48
+ return cleanObject({
49
+ ...chatP,
50
+ photo: fullChat.chat_photo && fullChat.chat_photo instanceof types.Photo ? constructPhoto(fullChat.chat_photo) : undefined,
51
+ videoChatId: fullChat.call ? String(fullChat.call.id) : undefined,
52
+ });
53
+ }
54
+ else if (fullChat instanceof types.ChannelFull) {
55
+ const chat = await getEntity(new types.PeerChannel({ channel_id: fullChat.id }));
56
+ if (chat == null)
57
+ unreachable();
58
+ const chatP = constructChatP(chat);
59
+ return cleanObject({
60
+ ...chatP,
61
+ photo: fullChat.chat_photo && fullChat.chat_photo instanceof types.Photo ? constructPhoto(fullChat.chat_photo) : undefined,
62
+ videoChatId: fullChat.call ? String(fullChat.call.id) : undefined,
63
+ });
64
+ }
65
+ unreachable();
66
+ }
@@ -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;
@@ -27,7 +27,7 @@ export interface MessageReactionCount {
27
27
  chat: ChatP;
28
28
  /** The message's identifier. */
29
29
  messageId: number;
30
- /** This reaction state's point of time. */
30
+ /** The point in time in which the change was made. */
31
31
  date: Date;
32
32
  /** The reactions made to the post. */
33
33
  reactions: ReactionCount[];
@@ -32,7 +32,7 @@ export interface MessageReactions {
32
32
  user?: User;
33
33
  /** The chat that changed its reactions to the message. Unset if done on behalf of a user. */
34
34
  actorChat?: ChatP;
35
- /** The point of time in which the change was made. */
35
+ /** The point in time in which the change was made. */
36
36
  date: Date;
37
37
  /** The previous reactions. */
38
38
  oldReactions: Reaction[];