@mtkruto/node 0.0.990 → 0.0.992

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 (254) hide show
  1. package/esm/1_utilities.d.ts +12 -0
  2. package/esm/1_utilities.js +12 -0
  3. package/esm/2_connection.d.ts +2 -0
  4. package/esm/2_connection.js +2 -0
  5. package/esm/2_tl.d.ts +10 -0
  6. package/esm/2_tl.js +10 -0
  7. package/esm/3_storage.d.ts +6 -0
  8. package/esm/3_storage.js +6 -0
  9. package/esm/3_transport.d.ts +4 -0
  10. package/esm/3_transport.js +4 -0
  11. package/esm/3_types.d.ts +35 -0
  12. package/esm/3_types.js +35 -0
  13. package/esm/{constants.d.ts → 4_constants.d.ts} +2 -2
  14. package/esm/{constants.js → 4_constants.js} +1 -1
  15. package/esm/5_client.d.ts +2 -0
  16. package/esm/5_client.js +2 -0
  17. package/esm/client/0_html.d.ts +1 -1
  18. package/esm/client/0_html.js +1 -1
  19. package/esm/client/0_message.d.ts +1 -2
  20. package/esm/client/0_message.js +7 -14
  21. package/esm/client/0_password.d.ts +2 -2
  22. package/esm/client/0_password.js +2 -4
  23. package/esm/client/0_utilities.d.ts +3 -5
  24. package/esm/client/0_utilities.js +3 -22
  25. package/esm/client/1_client_abstract.d.ts +2 -2
  26. package/esm/client/1_client_abstract.js +3 -3
  27. package/esm/client/2_client_plain.d.ts +3 -3
  28. package/esm/client/2_client_plain.js +13 -20
  29. package/esm/client/3_client.d.ts +43 -18
  30. package/esm/client/3_client.js +107 -46
  31. package/esm/connection/0_connection.d.ts +1 -1
  32. package/esm/connection/1_connection_web_socket.js +1 -1
  33. package/esm/mod.d.ts +7 -21
  34. package/esm/mod.js +7 -21
  35. package/esm/storage/0_storage.d.ts +4 -5
  36. package/esm/storage/0_storage.js +3 -8
  37. package/esm/storage/0_utilities.js +2 -2
  38. package/esm/storage/1_storage_local_storage.d.ts +1 -1
  39. package/esm/storage/1_storage_memory.d.ts +1 -1
  40. package/esm/storage/1_storage_session_storage.d.ts +1 -1
  41. package/esm/tl/0_tl_raw_reader.js +1 -1
  42. package/esm/tl/0_tl_raw_writer.js +1 -1
  43. package/esm/tl/1_tl_object.js +1 -1
  44. package/esm/tl/3_deserialize.js +1 -1
  45. package/esm/tl/3_utilities.d.ts +3 -0
  46. package/esm/tl/3_utilities.js +20 -0
  47. package/esm/tl/4_tl_writer.js +1 -1
  48. package/esm/transport/0_obfuscation.d.ts +2 -2
  49. package/esm/transport/0_obfuscation.js +1 -2
  50. package/esm/transport/0_transport.d.ts +1 -2
  51. package/esm/transport/1_transport_abridged.d.ts +1 -1
  52. package/esm/transport/1_transport_abridged.js +1 -1
  53. package/esm/transport/1_transport_intermediate.d.ts +1 -1
  54. package/esm/transport/1_transport_intermediate.js +1 -1
  55. package/esm/transport/2_transport_provider.d.ts +1 -1
  56. package/esm/transport/2_transport_provider.js +1 -1
  57. package/esm/types/!0_file_id.js +6 -9
  58. package/esm/types/!0_misc.d.ts +7 -0
  59. package/esm/types/!0_misc.js +1 -0
  60. package/esm/types/0_audio.d.ts +3 -3
  61. package/esm/types/0_audio.js +1 -1
  62. package/esm/types/0_chat_administrator_rights.d.ts +1 -1
  63. package/esm/types/0_chat_administrator_rights.js +1 -1
  64. package/esm/types/0_chat_photo.d.ts +3 -3
  65. package/esm/types/0_chat_photo.js +1 -1
  66. package/esm/types/0_color.d.ts +2 -0
  67. package/esm/types/0_color.js +16 -0
  68. package/esm/types/0_contact.d.ts +2 -2
  69. package/esm/types/0_dice.d.ts +1 -1
  70. package/esm/types/0_force_reply.d.ts +1 -1
  71. package/esm/types/0_force_reply.js +1 -1
  72. package/esm/types/0_location.d.ts +1 -1
  73. package/esm/types/0_location.js +1 -2
  74. package/esm/types/0_mask_position.d.ts +1 -1
  75. package/esm/types/0_message_entity.d.ts +5 -5
  76. package/esm/types/0_message_entity.js +1 -1
  77. package/esm/types/0_poll_option.d.ts +1 -1
  78. package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
  79. package/esm/types/0_reply_keyboard_remove.js +2 -2
  80. package/esm/types/0_thumbnail.d.ts +2 -2
  81. package/esm/types/0_thumbnail.js +1 -1
  82. package/esm/types/0_venue.d.ts +1 -1
  83. package/esm/types/0_venue.js +1 -2
  84. package/esm/types/0_voice.d.ts +3 -3
  85. package/esm/types/0_web_app_info.d.ts +2 -2
  86. package/esm/types/1_animation.d.ts +3 -3
  87. package/esm/types/1_animation.js +1 -1
  88. package/esm/types/1_chat.d.ts +5 -4
  89. package/esm/types/1_chat.js +8 -9
  90. package/esm/types/1_document.d.ts +4 -4
  91. package/esm/types/1_document.js +1 -1
  92. package/esm/types/1_inline_keyboard_button.d.ts +4 -4
  93. package/esm/types/1_inline_keyboard_button.js +2 -2
  94. package/esm/types/1_keyboard_button.d.ts +8 -8
  95. package/esm/types/1_keyboard_button.js +2 -2
  96. package/esm/types/1_photo.d.ts +2 -2
  97. package/esm/types/1_photo.js +1 -1
  98. package/esm/types/1_poll.d.ts +8 -8
  99. package/esm/types/1_poll.js +1 -1
  100. package/esm/types/1_sticker.d.ts +3 -3
  101. package/esm/types/1_sticker.js +1 -2
  102. package/esm/types/1_user.d.ts +4 -3
  103. package/esm/types/1_user.js +4 -4
  104. package/esm/types/1_video.d.ts +3 -3
  105. package/esm/types/1_video.js +1 -1
  106. package/esm/types/1_video_note.d.ts +2 -2
  107. package/esm/types/1_video_note.js +1 -1
  108. package/esm/types/2_game.d.ts +3 -3
  109. package/esm/types/2_game.js +2 -3
  110. package/esm/types/2_inline_keyboard_markup.d.ts +2 -2
  111. package/esm/types/2_inline_keyboard_markup.js +1 -1
  112. package/esm/types/2_inline_query.d.ts +19 -0
  113. package/esm/types/2_inline_query.js +41 -0
  114. package/esm/types/2_reply_keyboard_markup.d.ts +2 -2
  115. package/esm/types/2_reply_keyboard_markup.js +1 -1
  116. package/esm/types/3_message.d.ts +23 -23
  117. package/esm/types/3_message.js +19 -18
  118. package/esm/types/4_callback_query.d.ts +14 -0
  119. package/esm/types/4_callback_query.js +24 -0
  120. package/esm/utilities/0_base64.js +1 -1
  121. package/esm/utilities/0_crypto.js +1 -1
  122. package/esm/utilities/0_queue.js +1 -1
  123. package/esm/utilities/1_auth.js +1 -1
  124. package/package.json +1 -1
  125. package/script/1_utilities.d.ts +12 -0
  126. package/script/1_utilities.js +28 -0
  127. package/script/2_connection.d.ts +2 -0
  128. package/script/2_connection.js +18 -0
  129. package/script/2_tl.d.ts +10 -0
  130. package/script/2_tl.js +40 -0
  131. package/script/3_storage.d.ts +6 -0
  132. package/script/3_storage.js +22 -0
  133. package/script/3_transport.d.ts +4 -0
  134. package/script/3_transport.js +20 -0
  135. package/script/3_types.d.ts +35 -0
  136. package/script/3_types.js +51 -0
  137. package/script/{constants.d.ts → 4_constants.d.ts} +2 -2
  138. package/script/{constants.js → 4_constants.js} +1 -1
  139. package/script/5_client.d.ts +2 -0
  140. package/script/5_client.js +18 -0
  141. package/script/client/0_html.d.ts +1 -1
  142. package/script/client/0_html.js +2 -2
  143. package/script/client/0_message.d.ts +1 -2
  144. package/script/client/0_message.js +32 -39
  145. package/script/client/0_password.d.ts +2 -2
  146. package/script/client/0_password.js +20 -22
  147. package/script/client/0_utilities.d.ts +3 -5
  148. package/script/client/0_utilities.js +24 -68
  149. package/script/client/1_client_abstract.d.ts +2 -2
  150. package/script/client/1_client_abstract.js +6 -6
  151. package/script/client/2_client_plain.d.ts +3 -3
  152. package/script/client/2_client_plain.js +45 -52
  153. package/script/client/3_client.d.ts +43 -18
  154. package/script/client/3_client.js +342 -305
  155. package/script/connection/0_connection.d.ts +1 -1
  156. package/script/connection/1_connection_web_socket.js +5 -5
  157. package/script/mod.d.ts +7 -21
  158. package/script/mod.js +17 -45
  159. package/script/storage/0_storage.d.ts +4 -5
  160. package/script/storage/0_storage.js +11 -39
  161. package/script/storage/0_utilities.js +6 -6
  162. package/script/storage/1_storage_local_storage.d.ts +1 -1
  163. package/script/storage/1_storage_memory.d.ts +1 -1
  164. package/script/storage/1_storage_session_storage.d.ts +1 -1
  165. package/script/tl/0_tl_raw_reader.js +6 -6
  166. package/script/tl/0_tl_raw_writer.js +7 -7
  167. package/script/tl/1_tl_object.js +3 -3
  168. package/script/tl/3_deserialize.js +2 -2
  169. package/script/tl/3_utilities.d.ts +3 -0
  170. package/script/tl/3_utilities.js +48 -0
  171. package/script/tl/4_tl_writer.js +2 -2
  172. package/script/transport/0_obfuscation.d.ts +2 -2
  173. package/script/transport/0_obfuscation.js +5 -6
  174. package/script/transport/0_transport.d.ts +1 -2
  175. package/script/transport/1_transport_abridged.d.ts +1 -1
  176. package/script/transport/1_transport_abridged.js +3 -3
  177. package/script/transport/1_transport_intermediate.d.ts +1 -1
  178. package/script/transport/1_transport_intermediate.js +3 -3
  179. package/script/transport/2_transport_provider.d.ts +1 -1
  180. package/script/transport/2_transport_provider.js +2 -2
  181. package/script/types/!0_file_id.js +24 -27
  182. package/script/types/!0_misc.d.ts +7 -0
  183. package/script/types/!0_misc.js +2 -0
  184. package/script/types/0_audio.d.ts +3 -3
  185. package/script/types/0_audio.js +2 -25
  186. package/script/types/0_chat_administrator_rights.d.ts +1 -1
  187. package/script/types/0_chat_administrator_rights.js +2 -25
  188. package/script/types/0_chat_photo.d.ts +3 -3
  189. package/script/types/0_chat_photo.js +2 -25
  190. package/script/types/0_color.d.ts +2 -0
  191. package/script/types/{!0_id_color.js → 0_color.js} +10 -10
  192. package/script/types/0_contact.d.ts +2 -2
  193. package/script/types/0_dice.d.ts +1 -1
  194. package/script/types/0_force_reply.d.ts +1 -1
  195. package/script/types/0_force_reply.js +2 -25
  196. package/script/types/0_location.d.ts +1 -1
  197. package/script/types/0_location.js +5 -29
  198. package/script/types/0_mask_position.d.ts +1 -1
  199. package/script/types/0_message_entity.d.ts +5 -5
  200. package/script/types/0_message_entity.js +39 -62
  201. package/script/types/0_poll_option.d.ts +1 -1
  202. package/script/types/0_reply_keyboard_remove.d.ts +1 -1
  203. package/script/types/0_reply_keyboard_remove.js +4 -27
  204. package/script/types/0_thumbnail.d.ts +2 -2
  205. package/script/types/0_thumbnail.js +2 -25
  206. package/script/types/0_venue.d.ts +1 -1
  207. package/script/types/0_venue.js +2 -26
  208. package/script/types/0_voice.d.ts +3 -3
  209. package/script/types/0_web_app_info.d.ts +2 -2
  210. package/script/types/1_animation.d.ts +3 -3
  211. package/script/types/1_animation.js +2 -25
  212. package/script/types/1_chat.d.ts +5 -4
  213. package/script/types/1_chat.js +20 -44
  214. package/script/types/1_document.d.ts +4 -4
  215. package/script/types/1_document.js +2 -25
  216. package/script/types/1_inline_keyboard_button.d.ts +4 -4
  217. package/script/types/1_inline_keyboard_button.js +19 -42
  218. package/script/types/1_keyboard_button.d.ts +8 -8
  219. package/script/types/1_keyboard_button.js +24 -47
  220. package/script/types/1_photo.d.ts +2 -2
  221. package/script/types/1_photo.js +4 -27
  222. package/script/types/1_poll.d.ts +8 -8
  223. package/script/types/1_poll.js +2 -2
  224. package/script/types/1_sticker.d.ts +3 -3
  225. package/script/types/1_sticker.js +6 -30
  226. package/script/types/1_user.d.ts +4 -3
  227. package/script/types/1_user.js +6 -29
  228. package/script/types/1_video.d.ts +3 -3
  229. package/script/types/1_video.js +2 -25
  230. package/script/types/1_video_note.d.ts +2 -2
  231. package/script/types/1_video_note.js +2 -25
  232. package/script/types/2_game.d.ts +3 -3
  233. package/script/types/2_game.js +6 -30
  234. package/script/types/2_inline_keyboard_markup.d.ts +2 -2
  235. package/script/types/2_inline_keyboard_markup.js +3 -26
  236. package/script/types/2_inline_query.d.ts +19 -0
  237. package/script/types/2_inline_query.js +45 -0
  238. package/script/types/2_reply_keyboard_markup.d.ts +2 -2
  239. package/script/types/2_reply_keyboard_markup.js +3 -26
  240. package/script/types/3_message.d.ts +23 -23
  241. package/script/types/3_message.js +97 -119
  242. package/script/types/4_callback_query.d.ts +14 -0
  243. package/script/types/4_callback_query.js +28 -0
  244. package/script/utilities/0_base64.js +3 -3
  245. package/script/utilities/0_crypto.js +3 -3
  246. package/script/utilities/0_queue.js +2 -2
  247. package/script/utilities/1_auth.js +5 -5
  248. package/esm/types/!0_id_color.d.ts +0 -1
  249. package/esm/types/!0_id_color.js +0 -16
  250. package/script/types/!0_id_color.d.ts +0 -1
  251. /package/esm/{deps.d.ts → 0_deps.d.ts} +0 -0
  252. /package/esm/{deps.js → 0_deps.js} +0 -0
  253. /package/script/{deps.d.ts → 0_deps.d.ts} +0 -0
  254. /package/script/{deps.js → 0_deps.js} +0 -0
