@mtkruto/node 0.0.992 → 0.0.994

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 (41) hide show
  1. package/esm/4_constants.d.ts +1 -1
  2. package/esm/4_constants.js +1 -1
  3. package/esm/5_client.d.ts +2 -1
  4. package/esm/5_client.js +2 -1
  5. package/esm/client/0_message.d.ts +3 -3
  6. package/esm/client/0_message.js +3 -3
  7. package/esm/client/0_utilities.d.ts +2 -0
  8. package/esm/client/0_utilities.js +1 -0
  9. package/esm/client/3_types.d.ts +221 -0
  10. package/esm/client/3_types.js +1 -0
  11. package/esm/client/4_composer.d.ts +13 -0
  12. package/esm/client/4_composer.js +80 -0
  13. package/esm/client/{3_client.d.ts → 5_client.d.ts} +20 -165
  14. package/esm/client/{3_client.js → 5_client.js} +143 -127
  15. package/esm/mod.d.ts +1 -0
  16. package/esm/mod.js +1 -0
  17. package/esm/tl/6_message.d.ts +2 -2
  18. package/esm/tl/6_message.js +2 -2
  19. package/esm/tl/7_message_container.d.ts +3 -3
  20. package/esm/tl/7_message_container.js +2 -2
  21. package/package.json +1 -1
  22. package/script/4_constants.d.ts +1 -1
  23. package/script/4_constants.js +1 -1
  24. package/script/5_client.d.ts +2 -1
  25. package/script/5_client.js +4 -1
  26. package/script/client/0_message.d.ts +3 -3
  27. package/script/client/0_message.js +2 -2
  28. package/script/client/0_utilities.d.ts +2 -0
  29. package/script/client/0_utilities.js +3 -1
  30. package/script/client/3_types.d.ts +221 -0
  31. package/script/client/3_types.js +2 -0
  32. package/script/client/4_composer.d.ts +13 -0
  33. package/script/client/4_composer.js +85 -0
  34. package/script/client/{3_client.d.ts → 5_client.d.ts} +20 -165
  35. package/script/client/{3_client.js → 5_client.js} +142 -125
  36. package/script/mod.d.ts +1 -0
  37. package/script/mod.js +1 -0
  38. package/script/tl/6_message.d.ts +2 -2
  39. package/script/tl/6_message.js +4 -4
  40. package/script/tl/7_message_container.d.ts +3 -3
  41. package/script/tl/7_message_container.js +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = exports.ParseMode = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
3
+ exports.Client = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
4
4
  const _0_deps_js_1 = require("../0_deps.js");
5
5
  const _1_utilities_js_1 = require("../1_utilities.js");
6
6
  const _2_tl_js_1 = require("../2_tl.js");
@@ -13,6 +13,7 @@ const _0_password_js_1 = require("./0_password.js");
13
13
  const _0_html_js_1 = require("./0_html.js");
14
14
  const _2_client_plain_js_1 = require("./2_client_plain.js");
15
15
  const _1_client_abstract_js_1 = require("./1_client_abstract.js");
16
+ const _4_composer_js_1 = require("./4_composer.js");
16
17
  const d = (0, _0_deps_js_1.debug)("Client");
17
18
  const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
18
19
  const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
@@ -23,11 +24,6 @@ exports.getStickerSetName = Symbol();
23
24
  exports.handleMigrationError = Symbol();
24
25
  exports.getMessageWithReply = Symbol();
25
26
  exports.restartAuth = Symbol();
