@mtkruto/node 0.0.832 → 0.0.835

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 (127) hide show
  1. package/esm/client/client.d.ts +7 -2
  2. package/esm/client/client.js +66 -13
  3. package/esm/client/client_abstract.d.ts +2 -2
  4. package/esm/client/client_abstract.js +3 -8
  5. package/esm/client/client_plain.js +8 -7
  6. package/esm/connection/connection.d.ts +2 -1
  7. package/esm/connection/connection_web_socket.d.ts +1 -0
  8. package/esm/connection/connection_web_socket.js +3 -0
  9. package/esm/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
  10. package/esm/deps/deno.land/std@0.69.0/fmt/colors.js +224 -0
  11. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
  12. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +71 -0
  13. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
  14. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +112 -0
  15. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
  16. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +2 -0
  17. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
  18. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +39 -0
  19. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
  20. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +1 -0
  21. package/esm/deps.d.ts +2 -0
  22. package/esm/deps.js +2 -0
  23. package/esm/storage/storage.d.ts +1 -1
  24. package/esm/storage/storage_local_storage.d.ts +1 -1
  25. package/esm/storage/storage_memory.d.ts +1 -1
  26. package/esm/storage/storage_session_storage.d.ts +1 -1
  27. package/esm/transport/transport.d.ts +1 -1
  28. package/esm/types/0_chat_administrator_rights.d.ts +17 -0
  29. package/esm/types/0_chat_administrator_rights.js +38 -0
  30. package/esm/types/0_chat_photo.d.ts +24 -0
  31. package/esm/types/0_chat_photo.js +28 -0
  32. package/esm/types/0_force_reply.d.ts +8 -0
  33. package/esm/types/0_force_reply.js +17 -0
  34. package/esm/types/0_keyboard_button_poll_type.d.ts +3 -0
  35. package/esm/types/0_login_url.d.ts +6 -0
  36. package/esm/types/0_login_url.js +1 -0
  37. package/esm/types/0_message_entity.d.ts +1 -1
  38. package/esm/types/0_message_entity.js +2 -2
  39. package/esm/types/0_reply_keyboard_remove.d.ts +7 -0
  40. package/esm/types/0_reply_keyboard_remove.js +8 -0
  41. package/esm/types/0_web_app_info.d.ts +4 -0
  42. package/esm/types/0_web_app_info.js +3 -0
  43. package/esm/types/1_chat.d.ts +60 -0
  44. package/esm/types/1_chat.js +70 -0
  45. package/esm/types/1_inline_keyboard_button.d.ts +33 -0
  46. package/esm/types/1_inline_keyboard_button.js +63 -0
  47. package/esm/types/1_keyboard_button.d.ts +43 -0
  48. package/esm/types/1_keyboard_button.js +133 -0
  49. package/esm/types/1_user.d.ts +19 -0
  50. package/esm/types/1_user.js +25 -0
  51. package/esm/types/2_inline_keyboard_markup.d.ts +7 -0
  52. package/esm/types/2_inline_keyboard_markup.js +25 -0
  53. package/esm/types/2_reply_keyboard_markup.d.ts +12 -0
  54. package/esm/types/2_reply_keyboard_markup.js +37 -0
  55. package/esm/types/3_message.d.ts +22 -0
  56. package/esm/types/3_message.js +87 -0
  57. package/esm/utilities/0_control.d.ts +1 -0
  58. package/esm/utilities/0_control.js +3 -0
  59. package/esm/utilities/0_object.d.ts +1 -0
  60. package/esm/utilities/0_object.js +14 -0
  61. package/esm/utilities/0_types.js +1 -0
  62. package/package.json +8 -6
  63. package/script/client/client.d.ts +7 -2
  64. package/script/client/client.js +65 -12
  65. package/script/client/client_abstract.d.ts +2 -2
  66. package/script/client/client_abstract.js +3 -8
  67. package/script/client/client_plain.js +7 -6
  68. package/script/connection/connection.d.ts +2 -1
  69. package/script/connection/connection_web_socket.d.ts +1 -0
  70. package/script/connection/connection_web_socket.js +3 -0
  71. package/script/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
  72. package/script/deps/deno.land/std@0.69.0/fmt/colors.js +298 -0
  73. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
  74. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +98 -0
  75. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
  76. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +141 -0
  77. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
  78. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +32 -0
  79. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
  80. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +43 -0
  81. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
  82. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +17 -0
  83. package/script/deps.d.ts +2 -0
  84. package/script/deps.js +4 -1
  85. package/script/storage/storage.d.ts +1 -1
  86. package/script/storage/storage_local_storage.d.ts +1 -1
  87. package/script/storage/storage_memory.d.ts +1 -1
  88. package/script/storage/storage_session_storage.d.ts +1 -1
  89. package/script/transport/transport.d.ts +1 -1
  90. package/script/types/0_chat_administrator_rights.d.ts +17 -0
  91. package/script/types/0_chat_administrator_rights.js +66 -0
  92. package/script/types/0_chat_photo.d.ts +24 -0
  93. package/script/types/0_chat_photo.js +55 -0
  94. package/script/types/0_force_reply.d.ts +8 -0
  95. package/script/types/0_force_reply.js +45 -0
  96. package/script/types/0_keyboard_button_poll_type.d.ts +3 -0
  97. package/script/types/0_login_url.d.ts +6 -0
  98. package/script/types/0_login_url.js +2 -0
  99. package/script/types/0_message_entity.d.ts +1 -1
  100. package/script/types/0_message_entity.js +2 -2
  101. package/script/types/0_reply_keyboard_remove.d.ts +7 -0
  102. package/script/types/0_reply_keyboard_remove.js +36 -0
  103. package/script/types/0_web_app_info.d.ts +4 -0
  104. package/script/types/0_web_app_info.js +7 -0
  105. package/script/types/1_chat.d.ts +60 -0
  106. package/script/types/1_chat.js +97 -0
  107. package/script/types/1_inline_keyboard_button.d.ts +33 -0
  108. package/script/types/1_inline_keyboard_button.js +91 -0
  109. package/script/types/1_keyboard_button.d.ts +43 -0
  110. package/script/types/1_keyboard_button.js +161 -0
  111. package/script/types/1_user.d.ts +19 -0
  112. package/script/types/1_user.js +52 -0
  113. package/script/types/2_inline_keyboard_markup.d.ts +7 -0
  114. package/script/types/2_inline_keyboard_markup.js +53 -0
  115. package/script/types/2_reply_keyboard_markup.d.ts +12 -0
  116. package/script/types/2_reply_keyboard_markup.js +65 -0
  117. package/script/types/3_message.d.ts +22 -0
  118. package/script/types/3_message.js +114 -0
  119. package/script/utilities/0_control.d.ts +1 -0
  120. package/script/utilities/0_control.js +7 -0
  121. package/script/utilities/0_object.d.ts +1 -0
  122. package/script/utilities/0_object.js +18 -0
  123. package/script/utilities/0_types.js +2 -0
  124. /package/esm/{types.js → types/0_keyboard_button_poll_type.js} +0 -0
  125. /package/esm/{types.d.ts → utilities/0_types.d.ts} +0 -0
  126. /package/script/{types.js → types/0_keyboard_button_poll_type.js} +0 -0
  127. /package/script/{types.d.ts → utilities/0_types.d.ts} +0 -0
