@mtcute/core 0.29.4 → 0.29.5

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 (64) hide show
  1. package/highlevel/base.cjs +0 -1
  2. package/highlevel/base.js +0 -1
  3. package/highlevel/methods/chats/get-creator-after-leave.cjs +4 -14
  4. package/highlevel/methods/chats/get-creator-after-leave.js +5 -15
  5. package/highlevel/methods/files/normalize-input-media.cjs +16 -14
  6. package/highlevel/methods/files/normalize-input-media.js +16 -14
  7. package/highlevel/methods/messages/close-poll.cjs +2 -1
  8. package/highlevel/methods/messages/close-poll.js +2 -1
  9. package/highlevel/methods/messages/send-vote.cjs +3 -1
  10. package/highlevel/methods/messages/send-vote.js +4 -2
  11. package/highlevel/storage/service/peers.cjs +1 -0
  12. package/highlevel/storage/service/peers.js +1 -0
  13. package/highlevel/types/media/input-media/types.d.cts +10 -13
  14. package/highlevel/types/media/input-media/types.d.ts +10 -13
  15. package/highlevel/types/media/poll.cjs +4 -1
  16. package/highlevel/types/media/poll.d.cts +2 -2
  17. package/highlevel/types/media/poll.d.ts +2 -2
  18. package/highlevel/types/media/poll.js +4 -1
  19. package/highlevel/types/messages/dialog.cjs +4 -0
  20. package/highlevel/types/messages/dialog.d.cts +2 -0
  21. package/highlevel/types/messages/dialog.d.ts +2 -0
  22. package/highlevel/types/messages/dialog.js +4 -0
  23. package/highlevel/types/messages/message-action.cjs +18 -0
  24. package/highlevel/types/messages/message-action.d.cts +19 -1
  25. package/highlevel/types/messages/message-action.d.ts +19 -1
  26. package/highlevel/types/messages/message-action.js +18 -0
  27. package/highlevel/types/peers/forum-topic.cjs +4 -0
  28. package/highlevel/types/peers/forum-topic.d.cts +2 -0
  29. package/highlevel/types/peers/forum-topic.d.ts +2 -0
  30. package/highlevel/types/peers/forum-topic.js +4 -0
  31. package/highlevel/types/peers/full-user.cjs +8 -0
  32. package/highlevel/types/peers/full-user.d.cts +4 -0
  33. package/highlevel/types/peers/full-user.d.ts +4 -0
  34. package/highlevel/types/peers/full-user.js +8 -0
  35. package/highlevel/types/peers/user.cjs +4 -0
  36. package/highlevel/types/peers/user.d.cts +2 -0
  37. package/highlevel/types/peers/user.d.ts +2 -0
  38. package/highlevel/types/peers/user.js +4 -0
  39. package/highlevel/types/updates/poll-update.cjs +8 -2
  40. package/highlevel/types/updates/poll-update.js +8 -2
  41. package/highlevel/updates/manager.cjs +7 -0
  42. package/highlevel/updates/manager.js +7 -0
  43. package/highlevel/worker/worker.cjs +6 -1
  44. package/highlevel/worker/worker.d.cts +2 -1
  45. package/highlevel/worker/worker.d.ts +2 -1
  46. package/highlevel/worker/worker.js +6 -1
  47. package/network/middlewares/flood-waiter.cjs +2 -1
  48. package/network/middlewares/flood-waiter.js +2 -1
  49. package/network/network-manager.cjs +1 -1
  50. package/network/network-manager.js +1 -1
  51. package/package.json +1 -1
  52. package/tl/api-schema.json +1 -1
  53. package/tl/binary/reader.cjs +86 -39
  54. package/tl/binary/reader.js +86 -39
  55. package/tl/binary/writer.cjs +308 -32
  56. package/tl/binary/writer.js +308 -32
  57. package/tl/compat/reader.cjs +34 -0
  58. package/tl/compat/reader.js +34 -0
  59. package/tl/index.d.cts +295 -25
  60. package/tl/index.d.ts +295 -25
  61. package/tl/inner-tl.cjs +16 -8
  62. package/tl/inner-tl.js +16 -8
  63. package/utils/binary/compat.cjs +41 -0
  64. package/utils/binary/compat.js +41 -0
@@ -44,7 +44,6 @@ class BaseTelegramClient {
44
44
  });
45
45
  if (!params.disableUpdates && params.updates !== false) {
46
46
  this.updates = new manager.UpdatesManager(this, params.updates);
47
- this.onServerUpdate.add(this.updates.handleUpdate.bind(this.updates));
48
47
  this.updates.onCatchingUp((catchingUp) => {
49
48
  this.onConnectionState.emit(catchingUp ? "updating" : "connected");
50
49
  });
package/highlevel/base.js CHANGED
@@ -37,7 +37,6 @@ class BaseTelegramClient {
37
37
  });
38
38
  if (!params.disableUpdates && params.updates !== false) {
39
39
  this.updates = new UpdatesManager(this, params.updates);
40
- this.onServerUpdate.add(this.updates.handleUpdate.bind(this.updates));
41
40
  this.updates.onCatchingUp((catchingUp) => {
42
41
  this.onConnectionState.emit(catchingUp ? "updating" : "connected");
43
42
  });
@@ -14,20 +14,10 @@ async function getCreatorAfterLeave(client, chatId) {
14
14
  if (peerUtils.isInputPeerUser(peer)) {
15
15
  throw new errors.MtInvalidPeerTypeError(chatId, "chat or channel");
16
16
  }
17
- let res;
18
- if (peerUtils.isInputPeerChannel(peer)) {
19
- res = await client.call({
20
- _: "channels.getFutureCreatorAfterLeave",
21
- channel: peerUtils.toInputChannel(peer)
22
- });
23
- } else if (peerUtils.isInputPeerChat(peer)) {
24
- res = await client.call({
25
- _: "messages.getFutureChatCreatorAfterLeave",
26
- peer
27
- });
28
- } else {
29
- throw new errors.MtInvalidPeerTypeError(chatId, "chat or channel");
30
- }
17
+ const res = await client.call({
18
+ _: "messages.getFutureChatCreatorAfterLeave",
19
+ peer
20
+ });
31
21
  if (res._ === "userEmpty") return null;
32
22
  return new user.User(res);
33
23
  }
@@ -1,26 +1,16 @@
1
1
  import { MtInvalidPeerTypeError } from "../../types/errors.js";
2
2
  import { User as User$2 } from "../../types/peers/user.js";
3
- import { isInputPeerUser, isInputPeerChannel, toInputChannel, isInputPeerChat } from "../../utils/peer-utils.js";
3
+ import { isInputPeerUser } from "../../utils/peer-utils.js";
4
4
  import { resolvePeer } from "../users/resolve-peer.js";
5
5
  async function getCreatorAfterLeave(client, chatId) {
6
6
  const peer = await resolvePeer(client, chatId);
7
7
  if (isInputPeerUser(peer)) {
8
8
  throw new MtInvalidPeerTypeError(chatId, "chat or channel");
9
9
  }
10
- let res;
11
- if (isInputPeerChannel(peer)) {
12
- res = await client.call({
13
- _: "channels.getFutureCreatorAfterLeave",
14
- channel: toInputChannel(peer)
15
- });
16
- } else if (isInputPeerChat(peer)) {
17
- res = await client.call({
18
- _: "messages.getFutureChatCreatorAfterLeave",
19
- peer
20
- });
21
- } else {
22
- throw new MtInvalidPeerTypeError(chatId, "chat or channel");
23
- }
10
+ const res = await client.call({
11
+ _: "messages.getFutureChatCreatorAfterLeave",
12
+ peer
13
+ });
24
14
  if (res._ === "userEmpty") return null;
25
15
  return new User$2(res);
26
16
  }
@@ -117,27 +117,28 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
117
117
  };
118
118
  }
119
119
  if (media.type === "poll" || media.type === "quiz") {
120
- const answers = media.answers.map((ans, idx) => {
121
- if (typeof ans === "object" && innerTl.isAnyPollAnswer(ans)) return ans;
120
+ const answers = await Promise.all(media.answers.map((ans) => {
121
+ if (typeof ans === "string") return { _: "inputPollAnswer", text: entities.inputTextToTl(ans) };
122
+ if (innerTl.isAnyPollAnswer(ans)) return ans;
123
+ if ("media" in ans && ans.media) {
124
+ return _normalizeInputMedia(client, ans.media, params, true).then((m) => ({
125
+ _: "inputPollAnswer",
126
+ text: entities.inputTextToTl(ans.text),
127
+ media: m
128
+ }));
129
+ }
122
130
  return {
123
- _: "pollAnswer",
124
- text: entities.inputTextToTl(ans),
125
- // emulate the behaviour of most implementations
126
- option: new Uint8Array([48 + idx])
131
+ _: "inputPollAnswer",
132
+ text: entities.inputTextToTl(ans.text)
127
133
  };
128
- });
134
+ }));
129
135
  let correct;
130
136
  let solution;
131
137
  let solutionEntities;
132
138
  if (media.type === "quiz") {
133
139
  let input2 = media.correct;
134
140
  if (!Array.isArray(input2)) input2 = [input2];
135
- correct = input2.map((it) => {
136
- if (typeof it === "number") {
137
- return answers[it].option;
138
- }
139
- return it;
140
- });
141
+ correct = input2;
141
142
  if (media.solution) {
142
143
  [solution, solutionEntities] = await normalizeText._normalizeInputText(client, media.solution);
143
144
  }
@@ -154,7 +155,8 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
154
155
  question: entities.inputTextToTl(media.question),
155
156
  answers,
156
157
  closePeriod: media.closePeriod,
157
- closeDate: miscUtils.normalizeDate(media.closeDate)
158
+ closeDate: miscUtils.normalizeDate(media.closeDate),
159
+ hash: Long.ZERO
158
160
  },
159
161
  correctAnswers: correct,
160
162
  solution,
@@ -110,27 +110,28 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
110
110
  };
111
111
  }
112
112
  if (media.type === "poll" || media.type === "quiz") {
113
- const answers = media.answers.map((ans, idx) => {
114
- if (typeof ans === "object" && isAnyPollAnswer(ans)) return ans;
113
+ const answers = await Promise.all(media.answers.map((ans) => {
114
+ if (typeof ans === "string") return { _: "inputPollAnswer", text: inputTextToTl(ans) };
115
+ if (isAnyPollAnswer(ans)) return ans;
116
+ if ("media" in ans && ans.media) {
117
+ return _normalizeInputMedia(client, ans.media, params, true).then((m) => ({
118
+ _: "inputPollAnswer",
119
+ text: inputTextToTl(ans.text),
120
+ media: m
121
+ }));
122
+ }
115
123
  return {
116
- _: "pollAnswer",
117
- text: inputTextToTl(ans),
118
- // emulate the behaviour of most implementations
119
- option: new Uint8Array([48 + idx])
124
+ _: "inputPollAnswer",
125
+ text: inputTextToTl(ans.text)
120
126
  };
121
- });
127
+ }));
122
128
  let correct;
123
129
  let solution;
124
130
  let solutionEntities;
125
131
  if (media.type === "quiz") {
126
132
  let input2 = media.correct;
127
133
  if (!Array.isArray(input2)) input2 = [input2];
128
- correct = input2.map((it) => {
129
- if (typeof it === "number") {
130
- return answers[it].option;
131
- }
132
- return it;
133
- });
134
+ correct = input2;
134
135
  if (media.solution) {
135
136
  [solution, solutionEntities] = await _normalizeInputText(client, media.solution);
136
137
  }
@@ -147,7 +148,8 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
147
148
  question: inputTextToTl(media.question),
148
149
  answers,
149
150
  closePeriod: media.closePeriod,
150
- closeDate: normalizeDate(media.closeDate)
151
+ closeDate: normalizeDate(media.closeDate),
152
+ hash: Long.ZERO
151
153
  },
152
154
  correctAnswers: correct,
153
155
  solution,
@@ -26,7 +26,8 @@ async function closePoll(client, params) {
26
26
  id: Long.ZERO,
27
27
  closed: true,
28
28
  question: { _: "textWithEntities", text: "", entities: [] },
29
- answers: []
29
+ answers: [],
30
+ hash: Long.ZERO
30
31
  }
31
32
  }
32
33
  });
@@ -19,7 +19,8 @@ async function closePoll(client, params) {
19
19
  id: Long.ZERO,
20
20
  closed: true,
21
21
  question: { _: "textWithEntities", text: "", entities: [] },
22
- answers: []
22
+ answers: [],
23
+ hash: Long.ZERO
23
24
  }
24
25
  }
25
26
  });
@@ -33,7 +33,9 @@ async function sendVote(client, params) {
33
33
  poll$1 = msg.media;
34
34
  options = options.map((opt) => {
35
35
  if (typeof opt === "number") {
36
- return poll$1.raw.answers[opt].option;
36
+ const answer = poll$1.raw.answers[opt];
37
+ typeAssertions.assertTypeIsNot("Poll.answers", answer, "inputPollAnswer");
38
+ return answer.option;
37
39
  }
38
40
  return opt;
39
41
  });
@@ -1,6 +1,6 @@
1
1
  import { MtArgumentError, MtTypeAssertionError } from "../../../types/errors.js";
2
2
  import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
- import { assertTypeIs } from "../../../utils/type-assertions.js";
3
+ import { assertTypeIsNot, assertTypeIs } from "../../../utils/type-assertions.js";
4
4
  import { assertIsUpdatesGroup } from "../../updates/utils.js";
5
5
  import { resolvePeer } from "../users/resolve-peer.js";
6
6
  import { getMessages } from "./get-messages.js";
@@ -26,7 +26,9 @@ async function sendVote(client, params) {
26
26
  poll = msg.media;
27
27
  options = options.map((opt) => {
28
28
  if (typeof opt === "number") {
29
- return poll.raw.answers[opt].option;
29
+ const answer = poll.raw.answers[opt];
30
+ assertTypeIsNot("Poll.answers", answer, "inputPollAnswer");
31
+ return answer.option;
30
32
  }
31
33
  return opt;
32
34
  });
@@ -182,6 +182,7 @@ class PeersService extends base.BaseService {
182
182
  contactRequirePremium: peer.contactRequirePremium,
183
183
  botBusiness: peer.botBusiness,
184
184
  botHasMainApp: peer.botHasMainApp,
185
+ botCanManageBots: peer.botCanManageBots,
185
186
  photo: peer.applyMinPhoto ? peer.photo : existing.photo,
186
187
  status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
187
188
  botInfoVersion: peer.botInfoVersion,
@@ -175,6 +175,7 @@ class PeersService extends BaseService {
175
175
  contactRequirePremium: peer.contactRequirePremium,
176
176
  botBusiness: peer.botBusiness,
177
177
  botHasMainApp: peer.botHasMainApp,
178
+ botCanManageBots: peer.botCanManageBots,
178
179
  photo: peer.applyMinPhoto ? peer.photo : existing.photo,
179
180
  status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
180
181
  botInfoVersion: peer.botInfoVersion,
@@ -384,6 +384,13 @@ export interface InputMediaInvoice extends CaptionMixin {
384
384
  */
385
385
  extendedMedia?: InputMediaLike;
386
386
  }
387
+ /** A poll answer */
388
+ export interface InputPollAnswer {
389
+ /** Answer text */
390
+ text: InputText;
391
+ /** Media to be attached near the answer */
392
+ media?: InputMediaLike;
393
+ }
387
394
  /**
388
395
  * A simple poll to be sent
389
396
  *
@@ -406,7 +413,7 @@ export interface InputMediaPoll extends CaptionMixin {
406
413
  * objects, with a single=byte incrementing
407
414
  * `option` value.
408
415
  */
409
- answers: (InputText | tl.TypePollAnswer)[];
416
+ answers: (InputText | tl.TypePollAnswer | InputPollAnswer)[];
410
417
  /**
411
418
  * Whether this is poll is closed
412
419
  * (i.e. nobody can vote anymore)
@@ -448,18 +455,8 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
448
455
  type: 'quiz';
449
456
  /**
450
457
  * Correct answer ID(s) or index(es).
451
- *
452
- * > **Note**: even though quizzes can actually
453
- * > only have exactly one correct answer,
454
- * > the API itself has the possibility to pass
455
- * > multiple or zero correct answers,
456
- * > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`
457
- * > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.
458
- * >
459
- * > But since the API has that option, we also provide it,
460
- * > maybe to future-proof this :shrug:
461
- */
462
- correct: MaybeArray<number | Uint8Array>;
458
+ */
459
+ correct: MaybeArray<number>;
463
460
  /**
464
461
  * Explanation of the quiz solution
465
462
  */
@@ -384,6 +384,13 @@ export interface InputMediaInvoice extends CaptionMixin {
384
384
  */
385
385
  extendedMedia?: InputMediaLike;
386
386
  }
387
+ /** A poll answer */
388
+ export interface InputPollAnswer {
389
+ /** Answer text */
390
+ text: InputText;
391
+ /** Media to be attached near the answer */
392
+ media?: InputMediaLike;
393
+ }
387
394
  /**
388
395
  * A simple poll to be sent
389
396
  *
@@ -406,7 +413,7 @@ export interface InputMediaPoll extends CaptionMixin {
406
413
  * objects, with a single=byte incrementing
407
414
  * `option` value.
408
415
  */
409
- answers: (InputText | tl.TypePollAnswer)[];
416
+ answers: (InputText | tl.TypePollAnswer | InputPollAnswer)[];
410
417
  /**
411
418
  * Whether this is poll is closed
412
419
  * (i.e. nobody can vote anymore)
@@ -448,18 +455,8 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
448
455
  type: 'quiz';
449
456
  /**
450
457
  * Correct answer ID(s) or index(es).
451
- *
452
- * > **Note**: even though quizzes can actually
453
- * > only have exactly one correct answer,
454
- * > the API itself has the possibility to pass
455
- * > multiple or zero correct answers,
456
- * > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`
457
- * > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.
458
- * >
459
- * > But since the API has that option, we also provide it,
460
- * > maybe to future-proof this :shrug:
461
- */
462
- correct: MaybeArray<number | Uint8Array>;
458
+ */
459
+ correct: MaybeArray<number>;
463
460
  /**
464
461
  * Explanation of the quiz solution
465
462
  */
@@ -6,6 +6,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const Long = require("long");
9
+ const typeAssertions = require("../../../utils/type-assertions.cjs");
9
10
  const memoize = require("../../utils/memoize.cjs");
10
11
  const messageEntity = require("../messages/message-entity.cjs");
11
12
  const inspectable = require("../../utils/inspectable.cjs");
@@ -91,6 +92,7 @@ class Poll {
91
92
  get answers() {
92
93
  const results = this.results?.results;
93
94
  return this.raw.answers.map((ans, idx) => {
95
+ typeAssertions.assertTypeIs("Poll.answers", ans, "pollAnswer");
94
96
  if (results) {
95
97
  return new PollAnswer(ans, results[idx]);
96
98
  }
@@ -177,7 +179,8 @@ class Poll {
177
179
  question: this.raw.question,
178
180
  answers: this.raw.answers,
179
181
  closePeriod: this.raw.closePeriod,
180
- closeDate: this.raw.closeDate
182
+ closeDate: this.raw.closeDate,
183
+ hash: Long.ZERO
181
184
  }
182
185
  };
183
186
  }
@@ -2,9 +2,9 @@ import { tl } from '../../../tl/index.js';
2
2
  import { PeersIndex } from '../peers/peers-index.js';
3
3
  import { MessageEntity } from '../messages/message-entity.js';
4
4
  export declare class PollAnswer {
5
- readonly raw: tl.TypePollAnswer;
5
+ readonly raw: tl.RawPollAnswer;
6
6
  readonly result?: tl.RawPollAnswerVoters | undefined;
7
- constructor(raw: tl.TypePollAnswer, result?: tl.RawPollAnswerVoters | undefined);
7
+ constructor(raw: tl.RawPollAnswer, result?: tl.RawPollAnswerVoters | undefined);
8
8
  /**
9
9
  * Answer text
10
10
  */
@@ -2,9 +2,9 @@ import { tl } from '../../../tl/index.js';
2
2
  import { PeersIndex } from '../peers/peers-index.js';
3
3
  import { MessageEntity } from '../messages/message-entity.js';
4
4
  export declare class PollAnswer {
5
- readonly raw: tl.TypePollAnswer;
5
+ readonly raw: tl.RawPollAnswer;
6
6
  readonly result?: tl.RawPollAnswerVoters | undefined;
7
- constructor(raw: tl.TypePollAnswer, result?: tl.RawPollAnswerVoters | undefined);
7
+ constructor(raw: tl.RawPollAnswer, result?: tl.RawPollAnswerVoters | undefined);
8
8
  /**
9
9
  * Answer text
10
10
  */
@@ -1,4 +1,5 @@
1
1
  import Long from "long";
2
+ import { assertTypeIs } from "../../../utils/type-assertions.js";
2
3
  import { memoizeGetters } from "../../utils/memoize.js";
3
4
  import { MessageEntity as MessageEntity$2 } from "../messages/message-entity.js";
4
5
  import { makeInspectable } from "../../utils/inspectable.js";
@@ -84,6 +85,7 @@ class Poll {
84
85
  get answers() {
85
86
  const results = this.results?.results;
86
87
  return this.raw.answers.map((ans, idx) => {
88
+ assertTypeIs("Poll.answers", ans, "pollAnswer");
87
89
  if (results) {
88
90
  return new PollAnswer(ans, results[idx]);
89
91
  }
@@ -170,7 +172,8 @@ class Poll {
170
172
  question: this.raw.question,
171
173
  answers: this.raw.answers,
172
174
  closePeriod: this.raw.closePeriod,
173
- closeDate: this.raw.closeDate
175
+ closeDate: this.raw.closeDate,
176
+ hash: Long.ZERO
174
177
  }
175
178
  };
176
179
  }
@@ -200,6 +200,10 @@ class Dialog {
200
200
  get unreadReactionsCount() {
201
201
  return this.raw.unreadReactionsCount;
202
202
  }
203
+ /** Number of unread poll votes */
204
+ get unreadPollVotesCount() {
205
+ return this.raw.unreadPollVotesCount;
206
+ }
203
207
  /**
204
208
  * Draft message in this dialog
205
209
  */
@@ -99,6 +99,8 @@ export declare class Dialog {
99
99
  * Number of unread reactions
100
100
  */
101
101
  get unreadReactionsCount(): number;
102
+ /** Number of unread poll votes */
103
+ get unreadPollVotesCount(): number;
102
104
  /**
103
105
  * Draft message in this dialog
104
106
  */
@@ -99,6 +99,8 @@ export declare class Dialog {
99
99
  * Number of unread reactions
100
100
  */
101
101
  get unreadReactionsCount(): number;
102
+ /** Number of unread poll votes */
103
+ get unreadPollVotesCount(): number;
102
104
  /**
103
105
  * Draft message in this dialog
104
106
  */
@@ -193,6 +193,10 @@ class Dialog {
193
193
  get unreadReactionsCount() {
194
194
  return this.raw.unreadReactionsCount;
195
195
  }
196
+ /** Number of unread poll votes */
197
+ get unreadPollVotesCount() {
198
+ return this.raw.unreadPollVotesCount;
199
+ }
196
200
  /**
197
201
  * Draft message in this dialog
198
202
  */
@@ -7,6 +7,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const Long = require("long");
9
9
  const peerUtils = require("../../../utils/peer-utils.cjs");
10
+ const typeAssertions = require("../../../utils/type-assertions.cjs");
10
11
  const photo = require("../media/photo.cjs");
11
12
  const peer = require("../peers/peer.cjs");
12
13
  const user = require("../peers/user.cjs");
@@ -453,6 +454,23 @@ function _messageActionFromTl(act) {
453
454
  prevValue: act.prevValue,
454
455
  newValue: act.newValue
455
456
  };
457
+ case "messageActionPollAppendAnswer":
458
+ typeAssertions.assertTypeIsNot("messageActionPollAppendAnswer", act.answer, "inputPollAnswer");
459
+ return {
460
+ type: "poll_append_answer",
461
+ answer: act.answer
462
+ };
463
+ case "messageActionPollDeleteAnswer":
464
+ typeAssertions.assertTypeIsNot("messageActionPollAppendAnswer", act.answer, "inputPollAnswer");
465
+ return {
466
+ type: "poll_delete_answer",
467
+ answer: act.answer
468
+ };
469
+ case "messageActionManagedBotCreated":
470
+ return {
471
+ type: "managed_bot_created",
472
+ botId: act.botId
473
+ };
456
474
  default:
457
475
  return null;
458
476
  }
@@ -591,6 +591,24 @@ export interface ActionNoForwardsRequest {
591
591
  /** New value */
592
592
  newValue: boolean;
593
593
  }
594
+ /** An answer was appended to a poll */
595
+ export interface ActionPollAppendAnswer {
596
+ readonly type: 'poll_append_answer';
597
+ /** The answer that was appended */
598
+ readonly answer: tl.RawPollAnswer;
599
+ }
600
+ /** An answer was deleted from a poll */
601
+ export interface ActionPollDeleteAnswer {
602
+ readonly type: 'poll_delete_answer';
603
+ /** The answer that was deleted */
604
+ readonly answer: tl.RawPollAnswer;
605
+ }
606
+ /** A managed bot was created */
607
+ export interface ActionManagedBotCreated {
608
+ readonly type: 'managed_bot_created';
609
+ /** ID of the created bot */
610
+ readonly botId: number;
611
+ }
594
612
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
595
613
  export interface ActionNewCreatorPending {
596
614
  readonly type: 'new_creator_pending';
@@ -603,7 +621,7 @@ export interface ActionChangeCreator {
603
621
  /** New creator */
604
622
  newCreator: User;
605
623
  }
606
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | null;
624
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | null;
607
625
  /** @internal */
608
626
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
609
627
  export {};
@@ -591,6 +591,24 @@ export interface ActionNoForwardsRequest {
591
591
  /** New value */
592
592
  newValue: boolean;
593
593
  }
594
+ /** An answer was appended to a poll */
595
+ export interface ActionPollAppendAnswer {
596
+ readonly type: 'poll_append_answer';
597
+ /** The answer that was appended */
598
+ readonly answer: tl.RawPollAnswer;
599
+ }
600
+ /** An answer was deleted from a poll */
601
+ export interface ActionPollDeleteAnswer {
602
+ readonly type: 'poll_delete_answer';
603
+ /** The answer that was deleted */
604
+ readonly answer: tl.RawPollAnswer;
605
+ }
606
+ /** A managed bot was created */
607
+ export interface ActionManagedBotCreated {
608
+ readonly type: 'managed_bot_created';
609
+ /** ID of the created bot */
610
+ readonly botId: number;
611
+ }
594
612
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
595
613
  export interface ActionNewCreatorPending {
596
614
  readonly type: 'new_creator_pending';
@@ -603,7 +621,7 @@ export interface ActionChangeCreator {
603
621
  /** New creator */
604
622
  newCreator: User;
605
623
  }
606
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | null;
624
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | null;
607
625
  /** @internal */
608
626
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
609
627
  export {};
@@ -1,5 +1,6 @@
1
1
  import Long from "long";
2
2
  import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
+ import { assertTypeIsNot } from "../../../utils/type-assertions.js";
3
4
  import { Photo as Photo$2 } from "../media/photo.js";
4
5
  import { parsePeer } from "../peers/peer.js";
5
6
  import { User as User$2 } from "../peers/user.js";
@@ -446,6 +447,23 @@ function _messageActionFromTl(act) {
446
447
  prevValue: act.prevValue,
447
448
  newValue: act.newValue
448
449
  };
450
+ case "messageActionPollAppendAnswer":
451
+ assertTypeIsNot("messageActionPollAppendAnswer", act.answer, "inputPollAnswer");
452
+ return {
453
+ type: "poll_append_answer",
454
+ answer: act.answer
455
+ };
456
+ case "messageActionPollDeleteAnswer":
457
+ assertTypeIsNot("messageActionPollAppendAnswer", act.answer, "inputPollAnswer");
458
+ return {
459
+ type: "poll_delete_answer",
460
+ answer: act.answer
461
+ };
462
+ case "messageActionManagedBotCreated":
463
+ return {
464
+ type: "managed_bot_created",
465
+ botId: act.botId
466
+ };
449
467
  default:
450
468
  return null;
451
469
  }
@@ -157,6 +157,10 @@ class ForumTopic {
157
157
  get unreadReactionsCount() {
158
158
  return this.raw.unreadReactionsCount;
159
159
  }
160
+ /** Number of unread poll votes in the topic */
161
+ get unreadPollVotesCount() {
162
+ return this.raw.unreadPollVotesCount;
163
+ }
160
164
  /**
161
165
  * Draft message in the topic
162
166
  */
@@ -94,6 +94,8 @@ export declare class ForumTopic {
94
94
  * Number of unread reactions in the topic
95
95
  */
96
96
  get unreadReactionsCount(): number;
97
+ /** Number of unread poll votes in the topic */
98
+ get unreadPollVotesCount(): number;
97
99
  /**
98
100
  * Draft message in the topic
99
101
  */
@@ -94,6 +94,8 @@ export declare class ForumTopic {
94
94
  * Number of unread reactions in the topic
95
95
  */
96
96
  get unreadReactionsCount(): number;
97
+ /** Number of unread poll votes in the topic */
98
+ get unreadPollVotesCount(): number;
97
99
  /**
98
100
  * Draft message in the topic
99
101
  */
@@ -150,6 +150,10 @@ class ForumTopic {
150
150
  get unreadReactionsCount() {
151
151
  return this.raw.unreadReactionsCount;
152
152
  }
153
+ /** Number of unread poll votes in the topic */
154
+ get unreadPollVotesCount() {
155
+ return this.raw.unreadPollVotesCount;
156
+ }
153
157
  /**
154
158
  * Draft message in the topic
155
159
  */