26
- var ParseMode;
27
- (function (ParseMode) {
28
- ParseMode["None"] = "none";
29
- ParseMode["HTML"] = "html";
30
- })(ParseMode = exports.ParseMode || (exports.ParseMode = {}));
31
27
  class Client extends _1_client_abstract_js_1.ClientAbstract {
32
28
  /**
33
29
  * Constructs the client.
@@ -220,7 +216,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
220
216
  writable: true,
221
217
  value: new _1_utilities_js_1.Queue("processUpdates")
222
218
  });
223
- Object.defineProperty(this, "handler", {
219
+ Object.defineProperty(this, "_handler", {
224
220
  enumerable: true,
225
221
  configurable: true,
226
222
  writable: true,
@@ -228,7 +224,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
228
224
  next();
229
225
  }
230
226
  });
231
- this.parseMode = params?.parseMode ?? ParseMode.None;
227
+ this.parseMode = params?.parseMode ?? "none";
232
228
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
233
229
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
234
230
  this.langCode = params?.langCode ?? _4_constants_js_1.LANG_CODE;
@@ -239,7 +235,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
239
235
  this.autoStart = params?.autoStart ?? true;
240
236
  }
241
237
  propagateConnectionState(connectionState) {
242
- return this.handler({ connectionState }, resolve);
238
+ return this._handler({ connectionState }, _0_utilities_js_1.resolve);
243
239
  }
244
240
  /**
245
241
  * Sets the DC and resets the auth key stored in the session provider
@@ -312,6 +308,16 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
312
308
  release();
313
309
  }
314
310
  }
311
+ async assertUser(source) {
312
+ if (await this.storage.getAccountType() != "user") {
313
+ throw new Error(`${source}: not user a client`);
314
+ }
315
+ }
316
+ async assertBot(source) {
317
+ if (await this.storage.getAccountType() != "bot") {
318
+ throw new Error(`${source}: not a bot client`);
319
+ }
320
+ }
315
321
  async fetchState(source) {
316
322
  const state = await this.invoke(new _2_tl_js_1.functions.UpdatesGetState());
317
323
  this.updateState = state;
@@ -356,7 +362,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
356
362
  }
357
363
  async propagateAuthorizationState(authorized) {
358
364
  if (this.lastPropagatedAuthorizationState != authorized) {
359
- await this.handler({ authorizationState: { authorized } }, resolve);
365
+ await this._handler({ authorizationState: { authorized } }, _0_utilities_js_1.resolve);
360
366
  this.lastPropagatedAuthorizationState = authorized;
361
367
  }
362
368
  }
@@ -681,7 +687,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
681
687
  this.state.seqNo++;
682
688
  }
683
689
  const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
684
- const message = new _2_tl_js_1.Message(messageId, seqNo, function_);
690
+ const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
685
691
  await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
686
692
  d("invoked %s", function_.constructor.name);
687
693
  if (noWait) {
@@ -1176,6 +1182,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1176
1182
  }
1177
1183
  return messages;
1178
1184
  }
1185
+ async resolveSendAs(params) {
1186
+ await this.assertUser("sendAs");
1187
+ return params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined;
1188
+ }
1179
1189
  /**
1180
1190
  * Send a text message.
1181
1191
  *
@@ -1183,50 +1193,16 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1183
1193
  * @param text The message's text.
1184
1194
  */
1185
1195
  async sendMessage(chatId, text, params) {
1186
- const entities_ = params?.entities ?? [];
1187
- const parseMode = params?.parseMode ?? this.parseMode;
1188
- switch (parseMode) {
1189
- case ParseMode.None:
1190
- break;
1191
- case ParseMode.HTML: {
1192
- const [newText, entitiesToPush] = (0, _0_html_js_1.parseHtml)(text);
1193
- text = newText;
1194
- for (const entity of entitiesToPush) {
1195
- entities_.push(entity);
1196
- }
1197
- }
1198
- }
1199
- let replyMarkup = undefined;
1200
- if (params?.replyMarkup) {
1201
- if ("inlineKeyboard" in params.replyMarkup) {
1202
- replyMarkup = await (0, _3_types_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1203
- const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
1204
- return new _2_tl_js_1.types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1205
- });
1206
- }
1207
- else if ("keyboard" in params.replyMarkup) {
1208
- replyMarkup = (0, _3_types_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1209
- }
1210
- else if ("removeKeyboard" in params.replyMarkup) {
1211
- replyMarkup = (0, _3_types_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1212
- }
1213
- else if ("forceReply" in params.replyMarkup) {
1214
- replyMarkup = (0, _3_types_js_1.forceReplyToTlObject)(params.replyMarkup);
1215
- }
1216
- else {
1217
- throw new Error("The replyMarkup parameter has an unexpected type");
1218
- }
1219
- }
1196
+ const [message, entities] = this.parseText(text, params);
1197
+ const replyMarkup = await this.constructReplyMarkup(params);
1220
1198
  const peer = await this.getInputPeer(chatId);
1221
1199
  const randomId = (0, _1_utilities_js_1.getRandomId)();
1222
- const message = text;
1223
1200
  const noWebpage = params?.disableWebPagePreview ? true : undefined;
1224
1201
  const silent = params?.disableNotification ? true : undefined;
1225
1202
  const noforwards = params?.protectContent ? true : undefined;
1226
1203
  const replyToMsgId = params?.replyToMessageId;
1227
1204
  const topMsgId = params?.messageThreadId;
1228
- const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined;
1229
- const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_1.messageEntityToTlObject)(v)) : undefined;
1205
+ const sendAs = await this.resolveSendAs(params);
1230
1206
  const result = await this.invoke(new _2_tl_js_1.functions.MessagesSendMessage({
1231
1207
  peer,
1232
1208
  randomId,
@@ -1239,56 +1215,46 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1239
1215
  entities,
1240
1216
  replyMarkup,
1241
1217
  }));
1242
- return await this.updatesToMessages(chatId, result).then((v) => v[0]);
1218
+ const message_ = await this.updatesToMessages(chatId, result).then((v) => v[0]);
1219
+ return Client.assertMsgHas(message_, "text");
1243
1220
  }