@@ -0,0 +1,91 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.inlineKeyboardButtonToTlObject = exports.constructInlineKeyboardButton = void 0;
27
+ const _0_control_js_1 = require("../utilities/0_control.js");
28
+ const types = __importStar(require("../tl/2_types.js"));
29
+ const _0_web_app_info_js_1 = require("./0_web_app_info.js");
30
+ function constructInlineKeyboardButton(button_) {
31
+ if (button_ instanceof types.KeyboardButtonURL) {
32
+ return { text: button_.text, url: button_.url };
33
+ }
34
+ else if (button_ instanceof types.KeyboardButtonCallback) {
35
+ return { text: button_.text, callbackData: new TextDecoder().decode(button_.data) };
36
+ }
37
+ else if (button_ instanceof types.KeyboardButtonWebView || button_ instanceof types.KeyboardButtonSimpleWebView) {
38
+ return { text: button_.text, webApp: (0, _0_web_app_info_js_1.constructWebAppInfo)(button_.url) };
39
+ }
40
+ else if (button_ instanceof types.KeyboardButtonURLAuth) {
41
+ return { text: button_.text, loginUrl: { url: button_.url, forwardText: button_.fwdText } };
42
+ }
43
+ else if (button_ instanceof types.KeyboardButtonSwitchInline) {
44
+ if (button_.samePeer) {
45
+ return { text: button_.text, switchInlineQueryCurrentChat: button_.query };
46
+ }
47
+ else {
48
+ return { text: button_.text, switchInlineQuery: button_.query };
49
+ }
50
+ }
51
+ else if (button_ instanceof types.KeyboardButtonBuy) {
52
+ return { text: button_.text, pay: true };
53
+ }
54
+ else {
55
+ (0, _0_control_js_1.UNREACHABLE)();
56
+ }
57
+ }
58
+ exports.constructInlineKeyboardButton = constructInlineKeyboardButton;
59
+ async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
60
+ if ("url" in button) {
61
+ return new types.KeyboardButtonURL({ text: button.text, url: button.url });
62
+ }
63
+ else if ("callbackData" in button) {
64
+ return new types.KeyboardButtonCallback({ text: button.text, data: new TextEncoder().encode(button.callbackData) });
65
+ }
66
+ else if ("webApp" in button) {
67
+ return new types.KeyboardButtonWebView({ text: button.text, url: button.webApp.url });
68
+ }
69
+ else if ("loginUrl" in button) {
70
+ return new types.InputKeyboardButtonURLAuth({
71
+ text: button.text,
72
+ url: button.loginUrl.url,
73
+ fwdText: button.loginUrl.forwardText,
74
+ bot: button.loginUrl.botUsername ? await usernameResolver(button.loginUrl.botUsername) : new types.InputUserSelf(),
75
+ requestWriteAccess: button.loginUrl.requestWriteAccess || undefined,
76
+ });
77
+ }
78
+ else if ("switchInlineQuery" in button) {
79
+ return new types.KeyboardButtonSwitchInline({ text: button.text, query: button.switchInlineQuery });
80
+ }
81
+ else if ("switchInlineQueryCurrentChat" in button) {
82
+ return new types.KeyboardButtonSwitchInline({ text: button.text, query: button.switchInlineQueryCurrentChat, samePeer: true });
83
+ }
84
+ else if ("pay" in button) {
85
+ return new types.KeyboardButtonBuy({ text: button.text });
86
+ }
87
+ else {
88
+ (0, _0_control_js_1.UNREACHABLE)();
89
+ }
90
+ }
91
+ exports.inlineKeyboardButtonToTlObject = inlineKeyboardButtonToTlObject;
@@ -0,0 +1,43 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { ChatAdministratorRights } from "./0_chat_administrator_rights.js";
3
+ import { KeyboardButtonPollType } from "./0_keyboard_button_poll_type.js";
4
+ import { WebAppInfo } from "./0_web_app_info.js";
5
+ export declare namespace KeyboardButton {
6
+ interface Text {
7
+ text: string;
8
+ }
9
+ interface RequestUser extends Text {
10
+ requestUser: {
11
+ requestId: number;
12
+ userIsBot?: boolean;
13
+ userIsPremium?: boolean;
14
+ };
15
+ }
16
+ interface RequestChat extends Text {
17
+ requestChat: {
18
+ requestId: number;
19
+ chatIsChannel: boolean;
20
+ chatIsForum?: boolean;
21
+ chatHasUsername?: boolean;
22
+ chatIsCreated?: boolean;
23
+ userAdministratorRights?: ChatAdministratorRights;
24
+ botAdministratorRights?: ChatAdministratorRights;
25
+ botIsMember?: boolean;
26
+ };
27
+ }
28
+ interface RequestContact extends Text {
29
+ requestContact: true;
30
+ }
31
+ interface RequestLocation extends Text {
32
+ requestLocation: true;
33
+ }
34
+ interface RequestPoll extends Text {
35
+ requestPoll: KeyboardButtonPollType;
36
+ }
37
+ interface WebApp extends Text {
38
+ webApp: WebAppInfo;
39
+ }
40
+ }
41
+ export type KeyboardButton = KeyboardButton.Text | KeyboardButton.RequestUser | KeyboardButton.RequestChat | KeyboardButton.RequestContact | KeyboardButton.RequestLocation | KeyboardButton.RequestPoll | KeyboardButton.WebApp;
42
+ export declare function constructKeyboardButton(button_: types.TypeKeyboardButton): KeyboardButton;
43
+ export declare function keyboardButtonToTlObject(button: KeyboardButton): types.KeyboardButtonRequestPhone | types.KeyboardButtonRequestGeoLocation | types.KeyboardButtonRequestPoll | types.KeyboardButtonWebView | types.KeyboardButtonRequestPeer;
@@ -0,0 +1,161 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.keyboardButtonToTlObject = exports.constructKeyboardButton = void 0;
27
+ const _0_control_js_1 = require("../utilities/0_control.js");
28
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
29
+ const types = __importStar(require("../tl/2_types.js"));
30
+ const _0_chat_administrator_rights_js_1 = require("./0_chat_administrator_rights.js");
31
+ function constructKeyboardButton(button_) {
32
+ if (button_ instanceof types.KeyboardButton) {
33
+ return { text: button_.text };
34
+ }
35
+ else if (button_ instanceof types.KeyboardButtonRequestPeer) {
36
+ if (button_.peerType instanceof types.RequestPeerTypeUser) {
37
+ return {
38
+ text: button_.text,
39
+ requestUser: {
40
+ requestId: button_.buttonId,
41
+ userIsBot: button_.peerType.bot || false,
42
+ userIsPremium: button_.peerType.premium || false,
43
+ },
44
+ };
45
+ }
46
+ else if (button_.peerType instanceof types.RequestPeerTypeChat) {
47
+ const button = {
48
+ text: button_.text,
49
+ requestChat: {
50
+ requestId: button_.buttonId,
51
+ chatIsChannel: false,
52
+ chatIsForum: button_.peerType.forum || false,
53
+ chatHasUsername: button_.peerType.hasUsername || false,
54
+ chatIsCreated: button_.peerType.creator || false,
55
+ botIsMember: button_.peerType.botParticipant || false,
56
+ },
57
+ };
58
+ if (button_.peerType.botAdminRights) {
59
+ button.requestChat.botAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peerType.botAdminRights[_1_tl_object_js_1.as](types.ChatAdminRights));
60
+ }
61
+ if (button_.peerType.userAdminRights) {
62
+ button.requestChat.userAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peerType.userAdminRights[_1_tl_object_js_1.as](types.ChatAdminRights));
63
+ }
64
+ return button;
65
+ }
66
+ else if (button_.peerType instanceof types.RequestPeerTypeBroadcast) {
67
+ const button = {
68
+ text: button_.text,
69
+ requestChat: {
70
+ requestId: button_.buttonId,
71
+ chatIsChannel: true,
72
+ chatIsCreated: button_.peerType.creator || false,
73
+ chatHasUsername: button_.peerType.hasUsername || false,
74
+ },
75
+ };
76
+ if (button_.peerType.botAdminRights) {
77
+ button.requestChat.botAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peerType.botAdminRights[_1_tl_object_js_1.as](types.ChatAdminRights));
78
+ }
79
+ if (button_.peerType.userAdminRights) {
80
+ button.requestChat.userAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peerType.userAdminRights[_1_tl_object_js_1.as](types.ChatAdminRights));
81
+ }
82
+ return button;
83
+ }
84
+ else {
85
+ (0, _0_control_js_1.UNREACHABLE)();
86
+ }
87
+ }
88
+ else if (button_ instanceof types.KeyboardButtonRequestPhone) {
89
+ return { text: button_.text, requestContact: true };
90
+ }
91
+ else if (button_ instanceof types.KeyboardButtonRequestGeoLocation) {
92
+ return { text: button_.text, requestLocation: true };
93
+ }
94
+ else if (button_ instanceof types.KeyboardButtonRequestPoll) {
95
+ const button = { text: button_.text, requestPoll: {} };
96
+ if (button_.quiz) {
97
+ button.requestPoll.type = "quiz";
98
+ }
99
+ return button;
100
+ }
101
+ else if (button_ instanceof types.KeyboardButtonWebView || button_ instanceof types.KeyboardButtonSimpleWebView) {
102
+ return { text: button_.text, webApp: { url: button_.url } };
103
+ }
104
+ else {
105
+ (0, _0_control_js_1.UNREACHABLE)();
106
+ }
107
+ }
108
+ exports.constructKeyboardButton = constructKeyboardButton;
109
+ function keyboardButtonToTlObject(button) {
110
+ if ("requestUser" in button) {
111
+ return new types.KeyboardButtonRequestPeer({
112
+ text: button.text,
113
+ buttonId: button.requestUser.requestId,
114
+ peerType: new types.RequestPeerTypeUser({ bot: button.requestUser.userIsBot, premium: button.requestUser.userIsPremium }),
115
+ });
116
+ }
117
+ else if ("requestChat" in button) {
118
+ if (!button.requestChat.chatIsChannel) { // GUESS
119
+ return new types.KeyboardButtonRequestPeer({
120
+ text: button.text,
121
+ buttonId: button.requestChat.requestId,
122
+ peerType: new types.RequestPeerTypeChat({
123
+ forum: button.requestChat.chatIsForum,
124
+ hasUsername: button.requestChat.chatHasUsername,
125
+ creator: button.requestChat.chatIsCreated || undefined,
126
+ botParticipant: button.requestChat.botIsMember || undefined,
127
+ botAdminRights: button.requestChat.botAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.botAdministratorRights) : undefined,
128
+ userAdminRights: button.requestChat.userAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.userAdministratorRights) : undefined,
129
+ }),
130
+ });
131
+ }
132
+ else {
133
+ return new types.KeyboardButtonRequestPeer({
134
+ text: button.text,
135
+ buttonId: button.requestChat.requestId,
136
+ peerType: new types.RequestPeerTypeBroadcast({
137
+ hasUsername: button.requestChat.chatHasUsername,
138
+ creator: button.requestChat.chatIsCreated || undefined,
139
+ botAdminRights: button.requestChat.botAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.botAdministratorRights) : undefined,
140
+ userAdminRights: button.requestChat.userAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.userAdministratorRights) : undefined,
141
+ }),
142
+ });
143
+ }
144
+ }
145
+ else if ("requestContact" in button) {
146
+ return new types.KeyboardButtonRequestPhone({ text: button.text });
147
+ }
148
+ else if ("requestLocation" in button) {
149
+ return new types.KeyboardButtonRequestGeoLocation({ text: button.text });
150
+ }
151
+ else if ("requestPoll" in button) {
152
+ return new types.KeyboardButtonRequestPoll({ text: button.text, quiz: button.requestPoll.type == "quiz" });
153
+ }
154
+ else if ("webApp" in button) {
155
+ return new types.KeyboardButtonWebView({ text: button.text, url: button.webApp.url });
156
+ }
157
+ else {
158
+ (0, _0_control_js_1.UNREACHABLE)();
159
+ }
160
+ }
161
+ exports.keyboardButtonToTlObject = keyboardButtonToTlObject;
@@ -0,0 +1,19 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { ChatPhoto } from "./0_chat_photo.js";
3
+ export interface User {
4
+ id: number;
5
+ isBot: boolean;
6
+ firstName: string;
7
+ lastName?: string;
8
+ username?: string;
9
+ also?: string[];
10
+ photo?: ChatPhoto.User;
11
+ languageCode?: string;
12
+ isScam: boolean;
13
+ isFake: boolean;
14
+ isPremium: boolean;
15
+ isVerified: boolean;
16
+ isSupport: boolean;
17
+ addedToAttachmentMenu: boolean;
18
+ }
19
+ export declare function constructUser(user_: types.User): User;
@@ -0,0 +1,52 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructUser = void 0;
27
+ const _0_object_js_1 = require("../utilities/0_object.js");
28
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
29
+ const types = __importStar(require("../tl/2_types.js"));
30
+ const _0_chat_photo_js_1 = require("./0_chat_photo.js");
31
+ function constructUser(user_) {
32
+ const user = {
33
+ id: Number(user_.id),
34
+ isBot: user_.bot || false,
35
+ firstName: user_.firstName || "",
36
+ lastName: user_.lastName,
37
+ username: user_.username,
38
+ also: user_.usernames?.map((v) => v[_1_tl_object_js_1.as](types.Username)).map((v) => v.username),
39
+ languageCode: user_.langCode,
40
+ isScam: user_.scam || false,
41
+ isFake: user_.fake || false,
42
+ isPremium: user_.premium || false,
43
+ isVerified: user_.verified || false,
44
+ isSupport: user_.support || false,
45
+ addedToAttachmentMenu: user_.attachMenuEnabled || false,
46
+ };
47
+ if (user_.photo instanceof types.UserProfilePhoto) {
48
+ user.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(user_.photo);
49
+ }
50
+ return (0, _0_object_js_1.cleanObject)(user);
51
+ }
52
+ exports.constructUser = constructUser;
@@ -0,0 +1,7 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { InlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./1_inline_keyboard_button.js";
3
+ export interface InlineKeyboardMarkup {
4
+ inlineKeyboard: InlineKeyboardButton[][];
5
+ }
6
+ export declare function constructInlineKeyboardMarkup(keyboard_: types.ReplyInlineMarkup): InlineKeyboardMarkup;
7
+ export declare function inlineKeyboardMarkupToTlObject(keyboard: InlineKeyboardMarkup, usernameResolver: Parameters<typeof inlineKeyboardButtonToTlObject>[1]): Promise<types.ReplyInlineMarkup>;
@@ -0,0 +1,53 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.inlineKeyboardMarkupToTlObject = exports.constructInlineKeyboardMarkup = void 0;
27
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
28
+ const types = __importStar(require("../tl/2_types.js"));
29
+ const _1_inline_keyboard_button_js_1 = require("./1_inline_keyboard_button.js");
30
+ function constructInlineKeyboardMarkup(keyboard_) {
31
+ const rows = new Array();
32
+ for (const row_ of keyboard_.rows.map((v) => v[_1_tl_object_js_1.as](types.KeyboardButtonRow))) {
33
+ const row = new Array();
34
+ for (const button_ of row_.buttons) {
35
+ row.push((0, _1_inline_keyboard_button_js_1.constructInlineKeyboardButton)(button_));
36
+ }
37
+ rows.push(row);
38
+ }
39
+ return { inlineKeyboard: rows };
40
+ }
41
+ exports.constructInlineKeyboardMarkup = constructInlineKeyboardMarkup;
42
+ async function inlineKeyboardMarkupToTlObject(keyboard, usernameResolver) {
43
+ const rows_ = new Array();
44
+ for (const row of keyboard.inlineKeyboard) {
45
+ const row_ = new Array();
46
+ for (const button of row) {
47
+ row_.push(await (0, _1_inline_keyboard_button_js_1.inlineKeyboardButtonToTlObject)(button, usernameResolver));
48
+ }
49
+ rows_.push(new types.KeyboardButtonRow({ buttons: row_ }));
50
+ }
51
+ return new types.ReplyInlineMarkup({ rows: rows_ });
52
+ }
53
+ exports.inlineKeyboardMarkupToTlObject = inlineKeyboardMarkupToTlObject;
@@ -0,0 +1,12 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { KeyboardButton } from "./1_keyboard_button.js";
3
+ export interface ReplyKeyboardMarkup {
4
+ keyboard: KeyboardButton[][];
5
+ isPersistent?: boolean;
6
+ resizeKeyboard?: boolean;
7
+ oneTimeKeyboard?: boolean;
8
+ inputFieldPlaceholder?: string;
9
+ selective?: boolean;
10
+ }
11
+ export declare function constructReplyKeyboardMarkup(keyboard_: types.ReplyKeyboardMarkup): ReplyKeyboardMarkup;
12
+ export declare function replyKeyboardMarkupToTlObject(replyMarkup: ReplyKeyboardMarkup): types.ReplyKeyboardMarkup;
@@ -0,0 +1,65 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.replyKeyboardMarkupToTlObject = exports.constructReplyKeyboardMarkup = void 0;
27
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
28
+ const types = __importStar(require("../tl/2_types.js"));
29
+ const _1_keyboard_button_js_1 = require("./1_keyboard_button.js");
30
+ function constructReplyKeyboardMarkup(keyboard_) {
31
+ const rows = new Array();
32
+ for (const row_ of keyboard_.rows.map((v) => v[_1_tl_object_js_1.as](types.KeyboardButtonRow))) {
33
+ const row = new Array();
34
+ for (const button_ of row_.buttons) {
35
+ row.push((0, _1_keyboard_button_js_1.constructKeyboardButton)(button_));
36
+ }
37
+ rows.push(row);
38
+ }
39
+ return {
40
+ resizeKeyboard: keyboard_.resize || false,
41
+ oneTimeKeyboard: keyboard_.singleUse || false,
42
+ selective: keyboard_.selective || false,
43
+ isPersistent: keyboard_.persistent || false,
44
+ keyboard: rows,
45
+ };
46
+ }
47
+ exports.constructReplyKeyboardMarkup = constructReplyKeyboardMarkup;
48
+ function replyKeyboardMarkupToTlObject(replyMarkup) {
49
+ const rows_ = new Array();
50
+ for (const row of replyMarkup.keyboard) {
51
+ const row_ = new Array();
52
+ for (const button of row) {
53
+ row_.push((0, _1_keyboard_button_js_1.keyboardButtonToTlObject)(button));
54
+ }
55
+ rows_.push(new types.KeyboardButtonRow({ buttons: row_ }));
56
+ }
57
+ return new types.ReplyKeyboardMarkup({
58
+ resize: replyMarkup.resizeKeyboard || undefined,
59
+ singleUse: replyMarkup.oneTimeKeyboard || undefined,
60
+ selective: replyMarkup.selective || undefined,
61
+ persistent: replyMarkup.isPersistent || undefined,
62
+ rows: rows_,
63
+ });
64
+ }
65
+ exports.replyKeyboardMarkupToTlObject = replyKeyboardMarkupToTlObject;
@@ -0,0 +1,22 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { ForceReply } from "./0_force_reply.js";
3
+ import { MessageEntity } from "./0_message_entity.js";
4
+ import { ReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
5
+ import { Chat } from "./1_chat.js";
6
+ import { User } from "./1_user.js";
7
+ import { InlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
8
+ import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
9
+ export interface Message {
10
+ id: number;
11
+ from?: User;
12
+ chat: Chat;
13
+ text?: string;
14
+ caption?: string;
15
+ entities?: MessageEntity[];
16
+ captionEntities?: MessageEntity[];
17
+ date?: Date;
18
+ editDate?: Date;
19
+ views?: number;
20
+ replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
21
+ }
22
+ export declare function constructMessage(message_: types.Message, users: types.TypeUser[], chats: types.TypeChat[]): Message;
@@ -0,0 +1,114 @@
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 __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructMessage = void 0;
27
+ const _0_control_js_1 = require("../utilities/0_control.js");
28
+ const _0_object_js_1 = require("../utilities/0_object.js");
29
+ const types = __importStar(require("../tl/2_types.js"));
30
+ const _0_force_reply_js_1 = require("./0_force_reply.js");
31
+ const _0_message_entity_js_1 = require("./0_message_entity.js");
32
+ const _0_reply_keyboard_remove_js_1 = require("./0_reply_keyboard_remove.js");
33
+ const _1_chat_js_1 = require("./1_chat.js");
34
+ const _1_user_js_1 = require("./1_user.js");
35
+ const _2_inline_keyboard_markup_js_1 = require("./2_inline_keyboard_markup.js");
36
+ const _2_reply_keyboard_markup_js_1 = require("./2_reply_keyboard_markup.js");
37
+ function constructMessage(message_, users, chats) {
38
+ let chat_ = null;
39
+ if (message_.peerId instanceof types.PeerUser) {
40
+ for (const user of users) {
41
+ if (user instanceof types.User && user.id == message_.peerId.userId) {
42
+ chat_ = (0, _1_chat_js_1.constructChat)(user);
43
+ break;
44
+ }
45
+ }
46
+ }
47
+ else if (message_.peerId instanceof types.PeerChat) {
48
+ for (const chat of chats) {
49
+ if (chat instanceof types.Chat && chat.id == message_.peerId.chatId) {
50
+ chat_ = (0, _1_chat_js_1.constructChat)(chat);
51
+ break;
52
+ }
53
+ }
54
+ }
55
+ else if (message_.peerId instanceof types.PeerChannel) {
56
+ for (const chat of chats) {
57
+ if (chat instanceof types.Channel && chat.id == message_.peerId.channelId) {
58
+ chat_ = (0, _1_chat_js_1.constructChat)(chat);
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ if (!chat_) {
64
+ (0, _0_control_js_1.UNREACHABLE)();
65
+ }
66
+ const message = { id: message_.id, chat: chat_, views: message_.views };
67
+ if (message_.fromId instanceof types.PeerUser) {
68
+ for (const user of users) {
69
+ if (user instanceof types.User && user.id == message_.fromId.userId) {
70
+ message.from = (0, _1_user_js_1.constructUser)(user);
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ if (message_.message) {
76
+ if (message_.media == undefined) {
77
+ message.text = message_.message;
78
+ }
79
+ else {
80
+ message.caption = message_.message;
81
+ }
82
+ }
83
+ if (message_.entities != undefined) {
84
+ if (message_.media == undefined) {
85
+ message.entities = message_.entities.map(_0_message_entity_js_1.constructMessageEntity).filter((v) => v);
86
+ }
87
+ else {
88
+ message.captionEntities = message_.entities.map(_0_message_entity_js_1.constructMessageEntity).filter((v) => v);
89
+ }
90
+ }
91
+ message.date = new Date(message_.date * 1000);
92
+ if (message_.editDate != undefined) {
93
+ message.editDate = new Date(message_.editDate * 1000);
94
+ }
95
+ if (message_.replyMarkup) {
96
+ if (message_.replyMarkup instanceof types.ReplyKeyboardMarkup) {
97
+ message.replyMarkup = (0, _2_reply_keyboard_markup_js_1.constructReplyKeyboardMarkup)(message_.replyMarkup);
98
+ }
99
+ else if (message_.replyMarkup instanceof types.ReplyInlineMarkup) {
100
+ message.replyMarkup = (0, _2_inline_keyboard_markup_js_1.constructInlineKeyboardMarkup)(message_.replyMarkup);
101
+ }
102
+ else if (message_.replyMarkup instanceof types.ReplyKeyboardHide) {
103
+ message.replyMarkup = (0, _0_reply_keyboard_remove_js_1.constructReplyKeyboardRemove)(message_.replyMarkup);
104
+ }
105
+ else if (message_.replyMarkup instanceof types.ReplyKeyboardForceReply) {
106
+ message.replyMarkup = (0, _0_force_reply_js_1.constructForceReply)(message_.replyMarkup);
107
+ }
108
+ else {
109
+ (0, _0_control_js_1.UNREACHABLE)();
110
+ }
111
+ }
112
+ return (0, _0_object_js_1.cleanObject)(message);
113
+ }
114
+ exports.constructMessage = constructMessage;
@@ -0,0 +1 @@
1
+ export declare function UNREACHABLE(): never;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNREACHABLE = void 0;
4
+ function UNREACHABLE() {
5
+ throw new Error("Unreachable");
6
+ }
7
+ exports.UNREACHABLE = UNREACHABLE;
@@ -0,0 +1 @@
1
+ export declare function cleanObject<T extends Record<string, any>>(object: T): T;