@@ -1,10 +1,11 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
+ import { Color } from "./0_color.js";
2
3
  import { ChatPhoto } from "./0_chat_photo.js";
3
4
  /** This object represents a Telegram user or bot. */
4
5
  export interface User {
5
- /** Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */
6
+ /** Unique identifier for this user or bot */
6
7
  id: number;
7
- idColor: string;
8
+ color: Color;
8
9
  /** True, if this user is a bot */
9
10
  isBot: boolean;
10
11
  /** User's or bot's first name */
@@ -1,12 +1,12 @@
1
- import { cleanObject } from "../utilities/0_object.js";
2
- import * as types from "../tl/2_types.js";
3
- import { getIdColor } from "./!0_id_color.js";
1
+ import { cleanObject } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
+ import { getColor } from "./0_color.js";
4
4
  import { constructChatPhoto } from "./0_chat_photo.js";
5
5
  export function constructUser(user_) {
6
6
  const id = Number(user_.id);
7
7
  const user = {
8
8
  id,
9
- idColor: getIdColor(id),
9
+ color: getColor(id),
10
10
  isBot: user_.bot || false,
11
11
  firstName: user_.firstName || "",
12
12
  lastName: user_.lastName,
@@ -1,10 +1,10 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { Thumbnail } from "./0_thumbnail.js";
3
3
  /** This object represents a video file. */
4
4
  export interface Video {
5
5
  /** Identifier for this file, which can be used to download or reuse the file */
6
6
  fileId: string;
7
- /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
7
+ /** Unique identifier for this file, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
8
8
  fileUniqueId: string;
9
9
  /** Video width as defined by sender */
10
10
  width: number;
@@ -18,7 +18,7 @@ export interface Video {
18
18
  fileName?: string;
19
19
  /** MIME type of the file as defined by sender */
20
20
  mimeType: string;
21
- /** File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */
21
+ /** File size in bytes */
22
22
  fileSize: number;
23
23
  }
24
24
  export declare function constructVideo(document: types.Document, videoAttribute: types.DocumentAttributeVideo, fileName: string | undefined, fileId: string, fileUniqueId: string): Video;
@@ -1,4 +1,4 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { constructThumbnail } from "./0_thumbnail.js";
3
3
  export function constructVideo(document, videoAttribute, fileName, fileId, fileUniqueId) {
4
4
  return {
@@ -1,10 +1,10 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { Thumbnail } from "./0_thumbnail.js";
3
3
  /** This object represents a video message (available in Telegram apps as of v.4.0). */
4
4
  export interface VideoNote {
5
5
  /** Identifier for this file, which can be used to download or reuse the file */
6
6
  fileId: string;
7
- /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
7
+ /** Unique identifier for this file, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
8
8
  fileUniqueId: string;
9
9
  /** Video width and height (diameter of the video message) as defined by sender */
10
10
  length: number;
@@ -1,4 +1,4 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { constructThumbnail } from "./0_thumbnail.js";
3
3
  export function constructVideoNote(document, videoAttribute, fileId, fileUniqueId) {
4
4
  return {
@@ -1,4 +1,4 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { MessageEntity } from "./0_message_entity.js";
3
3
  import { Animation } from "./1_animation.js";
4
4
  import { Photo } from "./1_photo.js";
@@ -10,11 +10,11 @@ export interface Game {
10
10
  description: string;
11
11
  /** Photo that will be displayed in the game message in chats. */
12
12
  photo: Photo;
13
- /** Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls [setGameScore](https://corefork.telegram.org/bots/api#setgamescore), or manually edited using [editMessageText](https://corefork.telegram.org/bots/api#editmessagetext). 0-4096 characters. */
13
+ /** Brief description of the game or high scores included in the game message */
14
14
  text?: string;
15
15
  /** Special entities that appear in text, such as usernames, URLs, bot commands, etc. */
16
16
  textEntities?: MessageEntity[];
17
- /** Animation that will be displayed in the game message in chats. Upload via [BotFather](https://t.me/botfather) */
17
+ /** Animation that will be displayed in the game message in chats */
18
18
  animation?: Animation;
19
19
  }
20
20
  export declare function constructGame(media_: types.MessageMediaGame): Game;
@@ -1,6 +1,5 @@
1
- import { as } from "../tl/1_tl_object.js";
2
- import * as types from "../tl/2_types.js";
3
- import { cleanObject } from "../utilities/0_object.js";
1
+ import { cleanObject } from "../1_utilities.js";
2
+ import { as, types } from "../2_tl.js";
4
3
  import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
5
4
  import { constructAnimation } from "./1_animation.js";
6
5
  import { constructPhoto } from "./1_photo.js";
@@ -1,6 +1,6 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { InlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./1_inline_keyboard_button.js";
3
- /** This object represents an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) that appears right next to the message it belongs to. */
3
+ /** This object represents an inline keyboard that appears right next to the message it belongs to. */
4
4
  export interface InlineKeyboardMarkup {
5
5
  /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */
6
6
  inlineKeyboard: InlineKeyboardButton[][];
@@ -1,4 +1,4 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { constructInlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./1_inline_keyboard_button.js";
3
3
  export function constructInlineKeyboardMarkup(keyboard_) {
4
4
  const rows = new Array();
@@ -0,0 +1,19 @@
1
+ import { types } from "../2_tl.js";
2
+ import { EntityGetter } from "./!0_misc.js";
3
+ import { Location } from "./0_location.js";
4
+ import { User } from "./1_user.js";
5
+ export interface InlineQuery {
6
+ /** Unique identifier for this query */
7
+ id: string;
8
+ /** The user who made this query */
9
+ from: User;
10
+ /** The text of the query */
11
+ query: string;
12
+ /** Result offset */
13
+ offset: string;
14
+ /** Type of the chat from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat */
15
+ chatType?: "sender" | "private" | "group" | "supergroup" | "channel";
16
+ /** The location of the user who made this query */
17
+ location?: Location;
18
+ }
19
+ export declare function constructInlineQuery(query_: types.UpdateBotInlineQuery, getEntity: EntityGetter): Promise<InlineQuery>;
@@ -0,0 +1,41 @@
1
+ import { UNREACHABLE } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
+ import { constructLocation } from "./0_location.js";
4
+ import { constructUser } from "./1_user.js";
5
+ export async function constructInlineQuery(query_, getEntity) {
6
+ const user_ = await getEntity(new types.PeerUser({ userId: query_.userId }));
7
+ if (user_ == null) {
8
+ UNREACHABLE();
9
+ }
10
+ const user = constructUser(user_);
11
+ let chatType;
12
+ if (query_.peerType !== undefined) {
13
+ if (query_.peerType instanceof types.InlineQueryPeerTypeSameBotPM) {
14
+ chatType = "private";
15
+ }
16
+ else if (query_.peerType instanceof types.InlineQueryPeerTypeBotPM || query_.peerType instanceof types.InlineQueryPeerTypePM) {
17
+ chatType = "sender";
18
+ }
19
+ else if (query_.peerType instanceof types.InlineQueryPeerTypeChat) {
20
+ chatType = "group";
21
+ }
22
+ else if (query_.peerType instanceof types.InlineQueryPeerTypeMegagroup) {
23
+ chatType = "supergroup";
24
+ }
25
+ else if (query_.peerType instanceof types.InlineQueryPeerTypeBroadcast) {
26
+ chatType = "channel";
27
+ }
28
+ else {
29
+ UNREACHABLE();
30
+ }
31
+ }
32
+ const location = query_.geo !== undefined && query_.geo instanceof types.GeoPoint ? constructLocation(query_.geo) : undefined;
33
+ return {
34
+ id: String(query_.queryId),
35
+ from: user,
36
+ query: query_.query,
37
+ offset: query_.offset,
38
+ chatType,
39
+ location,
40
+ };
41
+ }
@@ -1,6 +1,6 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { KeyboardButton } from "./1_keyboard_button.js";
3
- /** This object represents a [custom keyboard](https://core.telegram.org/bots/features#keyboards) with reply options (see [Introduction to bots](https://core.telegram.org/bots/features#keyboards) for details and examples). */
3
+ /** This object represents a custom keyboard with reply options. */
4
4
  export interface ReplyKeyboardMarkup {
5
5
  /** Array of button rows, each represented by an Array of `KeyboardButton` objects */
6
6
  keyboard: KeyboardButton[][];
@@ -1,4 +1,4 @@
1
- import * as types from "../tl/2_types.js";
1
+ import { types } from "../2_tl.js";
2
2
  import { constructKeyboardButton, keyboardButtonToTlObject } from "./1_keyboard_button.js";
3
3
  export function constructReplyKeyboardMarkup(keyboard_) {
4
4
  const rows = new Array();
@@ -1,26 +1,27 @@
1
- import { MaybePromise } from "../utilities/0_types.js";
2
- import * as types from "../tl/2_types.js";
1
+ import { MaybePromise } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
+ import { EntityGetter } from "./!0_misc.js";
3
4
  import { ForceReply } from "./0_force_reply.js";
4
5
  import { MessageEntity } from "./0_message_entity.js";
6
+ import { Audio } from "./0_audio.js";
7
+ import { Contact } from "./0_contact.js";
8
+ import { Voice } from "./0_voice.js";
9
+ import { Venue } from "./0_venue.js";
10
+ import { Location } from "./0_location.js";
11
+ import { Dice } from "./0_dice.js";
5
12
  import { ReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
6
13
  import { Chat } from "./1_chat.js";
7
- import { User } from "./1_user.js";
8
- import { InlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
9
- import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
10
- import { Sticker, StickerSetNameGetter } from "./1_sticker.js";
11
14
  import { Photo } from "./1_photo.js";
12
15
  import { Document } from "./1_document.js";
13
16
  import { Video } from "./1_video.js";
14
17
  import { VideoNote } from "./1_video_note.js";
15
18
  import { Animation } from "./1_animation.js";
16
- import { Audio } from "./0_audio.js";
17
- import { Voice } from "./0_voice.js";
18
- import { Dice } from "./0_dice.js";
19
- import { Contact } from "./0_contact.js";
20
- import { Game } from "./2_game.js";
19
+ import { User } from "./1_user.js";
21
20
  import { Poll } from "./1_poll.js";
22
- import { Venue } from "./0_venue.js";
23
- import { Location } from "./0_location.js";
21
+ import { Sticker, StickerSetNameGetter } from "./1_sticker.js";
22
+ import { InlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
23
+ import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
24
+ import { Game } from "./2_game.js";
24
25
  /** This object represents a message. */
25
26
  export interface Message {
26
27
  /** Whether the message is outgoing */
@@ -37,6 +38,8 @@ export interface Message {
37
38
  date?: Date;
38
39
  /** Conversation the message belongs to */
39
40
  chat: Chat;
41
+ /** A link to the message */
42
+ link?: string;
40
43
  /** For forwarded messages, sender of the original message */
41
44
  forwardFrom?: User;
42
45
  /** For messages forwarded from channels or from anonymous administrators, information about the original sender chat */
@@ -101,6 +104,7 @@ export interface Message {
101
104
  contact?: Contact;
102
105
  /** Message is a game, information about the game. */
103
106
  game?: Game;
107
+ /** New poll state. Bots receive only updates about stopped polls and polls, which were sent by the bot. */
104
108
  poll?: Poll;
105
109
  /** Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set */
106
110
  venue?: Venue;
@@ -122,9 +126,9 @@ export interface Message {
122
126
  supergroupCreated?: true;
123
127
  /** Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. */
124
128
  channelCreated?: true;
125
- /** The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */
129
+ /** The group has been migrated to a supergroup with the specified identifier */
126
130
  chatMigratedTo?: number;
127
- /** The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */
131
+ /** The supergroup has been migrated from a group with the specified identifier */
128
132
  chatMigratedFrom?: number;
129
133
  /** Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. */
130
134
  pinnedMessage?: Message;
@@ -163,13 +167,9 @@ export interface Message {
163
167
  duration: number;
164
168
  };
165
169
  }
166
- interface EntityGetter {
167
- (peer: types.PeerUser): MaybePromise<types.User | null>;
168
- (peer: types.PeerChat): MaybePromise<types.Chat | null>;
169
- (peer: types.PeerChannel): MaybePromise<types.Channel | null>;
170
+ export interface MessageGetter<O extends keyof Message | null = null> {
171
+ (chatId: number, messageId: number): MaybePromise<(O extends null ? Message : Omit<Message, "replyToMessage">) | null>;
170
172
  }
171
- type MessageGetter = {
172
- (chatId: number, messageId: number): MaybePromise<Omit<Message, "replyToMessage"> | null>;
173
- } | null;
174
- export declare function constructMessage(message_: types.TypeMessage, getEntity: EntityGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Message>;
173
+ type Message_MessageGetter = MessageGetter<"replyToMessage"> | null;
174
+ export declare function constructMessage(message_: types.TypeMessage, getEntity: EntityGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Message>;
175
175
  export {};
@@ -1,31 +1,29 @@
1
- import { debug } from "../deps.js";
2
- import { UNREACHABLE } from "../utilities/0_control.js";
3
- import { cleanObject } from "../utilities/0_object.js";
4
- import { as } from "../tl/1_tl_object.js";
5
- import * as types from "../tl/2_types.js";
1
+ import { debug } from "../0_deps.js";
2
+ import { cleanObject, UNREACHABLE } from "../1_utilities.js";
3
+ import { as, types } from "../2_tl.js";
4
+ import { ZERO_CHANNEL_ID } from "../4_constants.js";
5
+ import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
6
6
  import { constructForceReply } from "./0_force_reply.js";
7
7
  import { constructMessageEntity } from "./0_message_entity.js";
8
+ import { constructAudio } from "./0_audio.js";
9
+ import { constructContact } from "./0_contact.js";
10
+ import { constructVoice } from "./0_voice.js";
11
+ import { constructVenue } from "./0_venue.js";
12
+ import { constructLocation } from "./0_location.js";
13
+ import { constructDice } from "./0_dice.js";
8
14
  import { constructReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
9
15
  import { ChatType, constructChat } from "./1_chat.js";
10
- import { constructUser } from "./1_user.js";
11
- import { constructInlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
12
- import { constructReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
13
- import { constructSticker } from "./1_sticker.js";
14
16
  import { constructPhoto } from "./1_photo.js";
15
17
  import { constructDocument } from "./1_document.js";
16
18
  import { constructVideo } from "./1_video.js";
17
19
  import { constructVideoNote } from "./1_video_note.js";
18
20
  import { constructAnimation } from "./1_animation.js";
19
- import { constructAudio } from "./0_audio.js";
20
- import { constructVoice } from "./0_voice.js";
21
- import { constructDice } from "./0_dice.js";
22
- import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
23
- import { constructContact } from "./0_contact.js";
24
- import { constructGame } from "./2_game.js";
21
+ import { constructUser } from "./1_user.js";
25
22
  import { constructPoll } from "./1_poll.js";
26
- import { constructVenue } from "./0_venue.js";
27
- import { constructLocation } from "./0_location.js";
28
- import { ZERO_CHANNEL_ID } from "../constants.js";
23
+ import { constructSticker } from "./1_sticker.js";
24
+ import { constructInlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
25
+ import { constructReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
26
+ import { constructGame } from "./2_game.js";
29
27
  const d = debug("types/Message");
30
28
  async function getSender(message_, getEntity) {
31
29
  if (message_.fromId instanceof types.PeerUser) {
@@ -185,6 +183,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
185
183
  if (!(message_ instanceof types.Message) && !(message_ instanceof types.MessageService)) {
186
184
  UNREACHABLE();
187
185
  }
186
+ let link;
188
187
  let chat_ = null;
189
188
  if (message_.peerId instanceof types.PeerUser) {
190
189
  const entity = await getEntity(message_.peerId);
@@ -205,6 +204,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
205
204
  }
206
205
  }
207
206
  else if (message_.peerId instanceof types.PeerChannel) {
207
+ link = `https://t.me/c/${message_.peerId.channelId}/${message_.id}`;
208
208
  const entity = await getEntity(message_.peerId);
209
209
  if (entity) {
210
210
  chat_ = constructChat(entity);
@@ -223,6 +223,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
223
223
  out: message_.out ?? false,
224
224
  id: message_.id,
225
225
  chat: chat_,
226
+ link,
226
227
  date: new Date(message_.date * 1000),
227
228
  views: message_.views,
228
229
  isTopicMessage: false,
@@ -0,0 +1,14 @@
1
+ import { types } from "../2_tl.js";
2
+ import { EntityGetter } from "./!0_misc.js";
3
+ import { User } from "./1_user.js";
4
+ import { Message, MessageGetter } from "./3_message.js";
5
+ export interface CallbackQuery {
6
+ id: string;
7
+ from: User;
8
+ message?: Message;
9
+ inlineMessageId?: number;
10
+ chatInstance?: string;
11
+ data?: string;
12
+ gameShortName?: string;
13
+ }
14
+ export declare function constructCallbackQuery(callbackQuery: types.UpdateBotCallbackQuery | types.UpdateInlineBotCallbackQuery, getEntity: EntityGetter, getMessage: MessageGetter): Promise<CallbackQuery>;
@@ -0,0 +1,24 @@
1
+ import { cleanObject, UNREACHABLE } from "../1_utilities.js";
2
+ import { peerToChatId, types } from "../2_tl.js";
3
+ import { constructUser } from "./1_user.js";
4
+ export async function constructCallbackQuery(callbackQuery, getEntity, getMessage) {
5
+ const user_ = await getEntity(new types.PeerUser({ userId: callbackQuery.userId }));
6
+ if (!user_) {
7
+ UNREACHABLE();
8
+ }
9
+ const user = constructUser(user_);
10
+ const id = String(callbackQuery.queryId);
11
+ const gameShortName = callbackQuery.gameShortName;
12
+ const data = callbackQuery.data !== undefined ? new TextDecoder().decode(callbackQuery.data) : undefined;
13
+ const chatInstance = callbackQuery.chatInstance == 0n ? "" : String(callbackQuery.chatInstance);
14
+ if (callbackQuery instanceof types.UpdateBotCallbackQuery) {
15
+ const message = await getMessage(peerToChatId(callbackQuery.peer), Number(callbackQuery.msgId));
16
+ if (message == null) {
17
+ UNREACHABLE();
18
+ }
19
+ return cleanObject({ id, from: user, message, chatInstance, data, gameShortName });
20
+ }
21
+ else {
22
+ return cleanObject({ id, from: user, inlineMessageId: Number(callbackQuery.msgId.id), chatInstance, data, gameShortName });
23
+ }
24
+ }
@@ -1,4 +1,4 @@
1
- import { base64Decode, base64Encode } from "../deps.js";
1
+ import { base64Decode, base64Encode } from "../0_deps.js";
2
2
  export function base64EncodeUrlSafe(data) {
3
3
  return base64Encode(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
4
4
  }
@@ -1,4 +1,4 @@
1
- import { ctr256Decrypt, ctr256Encrypt } from "../deps.js";
1
+ import { ctr256Decrypt, ctr256Encrypt } from "../0_deps.js";
2
2
  export class CTR {
3
3
  constructor(key, iv) {
4
4
  Object.defineProperty(this, "key", {
@@ -1,4 +1,4 @@
1
- import { debug } from "../deps.js";
1
+ import { debug } from "../0_deps.js";
2
2
  export class Queue {
3
3
  constructor(name) {
4
4
  Object.defineProperty(this, "d", {
@@ -1,5 +1,5 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
- import { assert, assertEquals, ige256Encrypt } from "../deps.js";
2
+ import { assert, assertEquals, ige256Encrypt } from "../0_deps.js";
3
3
  import { bigIntFromBuffer, modExp } from "./0_bigint.js";
4
4
  import { bufferFromBigInt, concat } from "./0_buffer.js";
5
5
  import { sha256 } from "./0_hash.js";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.990",
5
+ "version": "0.0.992",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -0,0 +1,12 @@
1
+ export * from "./utilities/0_base64.js";
2
+ export * from "./utilities/0_bigint.js";
3
+ export * from "./utilities/0_buffer.js";
4
+ export * from "./utilities/0_control.js";
5
+ export * from "./utilities/0_crypto.js";
6
+ export * from "./utilities/0_hash.js";
7
+ export * from "./utilities/0_object.js";
8
+ export * from "./utilities/0_queue.js";
9
+ export * from "./utilities/0_rle.js";
10
+ export * from "./utilities/0_types.js";
11
+ export * from "./utilities/1_auth.js";
12
+ export * from "./utilities/1_misc.js";
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utilities/0_base64.js"), exports);
18
+ __exportStar(require("./utilities/0_bigint.js"), exports);
19
+ __exportStar(require("./utilities/0_buffer.js"), exports);
20
+ __exportStar(require("./utilities/0_control.js"), exports);
21
+ __exportStar(require("./utilities/0_crypto.js"), exports);
22
+ __exportStar(require("./utilities/0_hash.js"), exports);
23
+ __exportStar(require("./utilities/0_object.js"), exports);
24
+ __exportStar(require("./utilities/0_queue.js"), exports);
25
+ __exportStar(require("./utilities/0_rle.js"), exports);
26
+ __exportStar(require("./utilities/0_types.js"), exports);
27
+ __exportStar(require("./utilities/1_auth.js"), exports);
28
+ __exportStar(require("./utilities/1_misc.js"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./connection/0_connection.js";
2
+ export * from "./connection/1_connection_web_socket.js";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./connection/0_connection.js"), exports);
18
+ __exportStar(require("./connection/1_connection_web_socket.js"), exports);
@@ -0,0 +1,10 @@
1
+ export { TLError } from "./tl/0_tl_raw_reader.js";
2
+ export * from "./tl/1_tl_object.js";
3
+ export * as types from "./tl/2_types.js";
4
+ export * as functions from "./tl/3_functions.js";
5
+ export * from "./tl/3_tl_reader.js";
6
+ export * from "./tl/3_utilities.js";
7
+ export * from "./tl/4_tl_writer.js";
8
+ export * from "./tl/5_rpc_result.js";
9
+ export * from "./tl/6_message.js";
10
+ export * from "./tl/7_message_container.js";
package/script/2_tl.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.functions = exports.types = exports.TLError = void 0;
30
+ var _0_tl_raw_reader_js_1 = require("./tl/0_tl_raw_reader.js");
31
+ Object.defineProperty(exports, "TLError", { enumerable: true, get: function () { return _0_tl_raw_reader_js_1.TLError; } });
32
+ __exportStar(require("./tl/1_tl_object.js"), exports);
33
+ exports.types = __importStar(require("./tl/2_types.js"));
34
+ exports.functions = __importStar(require("./tl/3_functions.js"));
35
+ __exportStar(require("./tl/3_tl_reader.js"), exports);
36
+ __exportStar(require("./tl/3_utilities.js"), exports);
37
+ __exportStar(require("./tl/4_tl_writer.js"), exports);
38
+ __exportStar(require("./tl/5_rpc_result.js"), exports);
39
+ __exportStar(require("./tl/6_message.js"), exports);
40
+ __exportStar(require("./tl/7_message_container.js"), exports);
@@ -0,0 +1,6 @@
1
+ export * from "./storage/0_storage.js";
2
+ export * from "./storage/0_utilities.js";
3
+ export * from "./storage/1_storage_indexed_db.js";
4
+ export * from "./storage/1_storage_local_storage.js";
5
+ export * from "./storage/1_storage_memory.js";
6
+ export * from "./storage/1_storage_session_storage.js";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./storage/0_storage.js"), exports);
18
+ __exportStar(require("./storage/0_utilities.js"), exports);
19
+ __exportStar(require("./storage/1_storage_indexed_db.js"), exports);
20
+ __exportStar(require("./storage/1_storage_local_storage.js"), exports);
21
+ __exportStar(require("./storage/1_storage_memory.js"), exports);
22
+ __exportStar(require("./storage/1_storage_session_storage.js"), exports);
@@ -0,0 +1,4 @@
1
+ export * from "./transport/0_transport.js";
2
+ export * from "./transport/1_transport_abridged.js";
3
+ export * from "./transport/1_transport_intermediate.js";
4
+ export * from "./transport/2_transport_provider.js";