1244
- /**
1245
- * Edit a message's text.
1246
- *
1247
- * @param chatId The chat where the message is.
1248
- * @param messageId The ID of the message.
1249
- * @param text The new text of the message.
1250
- */
1251
- async editMessageText(chatId, messageId, text, params) {
1221
+ parseText(text, params) {
1252
1222
  const entities_ = params?.entities ?? [];
1253
1223
  const parseMode = params?.parseMode ?? this.parseMode;
1254
1224
  switch (parseMode) {
1255
- case ParseMode.None:
1225
+ case "none":
1256
1226
  break;
1257
- case ParseMode.HTML: {
1227
+ case "html": {
1258
1228
  const [newText, entitiesToPush] = (0, _0_html_js_1.parseHtml)(text);
1259
1229
  text = newText;
1260
1230
  for (const entity of entitiesToPush) {
1261
1231
  entities_.push(entity);
1262
1232
  }
1233
+ break;
1263
1234
  }
1235
+ default:
1236
+ (0, _1_utilities_js_1.UNREACHABLE)();
1264
1237
  }
1265
- let replyMarkup = undefined;
1266
- if (params?.replyMarkup) {
1267
- if ("inlineKeyboard" in params.replyMarkup) {
1268
- replyMarkup = await (0, _3_types_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1269
- const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
1270
- return new _2_tl_js_1.types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1271
- });
1272
- }
1273
- else if ("keyboard" in params.replyMarkup) {
1274
- replyMarkup = (0, _3_types_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1275
- }
1276
- else if ("removeKeyboard" in params.replyMarkup) {
1277
- replyMarkup = (0, _3_types_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1278
- }
1279
- else if ("forceReply" in params.replyMarkup) {
1280
- replyMarkup = (0, _3_types_js_1.forceReplyToTlObject)(params.replyMarkup);
1281
- }
1282
- else {
1283
- throw new Error("The replyMarkup parameter has an unexpected type");
1284
- }
1285
- }
1286
- const id = messageId;
1287
- const peer = await this.getInputPeer(chatId);
1288
1238
  const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_1.messageEntityToTlObject)(v)) : undefined;
1289
- const message = text;
1290
- const noWebpage = params?.disableWebPagePreview ? true : undefined;
1291
- await this.invoke(new _2_tl_js_1.functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
1239
+ return [text, entities];
1240
+ }
1241
+ /**
1242
+ * Edit a message's text.
1243
+ *
1244
+ * @param chatId The chat where the message is.
1245
+ * @param messageId The ID of the message.
1246
+ * @param text The new text of the message.
1247
+ */
1248
+ async editMessageText(chatId, messageId, text, params) {
1249
+ const [message, entities] = this.parseText(text, params);
1250
+ await this.invoke(new _2_tl_js_1.functions.MessagesEditMessage({
1251
+ id: messageId,
1252
+ peer: await this.getInputPeer(chatId),
1253
+ entities,
1254
+ message,
1255
+ noWebpage: params?.disableWebPagePreview ? true : undefined,
1256
+ replyMarkup: await this.constructReplyMarkup(params),
1257
+ }));
1292
1258
  }
1293
1259
  async getMessagesInner(chatId_, messageIds) {
1294
1260
  const peer = await this.getInputPeer(chatId_);
@@ -1487,7 +1453,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1487
1453
  update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
1488
1454
  const key = update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ? "message" : "editedMessage";
1489
1455
  const message = await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1490
- await this.handler({ [key]: message }, resolve);
1456
+ await this._handler({ [key]: message }, _0_utilities_js_1.resolve);
1491
1457
  }
1492
1458
  if (update instanceof _2_tl_js_1.types.UpdateDeleteMessages) {
1493
1459
  const deletedMessages = new Array();
@@ -1502,7 +1468,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1502
1468
  }
1503
1469
  }
1504
1470
  if (deletedMessages.length > 0) {
1505
- await this.handler({ deletedMessages: deletedMessages }, resolve);
1471
+ await this._handler({ deletedMessages: deletedMessages }, _0_utilities_js_1.resolve);
1506
1472
  }
1507
1473
  }
1508
1474
  else if (update instanceof _2_tl_js_1.types.UpdateDeleteChannelMessages) {
@@ -1516,50 +1482,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1516
1482
  await this.storage.setMessage(chatId, messageId, null);
1517
1483
  }
1518
1484
  if (deletedMessages.length > 0) {
1519
- await this.handler({ deletedMessages: deletedMessages }, resolve);
1485
+ await this._handler({ deletedMessages: deletedMessages }, _0_utilities_js_1.resolve);
1520
1486
  }
1521
1487
  }
1522
1488
  if (update instanceof _2_tl_js_1.types.UpdateBotCallbackQuery || update instanceof _2_tl_js_1.types.UpdateInlineBotCallbackQuery) {
1523
- await this.handler({ callbackQuery: await (0, _3_types_js_1.constructCallbackQuery)(update, this[exports.getEntity].bind(this), this[exports.getMessageWithReply].bind(this)) }, resolve);
1489
+ await this._handler({ callbackQuery: await (0, _3_types_js_1.constructCallbackQuery)(update, this[exports.getEntity].bind(this), this[exports.getMessageWithReply].bind(this)) }, _0_utilities_js_1.resolve);
1524
1490
  }
1525
1491
  else if (update instanceof _2_tl_js_1.types.UpdateBotInlineQuery) {
1526
- await this.handler({ inlineQuery: await (0, _3_types_js_1.constructInlineQuery)(update, this[exports.getEntity].bind(this)) }, resolve);
1492
+ await this._handler({ inlineQuery: await (0, _3_types_js_1.constructInlineQuery)(update, this[exports.getEntity].bind(this)) }, _0_utilities_js_1.resolve);
1527
1493
  }
1528
1494
  }
1529
- use(middleware) {
1530
- const handler = this.handler;
1531
- this.handler = async (upd, next) => {
1532
- let called = false;
1533
- await handler(upd, async () => {
1534
- if (called)
1535
- return;
1536
- called = true;
1537
- await middleware(upd, next);
1538
- });
1539
- };
1540
- }
1541
- on(filter, handler) {
1542
- const type = typeof filter === "string" ? filter : filter[0];
1543
- const keys = Array.isArray(filter) ? filter.slice(1) : [];
1544
- this.use((update, next) => {
1545
- if (type in update) {
1546
- if (keys.length > 0) {
1547
- for (const key of keys) {
1548
- // deno-lint-ignore ban-ts-comment
1549
- // @ts-ignore
1550
- if (!(key in update[type])) {
1551
- return next();
1552
- }
1553
- }
1554
- }
1555
- // deno-lint-ignore ban-ts-comment
1556
- // @ts-ignore
1557
- return handler(update, next);
1558
- }
1559
- else {
1560
- return next();
1561
- }
1562
- });
1495
+ set handler(handler) {
1496
+ this._handler = (0, _4_composer_js_1.call)(handler);
1563
1497
  }
1564
1498
  /**
1565
1499
  * Answer a callback query. Bot-only.
@@ -1567,6 +1501,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1567
1501
  * @param id ID of the callback query to answer.
1568
1502
  */
1569
1503
  async answerCallbackQuery(id, params) {
1504
+ await this.assertBot("answerCallbackQuery");
1570
1505
  await this.invoke(new _2_tl_js_1.functions.MessagesSetBotCallbackAnswer({
1571
1506
  queryId: BigInt(id),
1572
1507
  cacheTime: params?.cacheTime ?? 0,
@@ -1574,6 +1509,88 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1574
1509
  alert: params?.alert ? true : undefined,
1575
1510
  }));
1576
1511
  }
1512
+ async constructReplyMarkup(params) {
1513
+ let replyMarkup = undefined;
1514
+ if (params?.replyMarkup) {
1515
+ await this.assertBot("replyMarkup");
1516
+ if ("inlineKeyboard" in params.replyMarkup) {
1517
+ replyMarkup = await (0, _3_types_js_1.inlineKeyboardMarkupToTlObject)(params.replyMarkup, async (v) => {
1518
+ const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
1519
+ return new _2_tl_js_1.types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1520
+ });
1521
+ }
1522
+ else if ("keyboard" in params.replyMarkup) {
1523
+ replyMarkup = (0, _3_types_js_1.replyKeyboardMarkupToTlObject)(params.replyMarkup);
1524
+ }
1525
+ else if ("removeKeyboard" in params.replyMarkup) {
1526
+ replyMarkup = (0, _3_types_js_1.replyKeyboardRemoveToTlObject)(params.replyMarkup);
1527
+ }
1528
+ else if ("forceReply" in params.replyMarkup) {
1529
+ replyMarkup = (0, _3_types_js_1.forceReplyToTlObject)(params.replyMarkup);
1530
+ }
1531
+ else {
1532
+ throw new Error("The replyMarkup parameter has an unexpected type");
1533
+ }
1534
+ }
1535
+ return replyMarkup;
1536
+ }
1537
+ static assertMsgHas(message, key) {
1538
+ if (!(key in message) || message[key] === undefined) {
1539
+ (0, _1_utilities_js_1.UNREACHABLE)();
1540
+ }
1541
+ return message;
1542
+ }
1543
+ /**
1544
+ * Send a poll.
1545
+ *
1546
+ * @param chatId The chat to send the poll to.
1547
+ * @param question The poll's question.
1548
+ * @param options The poll's options.
1549
+ */
1550
+ async sendPoll(chatId, question, options, params) {
1551
+ const peer = await this.getInputPeer(chatId);
1552
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
1553
+ const silent = params?.disableNotification ? true : undefined;
1554
+ const noforwards = params?.protectContent ? true : undefined;
1555
+ const replyToMsgId = params?.replyToMessageId;
1556
+ const topMsgId = params?.messageThreadId;
1557
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
1558
+ const replyMarkup = await this.constructReplyMarkup(params);
1559
+ const explanation = params?.explanation;
1560
+ const parseResult = explanation !== undefined ? this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
1561
+ const solution = parseResult === undefined ? undefined : parseResult[0];
1562
+ const solutionEntities = parseResult === undefined ? undefined : parseResult[1];
1563
+ const answers = options.map((v, i) => new _2_tl_js_1.types.PollAnswer({ option: new Uint8Array([i]), text: v }));
1564
+ const poll = new _2_tl_js_1.types.Poll({
1565
+ id: (0, _1_utilities_js_1.getRandomId)(),
1566
+ answers,
1567
+ question,
1568
+ closed: params?.isClosed ? true : undefined,
1569
+ closeDate: params?.closeDate ? Math.floor(params.closeDate.getTime() / 1000) : undefined,
1570
+ closePeriod: params?.openPeriod ? params.openPeriod : undefined,
1571
+ multipleChoice: params?.allowMultipleAnswers ? true : undefined,
1572
+ publicVoters: params?.isAnonymous === false ? true : undefined,
1573
+ quiz: params?.type == "quiz" ? true : undefined,
1574
+ });
1575
+ const media = new _2_tl_js_1.types.InputMediaPoll({
1576
+ poll,
1577
+ correctAnswers: params?.correctOptionIndex ? [new Uint8Array([params.correctOptionIndex])] : undefined,
1578
+ solution,
1579
+ solutionEntities,
1580
+ });
1581
+ const result = await this.invoke(new _2_tl_js_1.functions.MessagesSendMedia({
1582
+ peer,
1583
+ randomId,
1584
+ silent,
1585
+ noforwards,
1586
+ replyMarkup,
1587
+ replyTo: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ replyToMsgId, topMsgId }) : undefined,
1588
+ sendAs,
1589
+ media,
1590
+ message: "",
1591
+ }));
1592
+ const message = await this.updatesToMessages(chatId, result).then((v) => v[0]);
1593
+ return Client.assertMsgHas(message, "poll");
1594
+ }
1577
1595
  }
