Compare commits
No commits in common. "93fe673d2e79e6be46bdf47aa5393609dd4a45da" and "8a764eb337f937aab4a473aeb133a515194ceed1" have entirely different histories.
93fe673d2e
...
8a764eb337
33 changed files with 55 additions and 694 deletions
|
@ -24,7 +24,7 @@ import type { QuoteParamsFrom } from './methods/messages/send-quote.js'
|
||||||
import type { CanApplyBoostResult } from './methods/premium/can-apply-boost.js'
|
import type { CanApplyBoostResult } from './methods/premium/can-apply-boost.js'
|
||||||
import type { CanSendStoryResult } from './methods/stories/can-send-story.js'
|
import type { CanSendStoryResult } from './methods/stories/can-send-story.js'
|
||||||
import type { ITelegramStorageProvider } from './storage/provider.js'
|
import type { ITelegramStorageProvider } from './storage/provider.js'
|
||||||
import type { 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, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, 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'
|
import type { 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'
|
||||||
import type { ParsedUpdateHandlerParams } from './updates/parsed.js'
|
import type { ParsedUpdateHandlerParams } from './updates/parsed.js'
|
||||||
import type { RawUpdateInfo } from './updates/types.js'
|
import type { RawUpdateInfo } from './updates/types.js'
|
||||||
import type { InputStringSessionData } from './utils/string-session.js'
|
import type { InputStringSessionData } from './utils/string-session.js'
|
||||||
|
@ -211,7 +211,6 @@ import { changeCloudPassword } from './methods/password/change-cloud-password.js
|
||||||
import { enableCloudPassword } from './methods/password/enable-cloud-password.js'
|
import { enableCloudPassword } from './methods/password/enable-cloud-password.js'
|
||||||
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email.js'
|
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email.js'
|
||||||
import { removeCloudPassword } from './methods/password/remove-cloud-password.js'
|
import { removeCloudPassword } from './methods/password/remove-cloud-password.js'
|
||||||
import { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js'
|
|
||||||
import { acceptStarGift } from './methods/premium/accept-star-gift.js'
|
import { acceptStarGift } from './methods/premium/accept-star-gift.js'
|
||||||
import { applyBoost } from './methods/premium/apply-boost.js'
|
import { applyBoost } from './methods/premium/apply-boost.js'
|
||||||
import { canApplyBoost } from './methods/premium/can-apply-boost.js'
|
import { canApplyBoost } from './methods/premium/can-apply-boost.js'
|
||||||
|
@ -222,15 +221,11 @@ import { getBoosts } from './methods/premium/get-boosts.js'
|
||||||
import { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js'
|
import { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js'
|
||||||
import { getBusinessConnection } from './methods/premium/get-business-connection.js'
|
import { getBusinessConnection } from './methods/premium/get-business-connection.js'
|
||||||
import { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
|
import { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
|
||||||
import { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js'
|
|
||||||
import { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js'
|
|
||||||
import { getStarGiftOptions } from './methods/premium/get-star-gift-options.js'
|
import { getStarGiftOptions } from './methods/premium/get-star-gift-options.js'
|
||||||
import { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js'
|
|
||||||
import { getStarGifts } from './methods/premium/get-star-gifts.js'
|
import { getStarGifts } from './methods/premium/get-star-gifts.js'
|
||||||
import { getStarsTransactions } from './methods/premium/get-stars-transactions.js'
|
import { getStarsTransactions } from './methods/premium/get-stars-transactions.js'
|
||||||
import { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js'
|
import { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js'
|
||||||
import { iterBoosters } from './methods/premium/iter-boosters.js'
|
import { iterBoosters } from './methods/premium/iter-boosters.js'
|
||||||
import { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js'
|
|
||||||
import { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
import { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
||||||
import { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
import { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
||||||
import { sendStarGift } from './methods/premium/send-star-gift.js'
|
import { sendStarGift } from './methods/premium/send-star-gift.js'
|
||||||
|
@ -4550,9 +4545,6 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
removeCloudPassword(password: string): Promise<void>
|
removeCloudPassword(password: string): Promise<void>
|
||||||
|
|
||||||
_normalizeInputStarGift(
|
|
||||||
gift: InputStarGift): Promise<tl.TypeInputSavedStarGift>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept, hide or convert a star gift.
|
* Accept, hide or convert a star gift.
|
||||||
*
|
*
|
||||||
|
@ -4562,9 +4554,8 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
acceptStarGift(
|
acceptStarGift(
|
||||||
params: {
|
params: {
|
||||||
/** Input star gift to accept */
|
/** ID of the message containing the gift */
|
||||||
gift: InputStarGift
|
message: number | Message
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to perform on the gift.
|
* Action to perform on the gift.
|
||||||
* - `save` - save the gift to your profile
|
* - `save` - save the gift to your profile
|
||||||
|
@ -4690,34 +4681,6 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getMyBoostSlots(): Promise<BoostSlot[]>
|
getMyBoostSlots(): Promise<BoostSlot[]>
|
||||||
/** Get one or more saved star gifts by their IDs */
|
|
||||||
getSavedStarGiftsById(
|
|
||||||
gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>
|
|
||||||
/** Get a list of saved star gifts of a user */
|
|
||||||
getSavedStarGifts(
|
|
||||||
params: {
|
|
||||||
/** Peer to get saved gifts from */
|
|
||||||
owner: InputPeerLike
|
|
||||||
|
|
||||||
/** Whether to exclude hidden gifts */
|
|
||||||
excludeHidden?: boolean
|
|
||||||
/** Whether to exclude publicly visible gifts */
|
|
||||||
excludePublic?: boolean
|
|
||||||
/** Whether to exclude gifts with unlimited availability */
|
|
||||||
excludeUnlimited?: boolean
|
|
||||||
/** Whether to exclude gifts with limited availability */
|
|
||||||
excludeLimited?: boolean
|
|
||||||
/** Whether to exclude unique gifts */
|
|
||||||
excludeUnique?: boolean
|
|
||||||
|
|
||||||
/** Whether to sort by value */
|
|
||||||
sortByValue?: boolean
|
|
||||||
|
|
||||||
/** Offset for pagination */
|
|
||||||
offset?: string
|
|
||||||
/** Limit for pagination */
|
|
||||||
limit?: number
|
|
||||||
}): Promise<ArrayPaginated<SavedStarGift, string>>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of available star gifts.
|
* Get the list of available star gifts.
|
||||||
|
@ -4726,15 +4689,6 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
getStarGiftOptions(): Promise<StarGift[]>
|
getStarGiftOptions(): Promise<StarGift[]>
|
||||||
|
|
||||||
getStarGiftWithdrawalUrl(
|
|
||||||
params: {
|
|
||||||
/** The star gift to withdraw */
|
|
||||||
gift: InputStarGift
|
|
||||||
|
|
||||||
/** 2FA password */
|
|
||||||
password: string
|
|
||||||
}): Promise<string>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of gifts sent to a user.
|
* Get a list of gifts sent to a user.
|
||||||
*
|
*
|
||||||
|
@ -4823,34 +4777,6 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
chunkSize?: number
|
chunkSize?: number
|
||||||
}): AsyncIterableIterator<Boost>
|
}): AsyncIterableIterator<Boost>
|
||||||
/**
|
|
||||||
* Iterate over saved star gifts of a user,
|
|
||||||
* wrapper over {@link getSavedStarGifts}
|
|
||||||
*/
|
|
||||||
iterSavedStarGifts(
|
|
||||||
params: {
|
|
||||||
/** Peer to get saved gifts from */
|
|
||||||
owner: InputPeerLike
|
|
||||||
|
|
||||||
/** Whether to exclude unsaved gifts */
|
|
||||||
excludeUnsaved?: boolean
|
|
||||||
/** Whether to exclude saved gifts */
|
|
||||||
excludeSaved?: boolean
|
|
||||||
/** Whether to exclude gifts with unlimited availability */
|
|
||||||
excludeUnlimited?: boolean
|
|
||||||
/** Whether to exclude gifts with limited availability */
|
|
||||||
excludeLimited?: boolean
|
|
||||||
/** Whether to exclude unique gifts */
|
|
||||||
excludeUnique?: boolean
|
|
||||||
|
|
||||||
/** Whether to sort by value */
|
|
||||||
sortByValue?: boolean
|
|
||||||
|
|
||||||
/** Offset for pagination */
|
|
||||||
offset?: string
|
|
||||||
/** Limit for pagination */
|
|
||||||
limit?: number
|
|
||||||
}): AsyncIterableIterator<SavedStarGift>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over gifts sent to a given user.
|
* Iterate over gifts sent to a given user.
|
||||||
|
@ -4925,8 +4851,8 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
sendStarGift(
|
sendStarGift(
|
||||||
params: {
|
params: {
|
||||||
/** ID of the peer to send the gift to */
|
/** ID of the user to send the gift to */
|
||||||
peerId: InputPeerLike
|
userId: InputPeerLike
|
||||||
|
|
||||||
/** ID of the gift to send */
|
/** ID of the gift to send */
|
||||||
gift: Long | StarGift
|
gift: Long | StarGift
|
||||||
|
@ -5013,8 +4939,8 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
transferStarGift(
|
transferStarGift(
|
||||||
params: {
|
params: {
|
||||||
/** Star gift to transfer */
|
/** ID of the message containing the gift */
|
||||||
gift: InputStarGift
|
message: number | Message
|
||||||
|
|
||||||
/** ID of the user to transfer the gift to */
|
/** ID of the user to transfer the gift to */
|
||||||
recepient: InputPeerLike
|
recepient: InputPeerLike
|
||||||
|
@ -5039,7 +4965,8 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
*/
|
*/
|
||||||
upgradeStarGift(
|
upgradeStarGift(
|
||||||
params: {
|
params: {
|
||||||
gift: InputStarGift
|
/** ID of the message containing the gift */
|
||||||
|
message: number | Message
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to retain the original details of the gift
|
* Whether to retain the original details of the gift
|
||||||
|
@ -5952,8 +5879,6 @@ export interface TelegramClient extends ITelegramClient {
|
||||||
peerId: InputPeerLike
|
peerId: InputPeerLike
|
||||||
/** Custom emoji ID or `null` to remove the emoji */
|
/** Custom emoji ID or `null` to remove the emoji */
|
||||||
emoji: tl.Long | null
|
emoji: tl.Long | null
|
||||||
/** When true, `emoji` is the ID of the collectible emoji */
|
|
||||||
isCollectible?: boolean
|
|
||||||
/**
|
/**
|
||||||
* Date when the emoji status should expire (only if `emoji` is not `null`)
|
* Date when the emoji status should expire (only if `emoji` is not `null`)
|
||||||
*/
|
*/
|
||||||
|
@ -6827,9 +6752,6 @@ TelegramClient.prototype.cancelPasswordEmail = function (...args) {
|
||||||
TelegramClient.prototype.removeCloudPassword = function (...args) {
|
TelegramClient.prototype.removeCloudPassword = function (...args) {
|
||||||
return removeCloudPassword(this._client, ...args)
|
return removeCloudPassword(this._client, ...args)
|
||||||
}
|
}
|
||||||
TelegramClient.prototype._normalizeInputStarGift = function (...args) {
|
|
||||||
return _normalizeInputStarGift(this._client, ...args)
|
|
||||||
}
|
|
||||||
TelegramClient.prototype.acceptStarGift = function (...args) {
|
TelegramClient.prototype.acceptStarGift = function (...args) {
|
||||||
return acceptStarGift(this._client, ...args)
|
return acceptStarGift(this._client, ...args)
|
||||||
}
|
}
|
||||||
|
@ -6863,18 +6785,9 @@ TelegramClient.prototype.getBusinessConnection = function (...args) {
|
||||||
TelegramClient.prototype.getMyBoostSlots = function (...args) {
|
TelegramClient.prototype.getMyBoostSlots = function (...args) {
|
||||||
return getMyBoostSlots(this._client, ...args)
|
return getMyBoostSlots(this._client, ...args)
|
||||||
}
|
}
|
||||||
TelegramClient.prototype.getSavedStarGiftsById = function (...args) {
|
|
||||||
return getSavedStarGiftsById(this._client, ...args)
|
|
||||||
}
|
|
||||||
TelegramClient.prototype.getSavedStarGifts = function (...args) {
|
|
||||||
return getSavedStarGifts(this._client, ...args)
|
|
||||||
}
|
|
||||||
TelegramClient.prototype.getStarGiftOptions = function (...args) {
|
TelegramClient.prototype.getStarGiftOptions = function (...args) {
|
||||||
return getStarGiftOptions(this._client, ...args)
|
return getStarGiftOptions(this._client, ...args)
|
||||||
}
|
}
|
||||||
TelegramClient.prototype.getStarGiftWithdrawalUrl = function (...args) {
|
|
||||||
return getStarGiftWithdrawalUrl(this._client, ...args)
|
|
||||||
}
|
|
||||||
TelegramClient.prototype.getStarGifts = function (...args) {
|
TelegramClient.prototype.getStarGifts = function (...args) {
|
||||||
return getStarGifts(this._client, ...args)
|
return getStarGifts(this._client, ...args)
|
||||||
}
|
}
|
||||||
|
@ -6887,9 +6800,6 @@ TelegramClient.prototype.getUniqueStarGift = function (...args) {
|
||||||
TelegramClient.prototype.iterBoosters = function (...args) {
|
TelegramClient.prototype.iterBoosters = function (...args) {
|
||||||
return iterBoosters(this._client, ...args)
|
return iterBoosters(this._client, ...args)
|
||||||
}
|
}
|
||||||
TelegramClient.prototype.iterSavedStarGifts = function (...args) {
|
|
||||||
return iterSavedStarGifts(this._client, ...args)
|
|
||||||
}
|
|
||||||
TelegramClient.prototype.iterStarGifts = function (...args) {
|
TelegramClient.prototype.iterStarGifts = function (...args) {
|
||||||
return iterStarGifts(this._client, ...args)
|
return iterStarGifts(this._client, ...args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,6 @@ export { verifyPasswordEmail } from './methods/password/password-email.js'
|
||||||
export { resendPasswordEmail } from './methods/password/password-email.js'
|
export { resendPasswordEmail } from './methods/password/password-email.js'
|
||||||
export { cancelPasswordEmail } from './methods/password/password-email.js'
|
export { cancelPasswordEmail } from './methods/password/password-email.js'
|
||||||
export { removeCloudPassword } from './methods/password/remove-cloud-password.js'
|
export { removeCloudPassword } from './methods/password/remove-cloud-password.js'
|
||||||
export { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js'
|
|
||||||
export { acceptStarGift } from './methods/premium/accept-star-gift.js'
|
export { acceptStarGift } from './methods/premium/accept-star-gift.js'
|
||||||
export { applyBoost } from './methods/premium/apply-boost.js'
|
export { applyBoost } from './methods/premium/apply-boost.js'
|
||||||
export { canApplyBoost } from './methods/premium/can-apply-boost.js'
|
export { canApplyBoost } from './methods/premium/can-apply-boost.js'
|
||||||
|
@ -222,15 +221,11 @@ export { getBoosts } from './methods/premium/get-boosts.js'
|
||||||
export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js'
|
export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js'
|
||||||
export { getBusinessConnection } from './methods/premium/get-business-connection.js'
|
export { getBusinessConnection } from './methods/premium/get-business-connection.js'
|
||||||
export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
|
export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
|
||||||
export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js'
|
|
||||||
export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js'
|
|
||||||
export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js'
|
export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js'
|
||||||
export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js'
|
|
||||||
export { getStarGifts } from './methods/premium/get-star-gifts.js'
|
export { getStarGifts } from './methods/premium/get-star-gifts.js'
|
||||||
export { getStarsTransactions } from './methods/premium/get-stars-transactions.js'
|
export { getStarsTransactions } from './methods/premium/get-stars-transactions.js'
|
||||||
export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js'
|
export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js'
|
||||||
export { iterBoosters } from './methods/premium/iter-boosters.js'
|
export { iterBoosters } from './methods/premium/iter-boosters.js'
|
||||||
export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js'
|
|
||||||
export { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
export { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
||||||
export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
||||||
export { sendStarGift } from './methods/premium/send-star-gift.js'
|
export { sendStarGift } from './methods/premium/send-star-gift.js'
|
||||||
|
|
|
@ -67,7 +67,6 @@ import {
|
||||||
InputPeerLike,
|
InputPeerLike,
|
||||||
InputPrivacyRule,
|
InputPrivacyRule,
|
||||||
InputReaction,
|
InputReaction,
|
||||||
InputStarGift,
|
|
||||||
InputStickerSet,
|
InputStickerSet,
|
||||||
InputStickerSetItem,
|
InputStickerSetItem,
|
||||||
InputText,
|
InputText,
|
||||||
|
@ -89,7 +88,6 @@ import {
|
||||||
PreCheckoutQuery,
|
PreCheckoutQuery,
|
||||||
RawDocument,
|
RawDocument,
|
||||||
ReplyMarkup,
|
ReplyMarkup,
|
||||||
SavedStarGift,
|
|
||||||
SentCode,
|
SentCode,
|
||||||
StarGift,
|
StarGift,
|
||||||
StarGiftUnique,
|
StarGiftUnique,
|
||||||
|
|
|
@ -263,14 +263,6 @@ export async function _normalizeInputMedia(
|
||||||
mime = uploaded.mime
|
mime = uploaded.mime
|
||||||
}
|
}
|
||||||
|
|
||||||
let videoCover: tl.TypeInputPhoto | undefined
|
|
||||||
if (media.type === 'video' && media.cover) {
|
|
||||||
const inputMedia = await _normalizeInputMedia(client, media.cover)
|
|
||||||
assertTypeIs('uploadMediaIfNeeded', inputMedia, 'inputMediaPhoto')
|
|
||||||
|
|
||||||
videoCover = inputMedia.id
|
|
||||||
}
|
|
||||||
|
|
||||||
const uploadPeer = params.uploadPeer ?? { _: 'inputPeerSelf' }
|
const uploadPeer = params.uploadPeer ?? { _: 'inputPeerSelf' }
|
||||||
|
|
||||||
const uploadMediaIfNeeded = async (inputMedia: tl.TypeInputMedia, photo: boolean): Promise<tl.TypeInputMedia> => {
|
const uploadMediaIfNeeded = async (inputMedia: tl.TypeInputMedia, photo: boolean): Promise<tl.TypeInputMedia> => {
|
||||||
|
@ -312,8 +304,6 @@ export async function _normalizeInputMedia(
|
||||||
},
|
},
|
||||||
ttlSeconds: media.ttlSeconds,
|
ttlSeconds: media.ttlSeconds,
|
||||||
spoiler: media.type === 'video' && media.spoiler,
|
spoiler: media.type === 'video' && media.spoiler,
|
||||||
videoCover,
|
|
||||||
videoTimestamp: media.type === 'video' ? media.timestamp : undefined,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,8 +431,6 @@ export async function _normalizeInputMedia(
|
||||||
attributes,
|
attributes,
|
||||||
ttlSeconds: media.ttlSeconds,
|
ttlSeconds: media.ttlSeconds,
|
||||||
spoiler: media.type === 'video' && media.spoiler,
|
spoiler: media.type === 'video' && media.spoiler,
|
||||||
videoTimestamp: media.type === 'video' ? media.timestamp : undefined,
|
|
||||||
videoCover,
|
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
@ -78,9 +78,6 @@ export interface ForwardMessageOptions {
|
||||||
* The Stars will be withdrawn from the bot's balance.
|
* The Stars will be withdrawn from the bot's balance.
|
||||||
*/
|
*/
|
||||||
allowPaidFloodskip?: boolean
|
allowPaidFloodskip?: boolean
|
||||||
|
|
||||||
/** Video timestamp to use for the forwarded video */
|
|
||||||
videoTimestamp?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +110,6 @@ export async function forwardMessagesById(
|
||||||
noAuthor,
|
noAuthor,
|
||||||
noCaption,
|
noCaption,
|
||||||
allowPaidFloodskip,
|
allowPaidFloodskip,
|
||||||
videoTimestamp,
|
|
||||||
} = params
|
} = params
|
||||||
|
|
||||||
// sending more than 100 will not result in a server-sent
|
// sending more than 100 will not result in a server-sent
|
||||||
|
@ -141,7 +137,6 @@ export async function forwardMessagesById(
|
||||||
sendAs: sendAs ? await resolvePeer(client, sendAs) : undefined,
|
sendAs: sendAs ? await resolvePeer(client, sendAs) : undefined,
|
||||||
quickReplyShortcut: _normalizeQuickReplyShortcut(params.quickReply),
|
quickReplyShortcut: _normalizeQuickReplyShortcut(params.quickReply),
|
||||||
allowPaidFloodskip,
|
allowPaidFloodskip,
|
||||||
videoTimestamp,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
assertIsUpdatesGroup('messages.forwardMessages', res)
|
assertIsUpdatesGroup('messages.forwardMessages', res)
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
|
||||||
import type { InputStarGift } from '../../types/index.js'
|
|
||||||
import { resolvePeer } from '../users/resolve-peer.js'
|
|
||||||
|
|
||||||
export async function _normalizeInputStarGift(
|
|
||||||
client: ITelegramClient,
|
|
||||||
gift: InputStarGift,
|
|
||||||
): Promise<tl.TypeInputSavedStarGift> {
|
|
||||||
if ('message' in gift) {
|
|
||||||
return {
|
|
||||||
_: 'inputSavedStarGiftUser',
|
|
||||||
msgId: typeof gift.message === 'number' ? gift.message : gift.message.id,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
_: 'inputSavedStarGiftChat',
|
|
||||||
peer: await resolvePeer(client, gift.owner),
|
|
||||||
savedId: gift.savedId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
import type { ITelegramClient } from '../../client.types.js'
|
||||||
import type { InputStarGift } from '../../types/index.js'
|
import type { Message } from '../../types/messages/message.js'
|
||||||
import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
|
||||||
|
|
||||||
// @available=user
|
// @available=user
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +10,8 @@ import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
||||||
export async function acceptStarGift(
|
export async function acceptStarGift(
|
||||||
client: ITelegramClient,
|
client: ITelegramClient,
|
||||||
params: {
|
params: {
|
||||||
/** Input star gift to accept */
|
/** ID of the message containing the gift */
|
||||||
gift: InputStarGift
|
message: number | Message
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to perform on the gift.
|
* Action to perform on the gift.
|
||||||
* - `save` - save the gift to your profile
|
* - `save` - save the gift to your profile
|
||||||
|
@ -24,17 +22,18 @@ export async function acceptStarGift(
|
||||||
},
|
},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const { action } = params
|
const { action } = params
|
||||||
const inputStarGift = await _normalizeInputStarGift(client, params.gift)
|
const message = typeof params.message === 'number' ? params.message : params.message.id
|
||||||
|
|
||||||
return client.call(
|
return client.call(
|
||||||
action === 'convert'
|
action === 'convert'
|
||||||
? {
|
? {
|
||||||
_: 'payments.convertStarGift',
|
_: 'payments.convertStarGift',
|
||||||
stargift: inputStarGift,
|
msgId: message,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
_: 'payments.saveStarGift',
|
_: 'payments.saveStarGift',
|
||||||
unsave: action === 'hide',
|
unsave: action === 'hide',
|
||||||
stargift: inputStarGift,
|
msgId: message,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
|
||||||
import type { InputStarGift } from '../../types/premium/stars-gift.js'
|
|
||||||
import { type MaybeArray, parallelMap } from '@fuman/utils'
|
|
||||||
import { PeersIndex, SavedStarGift } from '../../types/index.js'
|
|
||||||
import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
|
||||||
|
|
||||||
/** Get one or more saved star gifts by their IDs */
|
|
||||||
export async function getSavedStarGiftsById(
|
|
||||||
client: ITelegramClient,
|
|
||||||
gifts: MaybeArray<InputStarGift>,
|
|
||||||
): Promise<SavedStarGift[]> {
|
|
||||||
if (!Array.isArray(gifts)) gifts = [gifts]
|
|
||||||
const res = await client.call({
|
|
||||||
_: 'payments.getSavedStarGift',
|
|
||||||
stargift: await parallelMap(gifts, it => _normalizeInputStarGift(client, it), { limit: 10 }),
|
|
||||||
})
|
|
||||||
|
|
||||||
const peers = PeersIndex.from(res)
|
|
||||||
|
|
||||||
return res.gifts.map(it => new SavedStarGift(it, peers))
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
|
||||||
import type { ArrayPaginated, InputPeerLike } from '../../types/index.js'
|
|
||||||
import { PeersIndex } from '../../types/index.js'
|
|
||||||
import { SavedStarGift } from '../../types/premium/saved-star-gift.js'
|
|
||||||
import { makeArrayPaginated } from '../../utils/misc-utils.js'
|
|
||||||
import { resolvePeer } from '../users/resolve-peer.js'
|
|
||||||
|
|
||||||
/** Get a list of saved star gifts of a user */
|
|
||||||
export async function getSavedStarGifts(
|
|
||||||
client: ITelegramClient,
|
|
||||||
params: {
|
|
||||||
/** Peer to get saved gifts from */
|
|
||||||
owner: InputPeerLike
|
|
||||||
|
|
||||||
/** Whether to exclude hidden gifts */
|
|
||||||
excludeHidden?: boolean
|
|
||||||
/** Whether to exclude publicly visible gifts */
|
|
||||||
excludePublic?: boolean
|
|
||||||
/** Whether to exclude gifts with unlimited availability */
|
|
||||||
excludeUnlimited?: boolean
|
|
||||||
/** Whether to exclude gifts with limited availability */
|
|
||||||
excludeLimited?: boolean
|
|
||||||
/** Whether to exclude unique gifts */
|
|
||||||
excludeUnique?: boolean
|
|
||||||
|
|
||||||
/** Whether to sort by value */
|
|
||||||
sortByValue?: boolean
|
|
||||||
|
|
||||||
/** Offset for pagination */
|
|
||||||
offset?: string
|
|
||||||
/** Limit for pagination */
|
|
||||||
limit?: number
|
|
||||||
},
|
|
||||||
): Promise<ArrayPaginated<SavedStarGift, string>> {
|
|
||||||
const res = await client.call({
|
|
||||||
_: 'payments.getSavedStarGifts',
|
|
||||||
peer: await resolvePeer(client, params.owner),
|
|
||||||
excludeUnsaved: params.excludeHidden,
|
|
||||||
excludeSaved: params.excludePublic,
|
|
||||||
excludeUnlimited: params.excludeUnlimited,
|
|
||||||
excludeLimited: params.excludeLimited,
|
|
||||||
excludeUnique: params.excludeUnique,
|
|
||||||
sortByValue: params.sortByValue,
|
|
||||||
offset: params.offset ?? '',
|
|
||||||
limit: params.limit ?? 100,
|
|
||||||
})
|
|
||||||
|
|
||||||
const peers = PeersIndex.from(res)
|
|
||||||
|
|
||||||
return makeArrayPaginated(
|
|
||||||
res.gifts.map(it => new SavedStarGift(it, peers)),
|
|
||||||
res.count,
|
|
||||||
res.nextOffset,
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
|
||||||
import type { InputStarGift } from '../../types/index.js'
|
|
||||||
import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
|
||||||
|
|
||||||
export async function getStarGiftWithdrawalUrl(
|
|
||||||
client: ITelegramClient,
|
|
||||||
params: {
|
|
||||||
/** The star gift to withdraw */
|
|
||||||
gift: InputStarGift
|
|
||||||
|
|
||||||
/** 2FA password */
|
|
||||||
password: string
|
|
||||||
},
|
|
||||||
): Promise<string> {
|
|
||||||
const password = await client.computeSrpParams(
|
|
||||||
await client.call({
|
|
||||||
_: 'account.getPassword',
|
|
||||||
}),
|
|
||||||
params.password,
|
|
||||||
)
|
|
||||||
|
|
||||||
const res = await client.call({
|
|
||||||
_: 'payments.getStarGiftWithdrawalUrl',
|
|
||||||
stargift: await _normalizeInputStarGift(client, params.gift),
|
|
||||||
password,
|
|
||||||
})
|
|
||||||
|
|
||||||
return res.url
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
|
||||||
import type { InputPeerLike } from '../../types/index.js'
|
|
||||||
import { PeersIndex } from '../../types/index.js'
|
|
||||||
import { SavedStarGift } from '../../types/premium/saved-star-gift.js'
|
|
||||||
import { resolvePeer } from '../users/resolve-peer.js'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterate over saved star gifts of a user,
|
|
||||||
* wrapper over {@link getSavedStarGifts}
|
|
||||||
*/
|
|
||||||
export async function* iterSavedStarGifts(
|
|
||||||
client: ITelegramClient,
|
|
||||||
params: {
|
|
||||||
/** Peer to get saved gifts from */
|
|
||||||
owner: InputPeerLike
|
|
||||||
|
|
||||||
/** Whether to exclude unsaved gifts */
|
|
||||||
excludeUnsaved?: boolean
|
|
||||||
/** Whether to exclude saved gifts */
|
|
||||||
excludeSaved?: boolean
|
|
||||||
/** Whether to exclude gifts with unlimited availability */
|
|
||||||
excludeUnlimited?: boolean
|
|
||||||
/** Whether to exclude gifts with limited availability */
|
|
||||||
excludeLimited?: boolean
|
|
||||||
/** Whether to exclude unique gifts */
|
|
||||||
excludeUnique?: boolean
|
|
||||||
|
|
||||||
/** Whether to sort by value */
|
|
||||||
sortByValue?: boolean
|
|
||||||
|
|
||||||
/** Offset for pagination */
|
|
||||||
offset?: string
|
|
||||||
/** Limit for pagination */
|
|
||||||
limit?: number
|
|
||||||
},
|
|
||||||
): AsyncIterableIterator<SavedStarGift> {
|
|
||||||
const owner = await resolvePeer(client, params.owner)
|
|
||||||
let offset = ''
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
const res = await client.call({
|
|
||||||
_: 'payments.getSavedStarGifts',
|
|
||||||
peer: owner,
|
|
||||||
excludeUnsaved: params.excludeUnsaved,
|
|
||||||
excludeSaved: params.excludeSaved,
|
|
||||||
excludeUnlimited: params.excludeUnlimited,
|
|
||||||
excludeLimited: params.excludeLimited,
|
|
||||||
excludeUnique: params.excludeUnique,
|
|
||||||
sortByValue: params.sortByValue,
|
|
||||||
offset,
|
|
||||||
limit: params.limit ?? 100,
|
|
||||||
})
|
|
||||||
|
|
||||||
const peers = PeersIndex.from(res)
|
|
||||||
|
|
||||||
yield * res.gifts.map(it => new SavedStarGift(it, peers))
|
|
||||||
|
|
||||||
if (!res.nextOffset) break
|
|
||||||
offset = res.nextOffset
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import Long from 'long'
|
||||||
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
||||||
import { type InputText, inputTextToTl } from '../../types/misc/entities.js'
|
import { type InputText, inputTextToTl } from '../../types/misc/entities.js'
|
||||||
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
||||||
import { resolvePeer } from '../users/resolve-peer.js'
|
import { resolveUser } from '../users/resolve-peer.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a star gift to a user.
|
* Send a star gift to a user.
|
||||||
|
@ -23,8 +23,8 @@ import { resolvePeer } from '../users/resolve-peer.js'
|
||||||
export async function sendStarGift(
|
export async function sendStarGift(
|
||||||
client: ITelegramClient,
|
client: ITelegramClient,
|
||||||
params: {
|
params: {
|
||||||
/** ID of the peer to send the gift to */
|
/** ID of the user to send the gift to */
|
||||||
peerId: InputPeerLike
|
userId: InputPeerLike
|
||||||
|
|
||||||
/** ID of the gift to send */
|
/** ID of the gift to send */
|
||||||
gift: Long | StarGift
|
gift: Long | StarGift
|
||||||
|
@ -50,7 +50,7 @@ export async function sendStarGift(
|
||||||
},
|
},
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const {
|
const {
|
||||||
peerId,
|
userId,
|
||||||
gift,
|
gift,
|
||||||
anonymous,
|
anonymous,
|
||||||
message,
|
message,
|
||||||
|
@ -61,7 +61,7 @@ export async function sendStarGift(
|
||||||
const invoice: tl.TypeInputInvoice = {
|
const invoice: tl.TypeInputInvoice = {
|
||||||
_: 'inputInvoiceStarGift',
|
_: 'inputInvoiceStarGift',
|
||||||
hideName: anonymous,
|
hideName: anonymous,
|
||||||
peer: await resolvePeer(client, peerId),
|
userId: await resolveUser(client, userId),
|
||||||
giftId: Long.isLong(gift) ? gift : gift.id,
|
giftId: Long.isLong(gift) ? gift : gift.id,
|
||||||
message: message ? inputTextToTl(message) : undefined,
|
message: message ? inputTextToTl(message) : undefined,
|
||||||
includeUpgrade: withUpgrade,
|
includeUpgrade: withUpgrade,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
import type { tl } from '@mtcute/tl'
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
import type { ITelegramClient } from '../../client.types.js'
|
||||||
|
|
||||||
import type { InputPeerLike, InputStarGift } from '../../types/index.js'
|
import type { InputPeerLike } from '../../types/index.js'
|
||||||
import type { Message } from '../../types/messages/message.js'
|
import type { Message } from '../../types/messages/message.js'
|
||||||
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
||||||
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
||||||
import { resolvePeer } from '../users/resolve-peer.js'
|
import { resolveUser } from '../users/resolve-peer.js'
|
||||||
import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer a unique star gift.
|
* Transfer a unique star gift.
|
||||||
|
@ -21,8 +20,8 @@ import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
||||||
export async function transferStarGift(
|
export async function transferStarGift(
|
||||||
client: ITelegramClient,
|
client: ITelegramClient,
|
||||||
params: {
|
params: {
|
||||||
/** Star gift to transfer */
|
/** ID of the message containing the gift */
|
||||||
gift: InputStarGift
|
message: number | Message
|
||||||
|
|
||||||
/** ID of the user to transfer the gift to */
|
/** ID of the user to transfer the gift to */
|
||||||
recepient: InputPeerLike
|
recepient: InputPeerLike
|
||||||
|
@ -34,12 +33,13 @@ export async function transferStarGift(
|
||||||
shouldDispatch?: true
|
shouldDispatch?: true
|
||||||
},
|
},
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const { gift, recepient, shouldDispatch } = params
|
const { message, recepient, shouldDispatch } = params
|
||||||
|
|
||||||
|
const msgId = typeof message === 'number' ? message : message.id
|
||||||
const invoice: tl.TypeInputInvoice = {
|
const invoice: tl.TypeInputInvoice = {
|
||||||
_: 'inputInvoiceStarGiftTransfer',
|
_: 'inputInvoiceStarGiftTransfer',
|
||||||
stargift: await _normalizeInputStarGift(client, gift),
|
msgId,
|
||||||
toId: await resolvePeer(client, recepient),
|
toId: await resolveUser(client, recepient),
|
||||||
}
|
}
|
||||||
|
|
||||||
const form = await client.call({
|
const form = await client.call({
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
import type { tl } from '@mtcute/tl'
|
||||||
import type { ITelegramClient } from '../../client.types.js'
|
import type { ITelegramClient } from '../../client.types.js'
|
||||||
|
|
||||||
import type { InputStarGift } from '../../types/index.js'
|
|
||||||
import type { Message } from '../../types/messages/message.js'
|
import type { Message } from '../../types/messages/message.js'
|
||||||
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
import { assertTypeIs } from '../../../utils/type-assertions.js'
|
||||||
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
||||||
import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upgrades a star gift to a unique gift.
|
* Upgrades a star gift to a unique gift.
|
||||||
|
@ -20,7 +18,8 @@ import { _normalizeInputStarGift } from './_normalize-input-star-gift.js'
|
||||||
export async function upgradeStarGift(
|
export async function upgradeStarGift(
|
||||||
client: ITelegramClient,
|
client: ITelegramClient,
|
||||||
params: {
|
params: {
|
||||||
gift: InputStarGift
|
/** ID of the message containing the gift */
|
||||||
|
message: number | Message
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to retain the original details of the gift
|
* Whether to retain the original details of the gift
|
||||||
|
@ -35,11 +34,12 @@ export async function upgradeStarGift(
|
||||||
shouldDispatch?: true
|
shouldDispatch?: true
|
||||||
},
|
},
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const { gift, keepOriginalDetails, shouldDispatch } = params
|
const { message, keepOriginalDetails, shouldDispatch } = params
|
||||||
|
|
||||||
|
const msgId = typeof message === 'number' ? message : message.id
|
||||||
const invoice: tl.TypeInputInvoice = {
|
const invoice: tl.TypeInputInvoice = {
|
||||||
_: 'inputInvoiceStarGiftUpgrade',
|
_: 'inputInvoiceStarGiftUpgrade',
|
||||||
stargift: await _normalizeInputStarGift(client, gift),
|
msgId,
|
||||||
keepOriginalDetails,
|
keepOriginalDetails,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,6 @@ export async function setEmojiStatus(
|
||||||
peerId: InputPeerLike
|
peerId: InputPeerLike
|
||||||
/** Custom emoji ID or `null` to remove the emoji */
|
/** Custom emoji ID or `null` to remove the emoji */
|
||||||
emoji: tl.Long | null
|
emoji: tl.Long | null
|
||||||
/** When true, `emoji` is the ID of the collectible emoji */
|
|
||||||
isCollectible?: boolean
|
|
||||||
/**
|
/**
|
||||||
* Date when the emoji status should expire (only if `emoji` is not `null`)
|
* Date when the emoji status should expire (only if `emoji` is not `null`)
|
||||||
*/
|
*/
|
||||||
|
@ -58,7 +56,6 @@ export async function setEmojiStatus(
|
||||||
peerId,
|
peerId,
|
||||||
emoji,
|
emoji,
|
||||||
until,
|
until,
|
||||||
isCollectible,
|
|
||||||
} = params
|
} = params
|
||||||
|
|
||||||
const peer = await resolvePeer(client, peerId)
|
const peer = await resolvePeer(client, peerId)
|
||||||
|
@ -73,12 +70,6 @@ export async function setEmojiStatus(
|
||||||
documentId: emoji,
|
documentId: emoji,
|
||||||
until: normalizeDate(until),
|
until: normalizeDate(until),
|
||||||
}
|
}
|
||||||
} else if (isCollectible) {
|
|
||||||
emojiStatus = {
|
|
||||||
_: 'inputEmojiStatusCollectible',
|
|
||||||
collectibleId: emoji,
|
|
||||||
until: normalizeDate(until),
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
emojiStatus = {
|
emojiStatus = {
|
||||||
_: 'emojiStatus',
|
_: 'emojiStatus',
|
||||||
|
|
|
@ -243,12 +243,6 @@ export interface InputMediaVideo extends FileMixin, CaptionMixin {
|
||||||
* Whether this video should be hidden with a spoiler
|
* Whether this video should be hidden with a spoiler
|
||||||
*/
|
*/
|
||||||
spoiler?: boolean
|
spoiler?: boolean
|
||||||
|
|
||||||
/** Cover for the video */
|
|
||||||
cover?: InputMediaPhoto
|
|
||||||
|
|
||||||
/** Timestamp for the auto-generated cover (?) */
|
|
||||||
timestamp?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { makeInspectable } from '../../utils/index.js'
|
||||||
import { memoizeGetters } from '../../utils/memoize.js'
|
import { memoizeGetters } from '../../utils/memoize.js'
|
||||||
|
|
||||||
import { RawDocument } from './document.js'
|
import { RawDocument } from './document.js'
|
||||||
import { Photo } from './photo.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A video, round video message or GIF animation.
|
* A video, round video message or GIF animation.
|
||||||
|
@ -95,16 +94,6 @@ export class Video extends RawDocument {
|
||||||
get codec(): string | null {
|
get codec(): string | null {
|
||||||
return this.attr._ === 'documentAttributeVideo' ? this.attr.videoCodec ?? null : null
|
return this.attr._ === 'documentAttributeVideo' ? this.attr.videoCodec ?? null : null
|
||||||
}
|
}
|
||||||
|
|
||||||
get videoCover(): Photo | null {
|
|
||||||
if (!this.media || this.media.videoCover?._ !== 'photo') return null
|
|
||||||
|
|
||||||
return new Photo(this.media.videoCover)
|
|
||||||
}
|
|
||||||
|
|
||||||
get videoTimestamp(): number | null {
|
|
||||||
return this.media?.videoTimestamp ?? null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memoizeGetters(Video, ['fileName', 'thumbnails', 'fileId', 'uniqueFileId', 'isAnimation'])
|
memoizeGetters(Video, ['fileName', 'thumbnails', 'fileId', 'uniqueFileId', 'isAnimation'])
|
||||||
|
|
|
@ -565,10 +565,6 @@ export interface ActionStarGift {
|
||||||
gift: StarGift | StarGiftUnique
|
gift: StarGift | StarGiftUnique
|
||||||
/** Message attached to the gift */
|
/** Message attached to the gift */
|
||||||
message: TextWithEntities | null
|
message: TextWithEntities | null
|
||||||
|
|
||||||
fromId?: number
|
|
||||||
toId?: number
|
|
||||||
savedId?: Long
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageAction =
|
export type MessageAction =
|
||||||
|
@ -928,31 +924,6 @@ export function _messageActionFromTl(this: Message, act: tl.TypeMessageAction):
|
||||||
upgraded: act.upgraded!,
|
upgraded: act.upgraded!,
|
||||||
upgradeStars: act.upgradeStars ?? Long.ZERO,
|
upgradeStars: act.upgradeStars ?? Long.ZERO,
|
||||||
upgradeMsgId: act.upgradeMsgId ?? null,
|
upgradeMsgId: act.upgradeMsgId ?? null,
|
||||||
|
|
||||||
fromId: act.fromId ? getMarkedPeerId(act.fromId) : undefined,
|
|
||||||
toId: act.peer ? getMarkedPeerId(act.peer) : undefined,
|
|
||||||
savedId: act.savedId,
|
|
||||||
}
|
|
||||||
case 'messageActionStarGiftUnique':
|
|
||||||
return {
|
|
||||||
type: 'stars_gift',
|
|
||||||
nameHidden: false,
|
|
||||||
saved: act.saved!,
|
|
||||||
converted: false,
|
|
||||||
convertStars: Long.ZERO,
|
|
||||||
refunded: act.refunded!,
|
|
||||||
gift: act.gift._ === 'starGift'
|
|
||||||
? new StarGift(act.gift)
|
|
||||||
: new StarGiftUnique(act.gift, this._peers),
|
|
||||||
message: null,
|
|
||||||
canUpgrade: false,
|
|
||||||
upgraded: true,
|
|
||||||
upgradeStars: Long.ZERO,
|
|
||||||
upgradeMsgId: null,
|
|
||||||
|
|
||||||
fromId: act.fromId ? getMarkedPeerId(act.fromId) : undefined,
|
|
||||||
toId: act.peer ? getMarkedPeerId(act.peer) : undefined,
|
|
||||||
savedId: act.savedId,
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -404,12 +404,7 @@ export class Chat {
|
||||||
*/
|
*/
|
||||||
get emojiStatus(): EmojiStatus | null {
|
get emojiStatus(): EmojiStatus | null {
|
||||||
if (this.raw._ !== 'channel') return null
|
if (this.raw._ !== 'channel') return null
|
||||||
if (
|
if (!this.raw.emojiStatus || this.raw.emojiStatus._ === 'emojiStatusEmpty') return null
|
||||||
!this.raw.emojiStatus
|
|
||||||
|| this.raw.emojiStatus._ === 'emojiStatusEmpty'
|
|
||||||
|| this.raw.emojiStatus._ === 'inputEmojiStatusCollectible') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmojiStatus(this.raw.emojiStatus)
|
return new EmojiStatus(this.raw.emojiStatus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,16 +364,6 @@ export class FullChat extends Chat {
|
||||||
|
|
||||||
return new BotVerification(this.full.botVerification)
|
return new BotVerification(this.full.botVerification)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether star gifts are available in this chat */
|
|
||||||
get starGiftsAvailable(): boolean {
|
|
||||||
return this.full._ === 'channelFull' && this.full.stargiftsAvailable!
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Number of star gifts available in this chat */
|
|
||||||
get starGiftsCount(): number {
|
|
||||||
return this.full._ === 'channelFull' ? this.full.stargiftsCount ?? 0 : 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memoizeGetters(FullChat, [
|
memoizeGetters(FullChat, [
|
||||||
|
|
|
@ -408,12 +408,7 @@ export class User {
|
||||||
* User's emoji status, if any.
|
* User's emoji status, if any.
|
||||||
*/
|
*/
|
||||||
get emojiStatus(): EmojiStatus | null {
|
get emojiStatus(): EmojiStatus | null {
|
||||||
if (
|
if (!this.raw.emojiStatus || this.raw.emojiStatus._ === 'emojiStatusEmpty') return null
|
||||||
!this.raw.emojiStatus
|
|
||||||
|| this.raw.emojiStatus._ === 'emojiStatusEmpty'
|
|
||||||
|| this.raw.emojiStatus._ === 'inputEmojiStatusCollectible') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmojiStatus(this.raw.emojiStatus)
|
return new EmojiStatus(this.raw.emojiStatus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ export * from './business-connection.js'
|
||||||
export * from './business-intro.js'
|
export * from './business-intro.js'
|
||||||
export * from './business-location.js'
|
export * from './business-location.js'
|
||||||
export * from './business-work-hours.js'
|
export * from './business-work-hours.js'
|
||||||
export * from './saved-star-gift.js'
|
|
||||||
export * from './stars-gift-unique.js'
|
export * from './stars-gift-unique.js'
|
||||||
export * from './stars-gift.js'
|
export * from './stars-gift.js'
|
||||||
export * from './stars-status.js'
|
export * from './stars-status.js'
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
|
||||||
import type { TextWithEntities } from '../misc/entities.js'
|
|
||||||
import type { Peer } from '../peers/peer.js'
|
|
||||||
import type { PeersIndex } from '../peers/peers-index.js'
|
|
||||||
import { makeInspectable } from '../../utils/inspectable.js'
|
|
||||||
import { memoizeGetters } from '../../utils/memoize.js'
|
|
||||||
import { parsePeer } from '../peers/peer.js'
|
|
||||||
import { StarGiftUnique } from './stars-gift-unique.js'
|
|
||||||
import { StarGift } from './stars-gift.js'
|
|
||||||
|
|
||||||
export class SavedStarGift {
|
|
||||||
constructor(
|
|
||||||
readonly raw: tl.RawSavedStarGift,
|
|
||||||
readonly _peers: PeersIndex,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/** Whether the sender name is hidden */
|
|
||||||
get nameHidden(): boolean {
|
|
||||||
return this.raw.nameHidden!
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Whether this gift was not saved yet */
|
|
||||||
get unsaved(): boolean {
|
|
||||||
return this.raw.unsaved!
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Whether this gift was refunded */
|
|
||||||
get refunded(): boolean {
|
|
||||||
return this.raw.refunded!
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Whether this gift can be upgraded to a unique gift */
|
|
||||||
get canUpgrade(): boolean {
|
|
||||||
return this.raw.canUpgrade!
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sender of the gift */
|
|
||||||
get sender(): Peer | null {
|
|
||||||
return this.raw.fromId ? parsePeer(this.raw.fromId, this._peers) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Date when the gift was sent */
|
|
||||||
get date(): Date {
|
|
||||||
return new Date(this.raw.date * 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The gift itself */
|
|
||||||
get gift(): StarGift | StarGiftUnique {
|
|
||||||
if (this.raw.gift._ === 'starGift') {
|
|
||||||
return new StarGift(this.raw.gift)
|
|
||||||
}
|
|
||||||
|
|
||||||
return new StarGiftUnique(this.raw.gift, this._peers)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The attached message */
|
|
||||||
get message(): TextWithEntities | null {
|
|
||||||
return this.raw.message ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ID of the message where the gift was originally sent (if available) */
|
|
||||||
get messageId(): number | null {
|
|
||||||
return this.raw.msgId ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ID of the saved gift */
|
|
||||||
get savedId(): tl.Long | null {
|
|
||||||
return this.raw.savedId ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Amount of stars the gift can be converted to by the recipient */
|
|
||||||
get convertStars(): tl.Long | null {
|
|
||||||
return this.raw.convertStars ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Amount of stars needed to upgrade the gift to a unique gift */
|
|
||||||
get upgradeStars(): tl.Long | null {
|
|
||||||
return this.raw.upgradeStars ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Amount of stars needed to transfer the gift */
|
|
||||||
get transferStars(): tl.Long | null {
|
|
||||||
return this.raw.transferStars ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Date when the gift can be exported to blockchain */
|
|
||||||
get canExportAt(): Date | null {
|
|
||||||
return this.raw.canExportAt ? new Date(this.raw.canExportAt * 1000) : null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
makeInspectable(SavedStarGift)
|
|
||||||
memoizeGetters(SavedStarGift, ['sender', 'gift'])
|
|
|
@ -1,13 +1,12 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
import type { tl } from '@mtcute/tl'
|
||||||
import type { Sticker } from '../media/sticker.js'
|
import type { Sticker } from '../media/sticker.js'
|
||||||
import type { TextWithEntities } from '../misc/entities.js'
|
import type { TextWithEntities } from '../misc/entities.js'
|
||||||
import type { Peer } from '../peers/peer.js'
|
|
||||||
import type { PeersIndex } from '../peers/peers-index.js'
|
import type { PeersIndex } from '../peers/peers-index.js'
|
||||||
import { assert } from '@fuman/utils'
|
import { assert } from '@fuman/utils'
|
||||||
import { makeInspectable } from '../../utils/inspectable.js'
|
import { makeInspectable } from '../../utils/inspectable.js'
|
||||||
import { memoizeGetters } from '../../utils/memoize.js'
|
import { memoizeGetters } from '../../utils/memoize.js'
|
||||||
import { parseDocument } from '../media/document-utils.js'
|
import { parseDocument } from '../media/document-utils.js'
|
||||||
import { parsePeer } from '../peers/peer.js'
|
import { User } from '../peers/user.js'
|
||||||
|
|
||||||
/** An attribute of a unique star gift containing a sticker */
|
/** An attribute of a unique star gift containing a sticker */
|
||||||
export class StarGiftUniqueAttribute {
|
export class StarGiftUniqueAttribute {
|
||||||
|
@ -79,13 +78,13 @@ export class StarGiftUniqueOriginalDetails {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/** ID of the user who sent the original star gift */
|
/** ID of the user who sent the original star gift */
|
||||||
get sender(): Peer | null {
|
get sender(): User | null {
|
||||||
return this.raw.senderId ? parsePeer(this.raw.senderId, this._peers) : null
|
return this.raw.senderId ? new User(this._peers.user(this.raw.senderId)) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ID of the user who received the original star gift */
|
/** ID of the user who received the original star gift */
|
||||||
get recipient(): Peer {
|
get recipient(): User {
|
||||||
return parsePeer(this.raw.recipientId, this._peers)
|
return new User(this._peers.user(this.raw.recipientId))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Date when the original star gift was sent */
|
/** Date when the original star gift was sent */
|
||||||
|
@ -145,10 +144,10 @@ export class StarGiftUnique {
|
||||||
return this.raw.slug
|
return this.raw.slug
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ID of the peer who owns this gift, if available */
|
/** ID of the user who owns this gift, if available */
|
||||||
get owner(): Peer | null {
|
get owner(): User | null {
|
||||||
if (!this.raw.ownerId) return null
|
if (!this.raw.ownerId) return null
|
||||||
return parsePeer(this.raw.ownerId, this._peers)
|
return new User(this._peers.user(this.raw.ownerId))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Name of the user who owns this gift, if available */
|
/** Name of the user who owns this gift, if available */
|
||||||
|
@ -184,11 +183,6 @@ export class StarGiftUnique {
|
||||||
if (!this._originalDetails) return null
|
if (!this._originalDetails) return null
|
||||||
return new StarGiftUniqueOriginalDetails(this._originalDetails, this._peers)
|
return new StarGiftUniqueOriginalDetails(this._originalDetails, this._peers)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TON address of the owner of the unique star gift */
|
|
||||||
get ownerAddress(): string | null {
|
|
||||||
return this.raw.ownerAddress ?? null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
makeInspectable(StarGiftUnique)
|
makeInspectable(StarGiftUnique)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import type { tl } from '@mtcute/tl'
|
import type { tl } from '@mtcute/tl'
|
||||||
|
|
||||||
import type { Sticker } from '../media/sticker.js'
|
import type { Sticker } from '../media/sticker.js'
|
||||||
import type { Message } from '../messages/message.js'
|
|
||||||
import type { TextWithEntities } from '../misc/entities.js'
|
import type { TextWithEntities } from '../misc/entities.js'
|
||||||
import type { InputPeerLike } from '../peers/peer.js'
|
|
||||||
import type { PeersIndex } from '../peers/peers-index.js'
|
import type { PeersIndex } from '../peers/peers-index.js'
|
||||||
import Long from 'long'
|
import Long from 'long'
|
||||||
import { MtTypeAssertionError } from '../../../types/errors.js'
|
import { MtTypeAssertionError } from '../../../types/errors.js'
|
||||||
|
@ -14,20 +12,8 @@ import { parseDocument } from '../media/document-utils.js'
|
||||||
import { User } from '../peers/user.js'
|
import { User } from '../peers/user.js'
|
||||||
import { StarGiftUnique } from './stars-gift-unique.js'
|
import { StarGiftUnique } from './stars-gift-unique.js'
|
||||||
|
|
||||||
export type InputStarGift =
|
|
||||||
| {
|
|
||||||
/** ID of the message containing the gift */
|
|
||||||
message: number | Message
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
/** Owner of the gift */
|
|
||||||
owner: InputPeerLike
|
|
||||||
/** ID of the gift */
|
|
||||||
savedId: tl.Long
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A gift bought with stars
|
* A gift with stars attached to it.
|
||||||
*/
|
*/
|
||||||
export class StarGift {
|
export class StarGift {
|
||||||
constructor(readonly raw: tl.RawStarGift) {}
|
constructor(readonly raw: tl.RawStarGift) {}
|
||||||
|
|
|
@ -2,54 +2,11 @@ import type { tl } from '@mtcute/tl'
|
||||||
|
|
||||||
import { makeInspectable } from '../../utils/index.js'
|
import { makeInspectable } from '../../utils/index.js'
|
||||||
|
|
||||||
export class EmojiStatusCollectible {
|
|
||||||
constructor(readonly raw: tl.RawEmojiStatusCollectible) {}
|
|
||||||
|
|
||||||
/** ID of the collectible */
|
|
||||||
get id(): tl.Long {
|
|
||||||
return this.raw.collectibleId
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Title of the collectible */
|
|
||||||
get title(): string {
|
|
||||||
return this.raw.title
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Slug of the collectible */
|
|
||||||
get slug(): string {
|
|
||||||
return this.raw.slug
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pattern emoji ID of the collectible */
|
|
||||||
get patternEmojiId(): tl.Long {
|
|
||||||
return this.raw.patternDocumentId
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Colors of the collectible */
|
|
||||||
get colors(): {
|
|
||||||
center: number
|
|
||||||
edge: number
|
|
||||||
pattern: number
|
|
||||||
text: number
|
|
||||||
} {
|
|
||||||
return {
|
|
||||||
center: this.raw.centerColor,
|
|
||||||
edge: this.raw.edgeColor,
|
|
||||||
pattern: this.raw.patternColor,
|
|
||||||
text: this.raw.textColor,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
makeInspectable(EmojiStatusCollectible)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about user's emoji status
|
* Information about user's emoji status
|
||||||
*/
|
*/
|
||||||
export class EmojiStatus {
|
export class EmojiStatus {
|
||||||
constructor(
|
constructor(readonly raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty>) {}
|
||||||
readonly raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty | tl.RawInputEmojiStatusCollectible>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/** ID of the custom emoji */
|
/** ID of the custom emoji */
|
||||||
get emoji(): tl.Long {
|
get emoji(): tl.Long {
|
||||||
|
@ -58,17 +15,10 @@ export class EmojiStatus {
|
||||||
|
|
||||||
/** This status is valid at most until this date */
|
/** This status is valid at most until this date */
|
||||||
get expireDate(): Date | null {
|
get expireDate(): Date | null {
|
||||||
if (!this.raw.until) return null
|
if (this.raw._ === 'emojiStatus') return null
|
||||||
|
|
||||||
return new Date(this.raw.until * 1000)
|
return new Date(this.raw.until * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If this is a collectible emoji status, information about it */
|
|
||||||
get collectible(): EmojiStatusCollectible | null {
|
|
||||||
if (this.raw._ !== 'emojiStatusCollectible') return null
|
|
||||||
|
|
||||||
return new EmojiStatusCollectible(this.raw)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
makeInspectable(EmojiStatus)
|
makeInspectable(EmojiStatus)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
TL schema and related utils used for mtcute.
|
TL schema and related utils used for mtcute.
|
||||||
|
|
||||||
Generated from TL layer **198** (last updated on 25.01.2025).
|
Generated from TL layer **197** (last updated on 22.01.2025).
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +0,0 @@
|
||||||
// LAYER 197
|
|
||||||
starGiftUnique_layer197#3482f322 flags:# id:long title:string slug:string num:int owner_id:flags.0?int53 owner_name:flags.1?string attributes:Vector<StarGiftAttribute> availability_issued:int availability_total:int = StarGift;
|
|
||||||
emojiStatus_layer197#929b619d document_id:long = EmojiStatus;
|
|
||||||
messageMediaDocument_layer197#dd570bd5 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_documents:flags.5?Vector<Document> ttl_seconds:flags.2?int = MessageMedia;
|
|
||||||
channelFull_layer197#9ff3b858 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true id:int53 about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int53 location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<int53> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification = ChatFull;
|
|
||||||
messageActionStarGiftUnique_layer197#26077b99 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long = MessageAction;
|
|
||||||
messageActionStarGift_layer197#d8f4f0a7 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long = MessageAction;
|
|
|
@ -103,6 +103,8 @@
|
||||||
"requestedPeerChat": ["chat_id"],
|
"requestedPeerChat": ["chat_id"],
|
||||||
"requestedPeerUser": ["user_id"],
|
"requestedPeerUser": ["user_id"],
|
||||||
"starRefProgram": ["bot_id"],
|
"starRefProgram": ["bot_id"],
|
||||||
|
"starGiftUnique": ["owner_id"],
|
||||||
|
"starGiftAttributeOriginalDetails": ["sender_id", "recipient_id"],
|
||||||
"secureFile": ["size"],
|
"secureFile": ["size"],
|
||||||
"statsGroupTopAdmin": ["user_id"],
|
"statsGroupTopAdmin": ["user_id"],
|
||||||
"statsGroupTopInviter": ["user_id"],
|
"statsGroupTopInviter": ["user_id"],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mtcute/tl",
|
"name": "@mtcute/tl",
|
||||||
"version": "198.0.0",
|
"version": "197.0.0",
|
||||||
"description": "TL schema used for mtcute",
|
"description": "TL schema used for mtcute",
|
||||||
"author": "alina sireneva <alina@tei.su>",
|
"author": "alina sireneva <alina@tei.su>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -10,7 +10,6 @@ export const API_SCHEMA_DIFF_JSON_FILE: string = join(__dirname, '../diff.json')
|
||||||
export const MTP_SCHEMA_JSON_FILE: string = join(__dirname, '../mtp-schema.json')
|
export const MTP_SCHEMA_JSON_FILE: string = join(__dirname, '../mtp-schema.json')
|
||||||
export const ERRORS_JSON_FILE: string = join(__dirname, '../raw-errors.json')
|
export const ERRORS_JSON_FILE: string = join(__dirname, '../raw-errors.json')
|
||||||
export const APP_CONFIG_JSON_FILE: string = join(__dirname, '../app-config.json')
|
export const APP_CONFIG_JSON_FILE: string = join(__dirname, '../app-config.json')
|
||||||
export const COMPAT_TL_FILE: string = join(__dirname, '../data/compat.tl')
|
|
||||||
|
|
||||||
export const CORE_DOMAIN = 'https://core.telegram.org'
|
export const CORE_DOMAIN = 'https://core.telegram.org'
|
||||||
export const COREFORK_DOMAIN = 'https://corefork.telegram.org'
|
export const COREFORK_DOMAIN = 'https://corefork.telegram.org'
|
||||||
|
@ -29,14 +28,3 @@ export const ESM_PRELUDE = `// This file is auto-generated. Do not edit.
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
`
|
`
|
||||||
|
|
||||||
export const TYPES_FOR_COMPAT: string[] = [
|
|
||||||
'message',
|
|
||||||
'messageService',
|
|
||||||
'channel',
|
|
||||||
'channelFull',
|
|
||||||
'chat',
|
|
||||||
'chatFull',
|
|
||||||
'user',
|
|
||||||
'userFull',
|
|
||||||
]
|
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
import type {
|
import type {
|
||||||
TlEntry,
|
TlEntry,
|
||||||
TlFullSchema,
|
TlFullSchema,
|
||||||
TlSchemaDiff,
|
|
||||||
} from '@mtcute/tl-utils'
|
} from '@mtcute/tl-utils'
|
||||||
import type { TlPackedSchema } from './schema.js'
|
import type { TlPackedSchema } from './schema.js'
|
||||||
import { createWriteStream } from 'node:fs'
|
|
||||||
|
|
||||||
import { readFile, writeFile } from 'node:fs/promises'
|
import { readFile, writeFile } from 'node:fs/promises'
|
||||||
|
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import * as readline from 'node:readline'
|
import * as readline from 'node:readline'
|
||||||
import { ffetchBase as ffetch } from '@fuman/fetch'
|
import { ffetchBase as ffetch } from '@fuman/fetch'
|
||||||
|
@ -23,24 +21,21 @@ import {
|
||||||
mergeTlSchemas,
|
mergeTlSchemas,
|
||||||
parseFullTlSchema,
|
parseFullTlSchema,
|
||||||
parseTlToEntries,
|
parseTlToEntries,
|
||||||
TL_PRIMITIVES,
|
|
||||||
writeTlEntryToString,
|
writeTlEntryToString,
|
||||||
} from '@mtcute/tl-utils'
|
} from '@mtcute/tl-utils'
|
||||||
|
|
||||||
import { parseTlEntriesFromJson } from '@mtcute/tl-utils/json.js'
|
import { parseTlEntriesFromJson } from '@mtcute/tl-utils/json.js'
|
||||||
|
|
||||||
import * as cheerio from 'cheerio'
|
import * as cheerio from 'cheerio'
|
||||||
import {
|
import {
|
||||||
__dirname,
|
__dirname,
|
||||||
API_SCHEMA_DIFF_JSON_FILE,
|
API_SCHEMA_DIFF_JSON_FILE,
|
||||||
API_SCHEMA_JSON_FILE,
|
API_SCHEMA_JSON_FILE,
|
||||||
BLOGFORK_DOMAIN,
|
BLOGFORK_DOMAIN,
|
||||||
COMPAT_TL_FILE,
|
|
||||||
CORE_DOMAIN,
|
CORE_DOMAIN,
|
||||||
COREFORK_DOMAIN,
|
COREFORK_DOMAIN,
|
||||||
TDESKTOP_LAYER,
|
TDESKTOP_LAYER,
|
||||||
TDESKTOP_SCHEMA,
|
TDESKTOP_SCHEMA,
|
||||||
TDLIB_SCHEMA,
|
TDLIB_SCHEMA,
|
||||||
TYPES_FOR_COMPAT,
|
|
||||||
WEBA_LAYER,
|
WEBA_LAYER,
|
||||||
WEBA_SCHEMA,
|
WEBA_SCHEMA,
|
||||||
WEBK_SCHEMA,
|
WEBK_SCHEMA,
|
||||||
|
@ -230,77 +225,6 @@ async function overrideInt53(schema: TlFullSchema): Promise<void> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateCompatSchema(oldLayer: number, oldSchema: TlFullSchema, diff: TlSchemaDiff) {
|
|
||||||
// generate list of all types that need to be added to compat.tl
|
|
||||||
const typesToAdd = new Set<string>()
|
|
||||||
const diffedTypes = new Set<string>()
|
|
||||||
|
|
||||||
for (const { name } of diff.classes.removed) {
|
|
||||||
diffedTypes.add(name)
|
|
||||||
}
|
|
||||||
for (const { name, id } of diff.classes.modified) {
|
|
||||||
if (id && id.old !== id.new) {
|
|
||||||
// no point in adding this type if there wasn't a change in constructor ID
|
|
||||||
diffedTypes.add(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const processedTypes = new Set<string>()
|
|
||||||
const queue = [...TYPES_FOR_COMPAT]
|
|
||||||
|
|
||||||
while (queue.length) {
|
|
||||||
const it = queue.pop()!
|
|
||||||
processedTypes.add(it)
|
|
||||||
|
|
||||||
const entry = oldSchema.classes[it]
|
|
||||||
if (!entry) {
|
|
||||||
console.log(`[warn] Cannot find ${it} in old schema`)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diffedTypes.has(it)) {
|
|
||||||
typesToAdd.add(it)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const arg of entry.arguments) {
|
|
||||||
const type = arg.type
|
|
||||||
if (type in TL_PRIMITIVES || type === '#') continue
|
|
||||||
|
|
||||||
const typeEntry = oldSchema.unions[type]
|
|
||||||
if (!typeEntry) {
|
|
||||||
console.log(`[warn] Cannot find ${type} in old schema`)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const { name } of typeEntry.classes) {
|
|
||||||
if (!processedTypes.has(name)) {
|
|
||||||
queue.push(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const compatWs = createWriteStream(COMPAT_TL_FILE, { flags: 'a' })
|
|
||||||
compatWs.write(`// LAYER ${oldLayer}\n`)
|
|
||||||
for (const type of typesToAdd) {
|
|
||||||
const entry = oldSchema.classes[type]
|
|
||||||
if (!entry) {
|
|
||||||
console.log(`[warn] Cannot find ${type} in old schema`)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const entryMod: TlEntry = {
|
|
||||||
...entry,
|
|
||||||
name: `${entry.name}_layer${oldLayer}`,
|
|
||||||
}
|
|
||||||
|
|
||||||
compatWs.write(`${writeTlEntryToString(entryMod)}\n`)
|
|
||||||
}
|
|
||||||
|
|
||||||
compatWs.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('Loading schemas...')
|
console.log('Loading schemas...')
|
||||||
|
|
||||||
|
@ -427,22 +351,18 @@ async function main() {
|
||||||
|
|
||||||
console.log('Writing diff to file...')
|
console.log('Writing diff to file...')
|
||||||
const oldSchema = unpackTlSchema(JSON.parse(await readFile(API_SCHEMA_JSON_FILE, 'utf8')) as TlPackedSchema)
|
const oldSchema = unpackTlSchema(JSON.parse(await readFile(API_SCHEMA_JSON_FILE, 'utf8')) as TlPackedSchema)
|
||||||
const diff = generateTlSchemasDifference(oldSchema[0], resultSchema)
|
|
||||||
await writeFile(
|
await writeFile(
|
||||||
API_SCHEMA_DIFF_JSON_FILE,
|
API_SCHEMA_DIFF_JSON_FILE,
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
{
|
{
|
||||||
layer: [oldSchema[1], resultLayer],
|
layer: [oldSchema[1], resultLayer],
|
||||||
diff,
|
diff: generateTlSchemasDifference(oldSchema[0], resultSchema),
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
4,
|
4,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log('Generating compat.tl...')
|
|
||||||
await generateCompatSchema(oldSchema[1], oldSchema[0], diff)
|
|
||||||
|
|
||||||
console.log('Writing result to file...')
|
console.log('Writing result to file...')
|
||||||
await writeFile(API_SCHEMA_JSON_FILE, JSON.stringify(packTlSchema(resultSchema, resultLayer)))
|
await writeFile(API_SCHEMA_JSON_FILE, JSON.stringify(packTlSchema(resultSchema, resultLayer)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue