@mtcute/core 0.19.7 → 0.19.10

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 (35) hide show
  1. package/client.cjs +4 -0
  2. package/client.js +4 -0
  3. package/highlevel/base.cjs +2 -2
  4. package/highlevel/base.js +2 -2
  5. package/highlevel/client.d.cts +5 -1
  6. package/highlevel/client.d.ts +5 -1
  7. package/highlevel/methods/premium/get-unique-star-gift.cjs +20 -0
  8. package/highlevel/methods/premium/get-unique-star-gift.d.cts +6 -0
  9. package/highlevel/methods/premium/get-unique-star-gift.d.ts +6 -0
  10. package/highlevel/methods/premium/get-unique-star-gift.js +15 -0
  11. package/highlevel/methods.d.cts +1 -0
  12. package/highlevel/methods.d.ts +1 -0
  13. package/highlevel/types/premium/stars-gift-unique.cjs +10 -1
  14. package/highlevel/types/premium/stars-gift-unique.d.cts +6 -2
  15. package/highlevel/types/premium/stars-gift-unique.d.ts +6 -2
  16. package/highlevel/types/premium/stars-gift-unique.js +10 -1
  17. package/highlevel/types/stories/interactive/index.cjs +4 -0
  18. package/highlevel/types/stories/interactive/index.d.cts +3 -2
  19. package/highlevel/types/stories/interactive/index.d.ts +3 -2
  20. package/highlevel/types/stories/interactive/index.js +4 -0
  21. package/highlevel/types/stories/interactive/star-gift.cjs +22 -0
  22. package/highlevel/types/stories/interactive/star-gift.d.cts +12 -0
  23. package/highlevel/types/stories/interactive/star-gift.d.ts +12 -0
  24. package/highlevel/types/stories/interactive/star-gift.js +17 -0
  25. package/highlevel/updates/manager.cjs +11 -9
  26. package/highlevel/updates/manager.d.cts +1 -3
  27. package/highlevel/updates/manager.d.ts +1 -3
  28. package/highlevel/updates/manager.js +11 -9
  29. package/index.cjs +2 -0
  30. package/index.js +2 -0
  31. package/methods.cjs +2 -0
  32. package/methods.js +2 -0
  33. package/network/network-manager.cjs +1 -1
  34. package/network/network-manager.js +1 -1
  35. package/package.json +2 -2
package/client.cjs CHANGED
@@ -199,6 +199,7 @@ const getMyBoostSlots = require("./highlevel/methods/premium/get-my-boost-slots.
199
199
  const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
200
200
  const getStarGifts = require("./highlevel/methods/premium/get-star-gifts.cjs");
201
201
  const getStarsTransactions = require("./highlevel/methods/premium/get-stars-transactions.cjs");
202
+ const getUniqueStarGift = require("./highlevel/methods/premium/get-unique-star-gift.cjs");
202
203
  const iterBoosters = require("./highlevel/methods/premium/iter-boosters.cjs");
203
204
  const iterStarGifts = require("./highlevel/methods/premium/iter-star-gifts.cjs");
204
205
  const iterStarsTransactions = require("./highlevel/methods/premium/iter-stars-transactions.cjs");
@@ -1054,6 +1055,9 @@ TelegramClient.prototype.getStarGifts = function(...args) {
1054
1055
  TelegramClient.prototype.getStarsTransactions = function(...args) {
1055
1056
  return getStarsTransactions.getStarsTransactions(this._client, ...args);
1056
1057
  };
1058
+ TelegramClient.prototype.getUniqueStarGift = function(...args) {
1059
+ return getUniqueStarGift.getUniqueStarGift(this._client, ...args);
1060
+ };
1057
1061
  TelegramClient.prototype.iterBoosters = function(...args) {
1058
1062
  return iterBoosters.iterBoosters(this._client, ...args);
1059
1063
  };
package/client.js CHANGED
@@ -192,6 +192,7 @@ import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.
192
192
  import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
193
193
  import { getStarGifts } from "./highlevel/methods/premium/get-star-gifts.js";
194
194
  import { getStarsTransactions } from "./highlevel/methods/premium/get-stars-transactions.js";
195
+ import { getUniqueStarGift } from "./highlevel/methods/premium/get-unique-star-gift.js";
195
196
  import { iterBoosters } from "./highlevel/methods/premium/iter-boosters.js";
196
197
  import { iterStarGifts } from "./highlevel/methods/premium/iter-star-gifts.js";
197
198
  import { iterStarsTransactions } from "./highlevel/methods/premium/iter-stars-transactions.js";
@@ -1047,6 +1048,9 @@ TelegramClient.prototype.getStarGifts = function(...args) {
1047
1048
  TelegramClient.prototype.getStarsTransactions = function(...args) {
1048
1049
  return getStarsTransactions(this._client, ...args);
1049
1050
  };
1051
+ TelegramClient.prototype.getUniqueStarGift = function(...args) {
1052
+ return getUniqueStarGift(this._client, ...args);
1053
+ };
1050
1054
  TelegramClient.prototype.iterBoosters = function(...args) {
1051
1055
  return iterBoosters(this._client, ...args);
1052
1056
  };
@@ -125,8 +125,8 @@ class BaseTelegramClient {
125
125
  async notifyLoggedIn(auth) {
126
126
  const user = this.mt.network.notifyLoggedIn(auth);
127
127
  this.log.prefix = `[USER ${user.id}] `;
128
- const self = await this.storage.self.storeFrom(user);
129
- this.updates?.notifyLoggedIn(self);
128
+ await this.storage.self.storeFrom(user);
129
+ this.updates?.notifyLoggedIn();
130
130
  return user;
131
131
  }
132
132
  async notifyLoggedOut() {
package/highlevel/base.js CHANGED
@@ -118,8 +118,8 @@ class BaseTelegramClient {
118
118
  async notifyLoggedIn(auth) {
119
119
  const user = this.mt.network.notifyLoggedIn(auth);
120
120
  this.log.prefix = `[USER ${user.id}] `;
121
- const self = await this.storage.self.storeFrom(user);
122
- this.updates?.notifyLoggedIn(self);
121
+ await this.storage.self.storeFrom(user);
122
+ this.updates?.notifyLoggedIn();
123
123
  return user;
124
124
  }
125
125
  async notifyLoggedOut() {
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
24
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
25
  import { ITelegramStorageProvider } from './storage/provider.js';
26
- import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarGift, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
26
+ import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
27
27
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
28
  import { RawUpdateInfo } from './updates/types.js';
29
29
  import { InputStringSessionData } from './utils/string-session.js';
@@ -3998,6 +3998,10 @@ export interface TelegramClient extends ITelegramClient {
3998
3998
  */
3999
3999
  limit?: number;
4000
4000
  }): Promise<StarsStatus>;
4001
+ /**
4002
+ * Get information about a unique star gift by its slug
4003
+ */
4004
+ getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
4001
4005
  /**
4002
4006
  * Iterate over boosters of a channel.
4003
4007
  *
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
24
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
25
  import { ITelegramStorageProvider } from './storage/provider.js';
26
- import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarGift, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
26
+ import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
27
27
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
28
  import { RawUpdateInfo } from './updates/types.js';
29
29
  import { InputStringSessionData } from './utils/string-session.js';
@@ -3998,6 +3998,10 @@ export interface TelegramClient extends ITelegramClient {
3998
3998
  */
3999
3999
  limit?: number;
4000
4000
  }): Promise<StarsStatus>;
4001
+ /**
4002
+ * Get information about a unique star gift by its slug
4003
+ */
4004
+ getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
4001
4005
  /**
4002
4006
  * Iterate over boosters of a channel.
4003
4007
  *
@@ -0,0 +1,20 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const utils = require("@fuman/utils");
9
+ const starsGiftUnique = require("../../types/premium/stars-gift-unique.cjs");
10
+ const peersIndex = require("../../types/peers/peers-index.cjs");
11
+ async function getUniqueStarGift(client, slug) {
12
+ const res = await client.call({
13
+ _: "payments.getUniqueStarGift",
14
+ slug
15
+ });
16
+ const peers = peersIndex.PeersIndex.from(res);
17
+ utils.assert(res.gift._ === "starGiftUnique");
18
+ return new starsGiftUnique.StarGiftUnique(res.gift, peers);
19
+ }
20
+ exports.getUniqueStarGift = getUniqueStarGift;
@@ -0,0 +1,6 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { StarGiftUnique } from '../../types/index.js';
3
+ /**
4
+ * Get information about a unique star gift by its slug
5
+ */
6
+ export declare function getUniqueStarGift(client: ITelegramClient, slug: string): Promise<StarGiftUnique>;
@@ -0,0 +1,6 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { StarGiftUnique } from '../../types/index.js';
3
+ /**
4
+ * Get information about a unique star gift by its slug
5
+ */
6
+ export declare function getUniqueStarGift(client: ITelegramClient, slug: string): Promise<StarGiftUnique>;
@@ -0,0 +1,15 @@
1
+ import { assert } from "@fuman/utils";
2
+ import { StarGiftUnique as StarGiftUnique$2 } from "../../types/premium/stars-gift-unique.js";
3
+ import { PeersIndex } from "../../types/peers/peers-index.js";
4
+ async function getUniqueStarGift(client, slug) {
5
+ const res = await client.call({
6
+ _: "payments.getUniqueStarGift",
7
+ slug
8
+ });
9
+ const peers = PeersIndex.from(res);
10
+ assert(res.gift._ === "starGiftUnique");
11
+ return new StarGiftUnique$2(res.gift, peers);
12
+ }
13
+ export {
14
+ getUniqueStarGift
15
+ };
@@ -223,6 +223,7 @@ export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
223
223
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
224
224
  export { getStarGifts } from './methods/premium/get-star-gifts.js';
225
225
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
226
+ export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
226
227
  export { iterBoosters } from './methods/premium/iter-boosters.js';
227
228
  export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
228
229
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
@@ -223,6 +223,7 @@ export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
223
223
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
224
224
  export { getStarGifts } from './methods/premium/get-star-gifts.js';
225
225
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
226
+ export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
226
227
  export { iterBoosters } from './methods/premium/iter-boosters.js';
227
228
  export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
228
229
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
@@ -112,10 +112,19 @@ class StarGiftUnique {
112
112
  get title() {
113
113
  return this.raw.title;
114
114
  }
115
- /** ID of the user who owns this gift */
115
+ /** Slug of the gift */
116
+ get slug() {
117
+ return this.raw.slug;
118
+ }
119
+ /** ID of the user who owns this gift, if available */
116
120
  get owner() {
121
+ if (!this.raw.ownerId) return null;
117
122
  return new user.User(this._peers.user(this.raw.ownerId));
118
123
  }
124
+ /** Name of the user who owns this gift, if available */
125
+ get ownerName() {
126
+ return this.raw.ownerName ?? null;
127
+ }
119
128
  get availabilityIssued() {
120
129
  return this.raw.availabilityIssued;
121
130
  }
@@ -55,8 +55,12 @@ export declare class StarGiftUnique {
55
55
  get num(): number;
56
56
  /** Title of the NFT */
57
57
  get title(): string;
58
- /** ID of the user who owns this gift */
59
- get owner(): User;
58
+ /** Slug of the gift */
59
+ get slug(): string;
60
+ /** ID of the user who owns this gift, if available */
61
+ get owner(): User | null;
62
+ /** Name of the user who owns this gift, if available */
63
+ get ownerName(): string | null;
60
64
  get availabilityIssued(): number;
61
65
  get availabilityTotal(): number;
62
66
  /** Model (i.e. the gift itself) of the unique star gift */
@@ -55,8 +55,12 @@ export declare class StarGiftUnique {
55
55
  get num(): number;
56
56
  /** Title of the NFT */
57
57
  get title(): string;
58
- /** ID of the user who owns this gift */
59
- get owner(): User;
58
+ /** Slug of the gift */
59
+ get slug(): string;
60
+ /** ID of the user who owns this gift, if available */
61
+ get owner(): User | null;
62
+ /** Name of the user who owns this gift, if available */
63
+ get ownerName(): string | null;
60
64
  get availabilityIssued(): number;
61
65
  get availabilityTotal(): number;
62
66
  /** Model (i.e. the gift itself) of the unique star gift */
@@ -105,10 +105,19 @@ class StarGiftUnique {
105
105
  get title() {
106
106
  return this.raw.title;
107
107
  }
108
- /** ID of the user who owns this gift */
108
+ /** Slug of the gift */
109
+ get slug() {
110
+ return this.raw.slug;
111
+ }
112
+ /** ID of the user who owns this gift, if available */
109
113
  get owner() {
114
+ if (!this.raw.ownerId) return null;
110
115
  return new User$2(this._peers.user(this.raw.ownerId));
111
116
  }
117
+ /** Name of the user who owns this gift, if available */
118
+ get ownerName() {
119
+ return this.raw.ownerName ?? null;
120
+ }
112
121
  get availabilityIssued() {
113
122
  return this.raw.availabilityIssued;
114
123
  }
@@ -9,6 +9,7 @@ const errors = require("../../../../types/errors.cjs");
9
9
  const channelPost = require("./channel-post.cjs");
10
10
  const location = require("./location.cjs");
11
11
  const reaction = require("./reaction.cjs");
12
+ const starGift = require("./star-gift.cjs");
12
13
  const url = require("./url.cjs");
13
14
  const venue = require("./venue.cjs");
14
15
  const weather = require("./weather.cjs");
@@ -26,6 +27,8 @@ function _storyInteractiveElementFromTl(raw, peers) {
26
27
  return new url.StoryInteractiveUrl(raw);
27
28
  case "mediaAreaWeather":
28
29
  return new weather.StoryInteractiveWeather(raw);
30
+ case "mediaAreaStarGift":
31
+ return new starGift.StoryInteractiveStarGift(raw);
29
32
  case "inputMediaAreaVenue":
30
33
  case "inputMediaAreaChannelPost":
31
34
  throw new errors.MtTypeAssertionError("StoryInteractiveElement", "!input*", raw._);
@@ -34,6 +37,7 @@ function _storyInteractiveElementFromTl(raw, peers) {
34
37
  exports.StoryInteractiveChannelPost = channelPost.StoryInteractiveChannelPost;
35
38
  exports.StoryInteractiveLocation = location.StoryInteractiveLocation;
36
39
  exports.StoryInteractiveReaction = reaction.StoryInteractiveReaction;
40
+ exports.StoryInteractiveStarGift = starGift.StoryInteractiveStarGift;
37
41
  exports.StoryInteractiveUrl = url.StoryInteractiveUrl;
38
42
  exports.StoryInteractiveVenue = venue.StoryInteractiveVenue;
39
43
  exports.StoryInteractiveWeather = weather.StoryInteractiveWeather;
@@ -3,10 +3,11 @@ import { PeersIndex } from '../../peers/index.js';
3
3
  import { StoryInteractiveChannelPost } from './channel-post.js';
4
4
  import { StoryInteractiveLocation } from './location.js';
5
5
  import { StoryInteractiveReaction } from './reaction.js';
6
+ import { StoryInteractiveStarGift } from './star-gift.js';
6
7
  import { StoryInteractiveUrl } from './url.js';
7
8
  import { StoryInteractiveVenue } from './venue.js';
8
9
  import { StoryInteractiveWeather } from './weather.js';
9
10
  export * from './input.js';
10
- export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
11
- export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl | StoryInteractiveWeather;
11
+ export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveStarGift, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
12
+ export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl | StoryInteractiveWeather | StoryInteractiveStarGift;
12
13
  export declare function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement;
@@ -3,10 +3,11 @@ import { PeersIndex } from '../../peers/index.js';
3
3
  import { StoryInteractiveChannelPost } from './channel-post.js';
4
4
  import { StoryInteractiveLocation } from './location.js';
5
5
  import { StoryInteractiveReaction } from './reaction.js';
6
+ import { StoryInteractiveStarGift } from './star-gift.js';
6
7
  import { StoryInteractiveUrl } from './url.js';
7
8
  import { StoryInteractiveVenue } from './venue.js';
8
9
  import { StoryInteractiveWeather } from './weather.js';
9
10
  export * from './input.js';
10
- export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
11
- export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl | StoryInteractiveWeather;
11
+ export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveStarGift, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
12
+ export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl | StoryInteractiveWeather | StoryInteractiveStarGift;
12
13
  export declare function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement;
@@ -2,6 +2,7 @@ import { MtTypeAssertionError } from "../../../../types/errors.js";
2
2
  import { StoryInteractiveChannelPost as StoryInteractiveChannelPost$2 } from "./channel-post.js";
3
3
  import { StoryInteractiveLocation as StoryInteractiveLocation$2 } from "./location.js";
4
4
  import { StoryInteractiveReaction as StoryInteractiveReaction$1 } from "./reaction.js";
5
+ import { StoryInteractiveStarGift as StoryInteractiveStarGift$1 } from "./star-gift.js";
5
6
  import { StoryInteractiveUrl } from "./url.js";
6
7
  import { StoryInteractiveVenue as StoryInteractiveVenue$2 } from "./venue.js";
7
8
  import { StoryInteractiveWeather as StoryInteractiveWeather$1 } from "./weather.js";
@@ -19,6 +20,8 @@ function _storyInteractiveElementFromTl(raw, peers) {
19
20
  return new StoryInteractiveUrl(raw);
20
21
  case "mediaAreaWeather":
21
22
  return new StoryInteractiveWeather$1(raw);
23
+ case "mediaAreaStarGift":
24
+ return new StoryInteractiveStarGift$1(raw);
22
25
  case "inputMediaAreaVenue":
23
26
  case "inputMediaAreaChannelPost":
24
27
  throw new MtTypeAssertionError("StoryInteractiveElement", "!input*", raw._);
@@ -28,6 +31,7 @@ export {
28
31
  StoryInteractiveChannelPost$2 as StoryInteractiveChannelPost,
29
32
  StoryInteractiveLocation$2 as StoryInteractiveLocation,
30
33
  StoryInteractiveReaction$1 as StoryInteractiveReaction,
34
+ StoryInteractiveStarGift$1 as StoryInteractiveStarGift,
31
35
  StoryInteractiveUrl,
32
36
  StoryInteractiveVenue$2 as StoryInteractiveVenue,
33
37
  StoryInteractiveWeather$1 as StoryInteractiveWeather,
@@ -0,0 +1,22 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const base = require("./base.cjs");
9
+ const inspectable = require("../../../utils/inspectable.cjs");
10
+ class StoryInteractiveStarGift extends base.StoryInteractiveArea {
11
+ constructor(raw) {
12
+ super(raw);
13
+ this.raw = raw;
14
+ }
15
+ type = "star_gift";
16
+ /** Star gift slug */
17
+ get slug() {
18
+ return this.raw.slug;
19
+ }
20
+ }
21
+ const StoryInteractiveStarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(StoryInteractiveStarGift);
22
+ exports.StoryInteractiveStarGift = StoryInteractiveStarGift$1;
@@ -0,0 +1,12 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a star gift
5
+ */
6
+ export declare class StoryInteractiveStarGift extends StoryInteractiveArea {
7
+ readonly raw: tl.RawMediaAreaStarGift;
8
+ readonly type: "star_gift";
9
+ constructor(raw: tl.RawMediaAreaStarGift);
10
+ /** Star gift slug */
11
+ get slug(): string;
12
+ }
@@ -0,0 +1,12 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a star gift
5
+ */
6
+ export declare class StoryInteractiveStarGift extends StoryInteractiveArea {
7
+ readonly raw: tl.RawMediaAreaStarGift;
8
+ readonly type: "star_gift";
9
+ constructor(raw: tl.RawMediaAreaStarGift);
10
+ /** Star gift slug */
11
+ get slug(): string;
12
+ }
@@ -0,0 +1,17 @@
1
+ import { StoryInteractiveArea } from "./base.js";
2
+ import { makeInspectable } from "../../../utils/inspectable.js";
3
+ class StoryInteractiveStarGift extends StoryInteractiveArea {
4
+ constructor(raw) {
5
+ super(raw);
6
+ this.raw = raw;
7
+ }
8
+ type = "star_gift";
9
+ /** Star gift slug */
10
+ get slug() {
11
+ return this.raw.slug;
12
+ }
13
+ }
14
+ const StoryInteractiveStarGift$1 = /* @__PURE__ */ makeInspectable(StoryInteractiveStarGift);
15
+ export {
16
+ StoryInteractiveStarGift$1 as StoryInteractiveStarGift
17
+ };
@@ -44,7 +44,7 @@ class UpdatesManager {
44
44
  this._channelPtsLimit = () => limit;
45
45
  }
46
46
  } else {
47
- this._channelPtsLimit = () => this.auth?.isBot ? 1e5 : 100;
47
+ this._channelPtsLimit = () => this.client.storage.self.getCached()?.isBot ? 1e5 : 100;
48
48
  }
49
49
  }
50
50
  updatesLoopActive = false;
@@ -91,8 +91,6 @@ class UpdatesManager {
91
91
  };
92
92
  // eslint-disable-next-line ts/no-unsafe-function-type
93
93
  _channelPtsLimit;
94
- auth;
95
- // todo: do we need a local copy?
96
94
  keepAliveInterval;
97
95
  onCatchingUp(handler) {
98
96
  this._onCatchingUp = handler;
@@ -100,8 +98,7 @@ class UpdatesManager {
100
98
  destroy() {
101
99
  this.stopLoop();
102
100
  }
103
- notifyLoggedIn(self) {
104
- this.auth = self;
101
+ notifyLoggedIn() {
105
102
  this.startLoop().catch((err) => this.client.onError.emit(utils.unknownToError(err)));
106
103
  }
107
104
  notifyLoggedOut() {
@@ -915,7 +912,7 @@ class UpdatesManager {
915
912
  case "updateUserName":
916
913
  break;
917
914
  case "updateDeleteChannelMessages":
918
- if (!this.auth?.isBot) {
915
+ if (!client.storage.self.getCached()?.isBot) {
919
916
  await client.storage.refMsgs.delete(peerUtils.toggleChannelIdMark(upd.channelId), upd.messages);
920
917
  }
921
918
  break;
@@ -923,13 +920,13 @@ class UpdatesManager {
923
920
  case "updateEditMessage":
924
921
  case "updateNewChannelMessage":
925
922
  case "updateEditChannelMessage":
926
- if (!this.auth?.isBot) {
923
+ if (!client.storage.self.getCached()?.isBot) {
927
924
  await this._storeMessageReferences(upd.message);
928
925
  }
929
926
  break;
930
927
  }
931
928
  if (missing?.size) {
932
- if (this.auth?.isBot) {
929
+ if (client.storage.self.getCached()?.isBot) {
933
930
  this.log.warn(
934
931
  "missing peers (%J) after getDifference for %s (pts = %d, cid = %d)",
935
932
  missing,
@@ -1098,6 +1095,11 @@ class UpdatesManager {
1098
1095
  }
1099
1096
  case "updateShortMessage": {
1100
1097
  log.debug("received updateShortMessage");
1098
+ const self = client.storage.self.getCached();
1099
+ if (!self) {
1100
+ log.warn("received updateShortMessage without auth");
1101
+ break;
1102
+ }
1101
1103
  const message = {
1102
1104
  _: "message",
1103
1105
  out: upd.out,
@@ -1107,7 +1109,7 @@ class UpdatesManager {
1107
1109
  id: upd.id,
1108
1110
  fromId: {
1109
1111
  _: "peerUser",
1110
- userId: upd.out ? this.auth.userId : upd.userId
1112
+ userId: upd.out ? self.userId : upd.userId
1111
1113
  },
1112
1114
  peerId: {
1113
1115
  _: "peerUser",
@@ -1,6 +1,5 @@
1
1
  import { Logger, EarlyTimer, SortedLinkedList } from '../../utils/index.js';
2
2
  import { BaseTelegramClient } from '../base.js';
3
- import { CurrentUserInfo } from '../storage/service/current-user.js';
4
3
  import { AsyncLock, ConditionVariable, Deque, timers } from '@fuman/utils';
5
4
  import { tl } from '@mtcute/tl';
6
5
  import { PeersIndex } from '../types/peers/peers-index.js';
@@ -40,12 +39,11 @@ export declare class UpdatesManager {
40
39
  log: Logger;
41
40
  private _onCatchingUp;
42
41
  private _channelPtsLimit;
43
- auth?: CurrentUserInfo | null;
44
42
  keepAliveInterval?: timers.Interval;
45
43
  constructor(client: BaseTelegramClient, params?: UpdatesManagerParams);
46
44
  onCatchingUp(handler: (catchingUp: boolean) => void): void;
47
45
  destroy(): void;
48
- notifyLoggedIn(self: CurrentUserInfo): void;
46
+ notifyLoggedIn(): void;
49
47
  notifyLoggedOut(): void;
50
48
  prepare(): Promise<void>;
51
49
  private _onKeepAlive;
@@ -1,6 +1,5 @@
1
1
  import { Logger, EarlyTimer, SortedLinkedList } from '../../utils/index.js';
2
2
  import { BaseTelegramClient } from '../base.js';
3
- import { CurrentUserInfo } from '../storage/service/current-user.js';
4
3
  import { AsyncLock, ConditionVariable, Deque, timers } from '@fuman/utils';
5
4
  import { tl } from '@mtcute/tl';
6
5
  import { PeersIndex } from '../types/peers/peers-index.js';
@@ -40,12 +39,11 @@ export declare class UpdatesManager {
40
39
  log: Logger;
41
40
  private _onCatchingUp;
42
41
  private _channelPtsLimit;
43
- auth?: CurrentUserInfo | null;
44
42
  keepAliveInterval?: timers.Interval;
45
43
  constructor(client: BaseTelegramClient, params?: UpdatesManagerParams);
46
44
  onCatchingUp(handler: (catchingUp: boolean) => void): void;
47
45
  destroy(): void;
48
- notifyLoggedIn(self: CurrentUserInfo): void;
46
+ notifyLoggedIn(): void;
49
47
  notifyLoggedOut(): void;
50
48
  prepare(): Promise<void>;
51
49
  private _onKeepAlive;
@@ -37,7 +37,7 @@ class UpdatesManager {
37
37
  this._channelPtsLimit = () => limit;
38
38
  }
39
39
  } else {
40
- this._channelPtsLimit = () => this.auth?.isBot ? 1e5 : 100;
40
+ this._channelPtsLimit = () => this.client.storage.self.getCached()?.isBot ? 1e5 : 100;
41
41
  }
42
42
  }
43
43
  updatesLoopActive = false;
@@ -84,8 +84,6 @@ class UpdatesManager {
84
84
  };
85
85
  // eslint-disable-next-line ts/no-unsafe-function-type
86
86
  _channelPtsLimit;
87
- auth;
88
- // todo: do we need a local copy?
89
87
  keepAliveInterval;
90
88
  onCatchingUp(handler) {
91
89
  this._onCatchingUp = handler;
@@ -93,8 +91,7 @@ class UpdatesManager {
93
91
  destroy() {
94
92
  this.stopLoop();
95
93
  }
96
- notifyLoggedIn(self) {
97
- this.auth = self;
94
+ notifyLoggedIn() {
98
95
  this.startLoop().catch((err) => this.client.onError.emit(unknownToError(err)));
99
96
  }
100
97
  notifyLoggedOut() {
@@ -908,7 +905,7 @@ class UpdatesManager {
908
905
  case "updateUserName":
909
906
  break;
910
907
  case "updateDeleteChannelMessages":
911
- if (!this.auth?.isBot) {
908
+ if (!client.storage.self.getCached()?.isBot) {
912
909
  await client.storage.refMsgs.delete(toggleChannelIdMark(upd.channelId), upd.messages);
913
910
  }
914
911
  break;
@@ -916,13 +913,13 @@ class UpdatesManager {
916
913
  case "updateEditMessage":
917
914
  case "updateNewChannelMessage":
918
915
  case "updateEditChannelMessage":
919
- if (!this.auth?.isBot) {
916
+ if (!client.storage.self.getCached()?.isBot) {
920
917
  await this._storeMessageReferences(upd.message);
921
918
  }
922
919
  break;
923
920
  }
924
921
  if (missing?.size) {
925
- if (this.auth?.isBot) {
922
+ if (client.storage.self.getCached()?.isBot) {
926
923
  this.log.warn(
927
924
  "missing peers (%J) after getDifference for %s (pts = %d, cid = %d)",
928
925
  missing,
@@ -1091,6 +1088,11 @@ class UpdatesManager {
1091
1088
  }
1092
1089
  case "updateShortMessage": {
1093
1090
  log.debug("received updateShortMessage");
1091
+ const self = client.storage.self.getCached();
1092
+ if (!self) {
1093
+ log.warn("received updateShortMessage without auth");
1094
+ break;
1095
+ }
1094
1096
  const message = {
1095
1097
  _: "message",
1096
1098
  out: upd.out,
@@ -1100,7 +1102,7 @@ class UpdatesManager {
1100
1102
  id: upd.id,
1101
1103
  fromId: {
1102
1104
  _: "peerUser",
1103
- userId: upd.out ? this.auth.userId : upd.userId
1105
+ userId: upd.out ? self.userId : upd.userId
1104
1106
  },
1105
1107
  peerId: {
1106
1108
  _: "peerUser",
package/index.cjs CHANGED
@@ -102,6 +102,7 @@ const input = require("./highlevel/types/stories/interactive/input.cjs");
102
102
  const channelPost = require("./highlevel/types/stories/interactive/channel-post.cjs");
103
103
  const location$1 = require("./highlevel/types/stories/interactive/location.cjs");
104
104
  const reaction = require("./highlevel/types/stories/interactive/reaction.cjs");
105
+ const starGift = require("./highlevel/types/stories/interactive/star-gift.cjs");
105
106
  const url = require("./highlevel/types/stories/interactive/url.cjs");
106
107
  const venue$1 = require("./highlevel/types/stories/interactive/venue.cjs");
107
108
  const weather = require("./highlevel/types/stories/interactive/weather.cjs");
@@ -272,6 +273,7 @@ exports.StoryElement = input.StoryElement;
272
273
  exports.StoryInteractiveChannelPost = channelPost.StoryInteractiveChannelPost;
273
274
  exports.StoryInteractiveLocation = location$1.StoryInteractiveLocation;
274
275
  exports.StoryInteractiveReaction = reaction.StoryInteractiveReaction;
276
+ exports.StoryInteractiveStarGift = starGift.StoryInteractiveStarGift;
275
277
  exports.StoryInteractiveUrl = url.StoryInteractiveUrl;
276
278
  exports.StoryInteractiveVenue = venue$1.StoryInteractiveVenue;
277
279
  exports.StoryInteractiveWeather = weather.StoryInteractiveWeather;
package/index.js CHANGED
@@ -95,6 +95,7 @@ import { StoryElement } from "./highlevel/types/stories/interactive/input.js";
95
95
  import { StoryInteractiveChannelPost } from "./highlevel/types/stories/interactive/channel-post.js";
96
96
  import { StoryInteractiveLocation } from "./highlevel/types/stories/interactive/location.js";
97
97
  import { StoryInteractiveReaction } from "./highlevel/types/stories/interactive/reaction.js";
98
+ import { StoryInteractiveStarGift } from "./highlevel/types/stories/interactive/star-gift.js";
98
99
  import { StoryInteractiveUrl } from "./highlevel/types/stories/interactive/url.js";
99
100
  import { StoryInteractiveVenue } from "./highlevel/types/stories/interactive/venue.js";
100
101
  import { StoryInteractiveWeather } from "./highlevel/types/stories/interactive/weather.js";
@@ -273,6 +274,7 @@ export {
273
274
  StoryInteractiveChannelPost,
274
275
  StoryInteractiveLocation,
275
276
  StoryInteractiveReaction,
277
+ StoryInteractiveStarGift,
276
278
  StoryInteractiveUrl,
277
279
  StoryInteractiveVenue,
278
280
  StoryInteractiveWeather,
package/methods.cjs CHANGED
@@ -196,6 +196,7 @@ const getMyBoostSlots = require("./highlevel/methods/premium/get-my-boost-slots.
196
196
  const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
197
197
  const getStarGifts = require("./highlevel/methods/premium/get-star-gifts.cjs");
198
198
  const getStarsTransactions = require("./highlevel/methods/premium/get-stars-transactions.cjs");
199
+ const getUniqueStarGift = require("./highlevel/methods/premium/get-unique-star-gift.cjs");
199
200
  const iterBoosters = require("./highlevel/methods/premium/iter-boosters.cjs");
200
201
  const iterStarGifts = require("./highlevel/methods/premium/iter-star-gifts.cjs");
201
202
  const iterStarsTransactions = require("./highlevel/methods/premium/iter-stars-transactions.cjs");
@@ -467,6 +468,7 @@ exports.getMyBoostSlots = getMyBoostSlots.getMyBoostSlots;
467
468
  exports.getStarGiftOptions = getStarGiftOptions.getStarGiftOptions;
468
469
  exports.getStarGifts = getStarGifts.getStarGifts;
469
470
  exports.getStarsTransactions = getStarsTransactions.getStarsTransactions;
471
+ exports.getUniqueStarGift = getUniqueStarGift.getUniqueStarGift;
470
472
  exports.iterBoosters = iterBoosters.iterBoosters;
471
473
  exports.iterStarGifts = iterStarGifts.iterStarGifts;
472
474
  exports.iterStarsTransactions = iterStarsTransactions.iterStarsTransactions;
package/methods.js CHANGED
@@ -189,6 +189,7 @@ import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.
189
189
  import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
190
190
  import { getStarGifts } from "./highlevel/methods/premium/get-star-gifts.js";
191
191
  import { getStarsTransactions } from "./highlevel/methods/premium/get-stars-transactions.js";
192
+ import { getUniqueStarGift } from "./highlevel/methods/premium/get-unique-star-gift.js";
192
193
  import { iterBoosters } from "./highlevel/methods/premium/iter-boosters.js";
193
194
  import { iterStarGifts } from "./highlevel/methods/premium/iter-star-gifts.js";
194
195
  import { iterStarsTransactions } from "./highlevel/methods/premium/iter-stars-transactions.js";
@@ -390,6 +391,7 @@ export {
390
391
  getStoriesInteractions,
391
392
  getStoryLink,
392
393
  getStoryViewers,
394
+ getUniqueStarGift,
393
395
  getUser,
394
396
  getUsers,
395
397
  hideAllJoinRequests,
@@ -220,7 +220,7 @@ class NetworkManager {
220
220
  _: "initConnection",
221
221
  deviceModel,
222
222
  systemVersion: "1.0",
223
- appVersion: "0.19.7",
223
+ appVersion: "0.19.10",
224
224
  systemLangCode: "en",
225
225
  langPack: "",
226
226
  // "langPacks are for official apps only"
@@ -213,7 +213,7 @@ class NetworkManager {
213
213
  _: "initConnection",
214
214
  deviceModel,
215
215
  systemVersion: "1.0",
216
- appVersion: "0.19.7",
216
+ appVersion: "0.19.10",
217
217
  systemLangCode: "en",
218
218
  langPack: "",
219
219
  // "langPacks are for official apps only"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.19.7",
4
+ "version": "0.19.10",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},
@@ -10,7 +10,7 @@
10
10
  "@fuman/net": "0.0.9",
11
11
  "@fuman/utils": "0.0.4",
12
12
  "@mtcute/file-id": "^0.19.0",
13
- "@mtcute/tl": "^196.0.0",
13
+ "@mtcute/tl": "^197.0.0",
14
14
  "@mtcute/tl-runtime": "^0.19.0",
15
15
  "@types/events": "3.0.0",
16
16
  "long": "5.2.3"