1578
1596
  exports.Client = Client;
1579
- const resolve = () => Promise.resolve();
package/script/mod.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./3_storage.js";
10
10
  export * from "./3_transport.js";
11
11
  export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
12
12
  export * from "./5_client.js";
13
+ export * from "./3_types.js";
package/script/mod.js CHANGED
@@ -32,3 +32,4 @@ Object.defineProperty(exports, "LAYER", { enumerable: true, get: function () { r
32
32
  Object.defineProperty(exports, "SYSTEM_LANG_CODE", { enumerable: true, get: function () { return _4_constants_js_1.SYSTEM_LANG_CODE; } });
33
33
  Object.defineProperty(exports, "SYSTEM_VERSION", { enumerable: true, get: function () { return _4_constants_js_1.SYSTEM_VERSION; } });
34
34
  __exportStar(require("./5_client.js"), exports);
35
+ __exportStar(require("./3_types.js"), exports);
@@ -1,10 +1,10 @@
1
1
  import { ReadObject, TLReader } from "./3_tl_reader.js";
2
2
  import { RPCResult } from "./5_rpc_result.js";
3
- export declare class Message {
3
+ export declare class Message_ {
4
4
  readonly id: bigint;
5
5
  readonly seqNo: number;
6
6
  readonly body: ReadObject | RPCResult;
7
7
  constructor(id: bigint, seqNo: number, body: ReadObject | RPCResult);
8
8
  serialize(): Uint8Array;
9
- static deserialize(reader: TLReader): Message;
9
+ static deserialize(reader: TLReader): Message_;
10
10
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Message = void 0;
3
+ exports.Message_ = void 0;
4
4
  const _1_tl_object_js_1 = require("./1_tl_object.js");
5
5
  const _3_tl_reader_js_1 = require("./3_tl_reader.js");
6
6
  const _4_tl_writer_js_1 = require("./4_tl_writer.js");
@@ -20,7 +20,7 @@ function calculateLength(object) {
20
20
  }
21
21
  return length;
22
22
  }
23
- class Message {
23
+ class Message_ {
24
24
  constructor(id, seqNo, body) {
25
25
  Object.defineProperty(this, "id", {
26
26
  enumerable: true,
@@ -67,7 +67,7 @@ class Message {
67
67
  body = reader.readObject(cid);
68
68
  }
69
69
  }
70
- return new Message(id_, seqNo, body);
70
+ return new Message_(id_, seqNo, body);
71
71
  }
72
72
  }
73
- exports.Message = Message;
73
+ exports.Message_ = Message_;
@@ -1,9 +1,9 @@
1
1
  import { id } from "./1_tl_object.js";
2
- import { Message } from "./6_message.js";
2
+ import { Message_ } from "./6_message.js";
3
3
  export declare class MessageContainer {
4
- messages: Message[];
4
+ messages: Message_[];
5
5
  static get [id](): number;
6
- constructor(messages: Message[]);
6
+ constructor(messages: Message_[]);
7
7
  serialize(): Uint8Array;
8
8
  static deserialize(buffer: Uint8Array): MessageContainer;
9
9
  }
@@ -31,7 +31,7 @@ class MessageContainer {
31
31
  const length = reader.readInt32();
32
32
  const messages = new Array();
33
33
  for (let i = 0; i < length; i++) {
34
- messages.push(_6_message_js_1.Message.deserialize(reader));
34
+ messages.push(_6_message_js_1.Message_.deserialize(reader));
35
35
  }
36
36
  return new MessageContainer(messages);
37
37
  }