feat: bumped to layer 194

This commit is contained in:
alina 🌸 2024-11-20 21:25:32 +03:00
parent 439f50bc50
commit 73a3f64fc3
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
21 changed files with 617 additions and 130 deletions

View file

@ -13,7 +13,7 @@ import type { BaseTelegramClientOptions } from './base.js'
import { BaseTelegramClient } from './base.js'
import type { ITelegramClient } from './client.types.js'
import type { RawUpdateInfo } from './updates/types.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, ChatMember, ChatMemberUpdate, ChatPreview, ChatlistPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerSourceType, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadFileLike, UploadedFile, User, UserStatusUpdate, UserTypingUpdate } 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, ChatMember, ChatMemberUpdate, ChatPreview, ChatlistPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStickerSet, InputStickerSetItem, InputText, 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, UploadFileLike, UploadedFile, User, UserStarGift, UserStatusUpdate, UserTypingUpdate } from './types/index.js'
import type { StringSessionData } from './utils/string-session.js'
import type { ITelegramStorageProvider } from './storage/provider.js'
import { Conversation } from './types/conversation.js'
@ -43,11 +43,13 @@ import { getBotMenuButton } from './methods/bots/get-bot-menu-button.js'
import { getCallbackAnswer } from './methods/bots/get-callback-answer.js'
import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores.js'
import { getMyCommands } from './methods/bots/get-my-commands.js'
import { prepareInlineMessage } from './methods/bots/prepare-inline-message.js'
import { setBotInfo } from './methods/bots/set-bot-info.js'
import { setBotMenuButton } from './methods/bots/set-bot-menu-button.js'
import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score.js'
import { setMyCommands } from './methods/bots/set-my-commands.js'
import { setMyDefaultRights } from './methods/bots/set-my-default-rights.js'
import { toggleEmojiStatusPermission } from './methods/bots/toggle-emoji-status-permission.js'
import { addChatMembers } from './methods/chats/add-chat-members.js'
import { archiveChats } from './methods/chats/archive-chats.js'
import { banChatMember } from './methods/chats/ban-chat-member.js'
@ -206,6 +208,7 @@ import { changeCloudPassword } from './methods/password/change-cloud-password.js
import { enableCloudPassword } from './methods/password/enable-cloud-password.js'
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email.js'
import { removeCloudPassword } from './methods/password/remove-cloud-password.js'
import { acceptStarGift } from './methods/premium/accept-star-gift.js'
import { applyBoost } from './methods/premium/apply-boost.js'
import type { CanApplyBoostResult } from './methods/premium/can-apply-boost.js'
import { canApplyBoost } from './methods/premium/can-apply-boost.js'
@ -216,9 +219,13 @@ import { getBoosts } from './methods/premium/get-boosts.js'
import { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js'
import { getBusinessConnection } from './methods/premium/get-business-connection.js'
import { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
import { getStarGiftOptions } from './methods/premium/get-star-gift-options.js'
import { getStarGifts } from './methods/premium/get-star-gifts.js'
import { getStarsTransactions } from './methods/premium/get-stars-transactions.js'
import { iterBoosters } from './methods/premium/iter-boosters.js'
import { iterStarGifts } from './methods/premium/iter-star-gifts.js'
import { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
import { sendStarGift } from './methods/premium/send-star-gift.js'
import { setBusinessIntro } from './methods/premium/set-business-intro.js'
import { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js'
import { addStickerToSet } from './methods/stickers/add-sticker-to-set.js'
@ -249,7 +256,6 @@ import { iterAllStories } from './methods/stories/iter-all-stories.js'
import { iterProfileStories } from './methods/stories/iter-profile-stories.js'
import { iterStoryViewers } from './methods/stories/iter-story-viewers.js'
import { readStories } from './methods/stories/read-stories.js'
import { reportStory } from './methods/stories/report-story.js'
import { sendStoryReaction } from './methods/stories/send-story-reaction.js'
import { sendStory } from './methods/stories/send-story.js'
import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived.js'
@ -268,9 +274,9 @@ import { isPeerAvailable } from './methods/users/is-peer-available.js'
import { iterProfilePhotos } from './methods/users/iter-profile-photos.js'
import { resolvePeerMany } from './methods/users/resolve-peer-many.js'
import { resolveChannel, resolvePeer, resolveUser } from './methods/users/resolve-peer.js'
import { setEmojiStatus, setMyEmojiStatus } from './methods/users/set-emoji-status.js'
import { setGlobalTtl } from './methods/users/set-global-ttl.js'
import { setMyBirthday } from './methods/users/set-my-birthday.js'
import { setMyEmojiStatus } from './methods/users/set-my-emoji-status.js'
import { setMyProfilePhoto } from './methods/users/set-my-profile-photo.js'
import { setMyUsername } from './methods/users/set-my-username.js'
import { setOffline } from './methods/users/set-offline.js'
@ -981,6 +987,26 @@ export interface TelegramClient extends ITelegramClient {
*/
langCode?: string
}): Promise<tl.RawBotCommand[]>
/**
* Prepare an inline message result to be sent later via the
* `shareMessage` [mini-app api method](https://core.telegram.org/bots/webapps#initializing-mini-apps).
*/
prepareInlineMessage(
params: {
userId: InputPeerLike
result: InputInlineResult
filter?: tl.TypeInlineQueryPeerType[] | {
/** private chat with the bot itself */
botSelf?: boolean
/** private chats */
private?: boolean
/** private chats with other bots */
bots?: boolean
chats?: boolean
supergroups?: boolean
channels?: boolean
}
}): Promise<tl.messages.TypeBotPreparedInlineMessage>
/**
* Sets information about a bot the current uzer owns (or the current bot)
* **Available**: both users and bots
@ -1119,6 +1145,16 @@ export interface TelegramClient extends ITelegramClient {
/** The default chat permissions. */
rights: Omit<tl.RawChatAdminRights, '_'>
}): Promise<void>
/**
* Give or revoke permission for a bot to update emoji status for your account
*/
toggleEmojiStatusPermission(
params: {
/** Bot to which the permission should be granted/revoked */
userId: InputPeerLike
/** Whether to grant or revoke permission */
allow: boolean
}): Promise<void>
/**
* Add one or more new members to a group, supergroup or channel.
*
@ -2423,6 +2459,15 @@ export interface TelegramClient extends ITelegramClient {
* the stream will be buffered in memory and the file size will be inferred from the buffer.
*/
requireFileSize?: boolean
/**
* When using `inputMediaUploadedPhoto` (e.g. when sending an uploaded photo) require
* the file extension to be known beforehand.
*
* This will make the library try to guess the file extension from the file mime type,
* or throw an error if it cannot be guessed.
*/
requireExtension?: boolean
}): Promise<UploadedFile>
/**
* Upload a media to Telegram servers, without actually
@ -2728,6 +2773,13 @@ export interface TelegramClient extends ITelegramClient {
* approved by an admin
*/
withApproval?: boolean
/**
* When a pricing plan is passed, this link will become a paid subscription link
*
* Currently the only allowed `.period` is 1 month, i.e. `2592000`
*/
subscriptionPricing?: tl.TypeStarsSubscriptionPricing
}): Promise<ChatInviteLink>
/**
* Edit an invite link. You can only edit non-primary
@ -3212,13 +3264,13 @@ export interface TelegramClient extends ITelegramClient {
*/
getCallbackQueryMessage(
id:
| CallbackQuery
| tl.RawUpdateBotCallbackQuery
| {
messageId: number
queryId: tl.Long
peer: InputPeerLike
}): Promise<Message | null>
| CallbackQuery
| tl.RawUpdateBotCallbackQuery
| {
messageId: number
queryId: tl.Long
peer: InputPeerLike
}): Promise<Message | null>
// public version of the same method because why not
/**
* Get discussion message for some channel post.
@ -3890,14 +3942,14 @@ export interface TelegramClient extends ITelegramClient {
*/
sendCopyGroup(
params: SendCopyGroupParams &
(
| {
(
| {
/** Source chat ID */
fromChatId: InputPeerLike
/** Message IDs to forward */
messages: number[]
}
| { messages: Message[] }
fromChatId: InputPeerLike
/** Message IDs to forward */
messages: number[]
}
| { messages: Message[] }
)): Promise<Message[]>
/**
* Copy a message (i.e. send the same message, but do not forward it).
@ -3911,14 +3963,14 @@ export interface TelegramClient extends ITelegramClient {
*/
sendCopy(
params: SendCopyParams &
(
| {
(
| {
/** Source chat ID */
fromChatId: InputPeerLike
/** Message ID to forward */
message: number
}
| { message: Message }
fromChatId: InputPeerLike
/** Message ID to forward */
message: number
}
| { message: Message }
)): Promise<Message>
/**
* Send a group of media.
@ -4325,6 +4377,24 @@ export interface TelegramClient extends ITelegramClient {
* @param password 2FA password as plaintext
*/
removeCloudPassword(password: string): Promise<void>
/**
* Accept, hide or convert a star gift.
*
* **Available**: 👤 users only
*
* @returns Whether the action was successful
*/
acceptStarGift(
params: InputMessageId & {
/**
* Action to perform on the gift.
* - `save` - save the gift to your profile
* - `hide` - hide the gift from your profile
* - `convert` - convert the gift to stars (can't be undone)
*/
action: 'save' | 'hide' | 'convert'
}): Promise<boolean>
/**
* Boost a given channel
*
@ -4442,6 +4512,37 @@ export interface TelegramClient extends ITelegramClient {
*
*/
getMyBoostSlots(): Promise<BoostSlot[]>
/**
* Get the list of available star gifts.
* **Available**: 👤 users only
*
*/
getStarGiftOptions(): Promise<StarGift[]>
/**
* Get a list of gifts sent to a user.
*
* **Available**: 👤 users only
*
* @param userId User whose gifts to fetch
* @returns Gifts sent to the user
*/
getStarGifts(
userId: InputPeerLike,
params?: {
/**
* Offset for pagination.
*/
offset?: string
/**
* Maximum number of gifts to fetch.
*
* @default 100
*/
limit?: number
}): Promise<ArrayPaginated<UserStarGift, string>>
/**
* Get Telegram Stars transactions for a given peer.
*
@ -4502,6 +4603,35 @@ export interface TelegramClient extends ITelegramClient {
*/
chunkSize?: number
}): AsyncIterableIterator<Boost>
/**
* Iterate over gifts sent to a given user.
*
* Wrapper over {@link getStarGifts}
*
* **Available**: 👤 users only
*
* @param peerId Peer ID
* @param params Additional parameters
*/
iterStarGifts(
peerId: InputPeerLike,
params?: Parameters<typeof getStarGifts>[2] & {
/**
* Total number of gifts to fetch
*
* @default Infinity, i.e. fetch all gifts
*/
limit?: number
/**
* Number of gifts to fetch per request
* Usually you don't need to change this
*
* @default 100
*/
chunkSize?: number
}): AsyncIterableIterator<UserStarGift>
/**
* Iterate over Telegram Stars transactions for a given peer.
*
@ -4533,6 +4663,42 @@ export interface TelegramClient extends ITelegramClient {
*/
chunkSize?: number
}): AsyncIterableIterator<StarsTransaction>
/**
* Send a star gift to a user.
*
* > **Note**: this method is not indended to be used by full-fledged clients,
* > as this method hides the actual invoice and payment form from the user.
* > For GUI clients, you should refer to the method's source code and
* > present the payment form to the user.
*
* **Available**: 👤 users only
*
* @returns Service message about the sent gift
*/
sendStarGift(
params: {
/** ID of the user to send the gift to */
userId: InputPeerLike
/** ID of the gift to send */
gift: Long | StarGift
/**
* Whether to send the gift anonymously
* (i.e. if the recipient chooses to display the gift
* on their profile, your name won't be visible)
*/
anonymous?: boolean
/** Message to send along with the gift */
message?: InputText
/**
* Whether to dispatch the new message event
* to the client's update handler.
*/
shouldDispatch?: true
}): Promise<Message>
/**
* Set current user's business introduction.
@ -4645,13 +4811,6 @@ export interface TelegramClient extends ITelegramClient {
*/
type?: StickerType
/**
* File source type for the stickers in this set.
*
* @default `static`, i.e. regular WEBP stickers.
*/
sourceType?: StickerSourceType
/**
* Whether to create "adaptive" emoji set.
*
@ -5141,27 +5300,6 @@ export interface TelegramClient extends ITelegramClient {
* @returns IDs of the stores that were marked as read
*/
readStories(peerId: InputPeerLike, maxId: number): Promise<number[]>
/**
* Report a story (or multiple stories) to the moderation team
* **Available**: 👤 users only
*
*/
reportStory(
peerId: InputPeerLike,
storyIds: MaybeArray<number>,
params?: {
/**
* Reason for reporting
*
* @default inputReportReasonSpam
*/
reason?: tl.TypeReportReason
/**
* Additional comment to the report
*/
message?: string
}): Promise<void>
/**
* Send (or remove) a reaction to a story
* **Available**: 👤 users only
@ -5480,6 +5618,40 @@ export interface TelegramClient extends ITelegramClient {
*/
resolveChannel(
peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputChannel>
/**
* Set an emoji status for the current user
*
* **Available**: both users and bots
*
* @deprecated use {@link setEmojiStatus} with `self` instead
*/
setMyEmojiStatus(
emoji: tl.Long | null,
params?: {
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
}): Promise<void>
/**
* Set an emoji status for the given user/chat
*
* You can change emoji status of:
* - yourself (`self`)
* - supergroups or channels with enough boosts which you are an admin of
* - for bots users who gave you the appropriate permissions
*/
setEmojiStatus(
params: {
/** User or chat where the emoji status should be set */
peerId: InputPeerLike
/** Custom emoji ID or `null` to remove the emoji */
emoji: tl.Long | null
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
}): Promise<void>
/**
* Changes the current default value of the Time-To-Live setting,
* applied to all new chats.
@ -5504,21 +5676,6 @@ export interface TelegramClient extends ITelegramClient {
/** Birthday year (optional) */
year?: number
} | null): Promise<void>
/**
* Set an emoji status for the current user
*
* **Available**: 👤 users only
*
* @param emoji Custom emoji ID or `null` to remove the emoji
*/
setMyEmojiStatus(
emoji: tl.Long | null,
params?: {
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
}): Promise<void>
/**
* Set a new profile photo or video for the current user.
*
@ -5646,6 +5803,7 @@ export class TelegramClient implements ITelegramClient {
Object.defineProperty(this, 'onServerUpdate', { value: this._client.onServerUpdate })
Object.defineProperty(this, 'onRawUpdate', { value: this._client.onServerUpdate })
Object.defineProperty(this, 'onConnectionState', { value: this._client.onConnectionState })
Object.defineProperty(this, 'onError', { value: this._client.onError })
if (!opts.disableUpdates) {
const skipConversationUpdates = opts.skipConversationUpdates ?? true
@ -5826,6 +5984,9 @@ TelegramClient.prototype.getInlineGameHighScores = function (...args) {
TelegramClient.prototype.getMyCommands = function (...args) {
return getMyCommands(this._client, ...args)
}
TelegramClient.prototype.prepareInlineMessage = function (...args) {
return prepareInlineMessage(this._client, ...args)
}
TelegramClient.prototype.setBotInfo = function (...args) {
return setBotInfo(this._client, ...args)
}
@ -5844,6 +6005,9 @@ TelegramClient.prototype.setMyCommands = function (...args) {
TelegramClient.prototype.setMyDefaultRights = function (...args) {
return setMyDefaultRights(this._client, ...args)
}
TelegramClient.prototype.toggleEmojiStatusPermission = function (...args) {
return toggleEmojiStatusPermission(this._client, ...args)
}
TelegramClient.prototype.addChatMembers = function (...args) {
return addChatMembers(this._client, ...args)
}
@ -6327,6 +6491,9 @@ TelegramClient.prototype.cancelPasswordEmail = function (...args) {
TelegramClient.prototype.removeCloudPassword = function (...args) {
return removeCloudPassword(this._client, ...args)
}
TelegramClient.prototype.acceptStarGift = function (...args) {
return acceptStarGift(this._client, ...args)
}
TelegramClient.prototype.applyBoost = function (...args) {
return applyBoost(this._client, ...args)
}
@ -6357,15 +6524,27 @@ TelegramClient.prototype.getBusinessConnection = function (...args) {
TelegramClient.prototype.getMyBoostSlots = function (...args) {
return getMyBoostSlots(this._client, ...args)
}
TelegramClient.prototype.getStarGiftOptions = function (...args) {
return getStarGiftOptions(this._client, ...args)
}
TelegramClient.prototype.getStarGifts = function (...args) {
return getStarGifts(this._client, ...args)
}
TelegramClient.prototype.getStarsTransactions = function (...args) {
return getStarsTransactions(this._client, ...args)
}
TelegramClient.prototype.iterBoosters = function (...args) {
return iterBoosters(this._client, ...args)
}
TelegramClient.prototype.iterStarGifts = function (...args) {
return iterStarGifts(this._client, ...args)
}
TelegramClient.prototype.iterStarsTransactions = function (...args) {
return iterStarsTransactions(this._client, ...args)
}
TelegramClient.prototype.sendStarGift = function (...args) {
return sendStarGift(this._client, ...args)
}
TelegramClient.prototype.setBusinessIntro = function (...args) {
return setBusinessIntro(this._client, ...args)
}
@ -6456,9 +6635,6 @@ TelegramClient.prototype.iterStoryViewers = function (...args) {
TelegramClient.prototype.readStories = function (...args) {
return readStories(this._client, ...args)
}
TelegramClient.prototype.reportStory = function (...args) {
return reportStory(this._client, ...args)
}
TelegramClient.prototype.sendStoryReaction = function (...args) {
return sendStoryReaction(this._client, ...args)
}
@ -6524,15 +6700,18 @@ TelegramClient.prototype.resolveUser = function (...args) {
TelegramClient.prototype.resolveChannel = function (...args) {
return resolveChannel(this._client, ...args)
}
TelegramClient.prototype.setMyEmojiStatus = function (...args) {
return setMyEmojiStatus(this._client, ...args)
}
TelegramClient.prototype.setEmojiStatus = function (...args) {
return setEmojiStatus(this._client, ...args)
}
TelegramClient.prototype.setGlobalTtl = function (...args) {
return setGlobalTtl(this._client, ...args)
}
TelegramClient.prototype.setMyBirthday = function (...args) {
return setMyBirthday(this._client, ...args)
}
TelegramClient.prototype.setMyEmojiStatus = function (...args) {
return setMyEmojiStatus(this._client, ...args)
}
TelegramClient.prototype.setMyProfilePhoto = function (...args) {
return setMyProfilePhoto(this._client, ...args)
}

View file

@ -24,12 +24,14 @@ export { getCallbackAnswer } from './methods/bots/get-callback-answer.js'
export { getGameHighScores } from './methods/bots/get-game-high-scores.js'
export { getInlineGameHighScores } from './methods/bots/get-game-high-scores.js'
export { getMyCommands } from './methods/bots/get-my-commands.js'
export { prepareInlineMessage } from './methods/bots/prepare-inline-message.js'
export { setBotInfo } from './methods/bots/set-bot-info.js'
export { setBotMenuButton } from './methods/bots/set-bot-menu-button.js'
export { setGameScore } from './methods/bots/set-game-score.js'
export { setInlineGameScore } from './methods/bots/set-game-score.js'
export { setMyCommands } from './methods/bots/set-my-commands.js'
export { setMyDefaultRights } from './methods/bots/set-my-default-rights.js'
export { toggleEmojiStatusPermission } from './methods/bots/toggle-emoji-status-permission.js'
export { addChatMembers } from './methods/chats/add-chat-members.js'
export { archiveChats } from './methods/chats/archive-chats.js'
export { banChatMember } from './methods/chats/ban-chat-member.js'
@ -273,9 +275,10 @@ export { resolvePeerMany } from './methods/users/resolve-peer-many.js'
export { resolvePeer } from './methods/users/resolve-peer.js'
export { resolveUser } from './methods/users/resolve-peer.js'
export { resolveChannel } from './methods/users/resolve-peer.js'
export { setMyEmojiStatus } from './methods/users/set-emoji-status.js'
export { setEmojiStatus } from './methods/users/set-emoji-status.js'
export { setGlobalTtl } from './methods/users/set-global-ttl.js'
export { setMyBirthday } from './methods/users/set-my-birthday.js'
export { setMyEmojiStatus } from './methods/users/set-my-emoji-status.js'
export { setMyProfilePhoto } from './methods/users/set-my-profile-photo.js'
export { setMyUsername } from './methods/users/set-my-username.js'
export { setOffline } from './methods/users/set-offline.js'

View file

@ -0,0 +1,86 @@
import type { tl } from '@mtcute/tl'
import { objectKeys } from '@fuman/utils'
import type { ITelegramClient } from '../../client.types.js'
import type { InputInlineResult } from '../../types/bots/inline-result/types.js'
import { BotInline, type InputPeerLike } from '../../types/index.js'
import { assertNever } from '../../../types/utils.js'
import { resolveUser } from '../users/resolve-peer.js'
/**
* Prepare an inline message result to be sent later via the
* `shareMessage` [mini-app api method](https://core.telegram.org/bots/webapps#initializing-mini-apps).
*/
export async function prepareInlineMessage(
client: ITelegramClient,
params: {
userId: InputPeerLike
result: InputInlineResult
/**
* Filters for the client to use when prompting the user for the
* chat to send the inline message to.
*
* Note that this is just a hint for the client, and the client is free to ignore it.
*/
filter?: tl.TypeInlineQueryPeerType[] | {
/** private chat with the bot itself */
botSelf?: boolean
/** private chats */
private?: boolean
/** private chats with other bots */
bots?: boolean
/** "basic" chats */
chats?: boolean
/** supergroups */
supergroups?: boolean
/** broadcast channels */
channels?: boolean
}
},
): Promise<tl.messages.TypeBotPreparedInlineMessage> {
let peerTypes: tl.TypeInlineQueryPeerType[] | undefined
if (params.filter) {
if (Array.isArray(params.filter)) {
peerTypes = params.filter
} else {
peerTypes = []
for (const key of objectKeys(params.filter)) {
if (!params.filter[key]) continue
switch (key) {
case 'botSelf':
peerTypes.push({ _: 'inlineQueryPeerTypeBotPM' })
break
case 'private':
peerTypes.push({ _: 'inlineQueryPeerTypePM' })
break
case 'bots':
peerTypes.push({ _: 'inlineQueryPeerTypeBroadcast' })
break
case 'chats':
peerTypes.push({ _: 'inlineQueryPeerTypeChat' })
break
case 'supergroups':
peerTypes.push({ _: 'inlineQueryPeerTypeMegagroup' })
break
case 'channels':
peerTypes.push({ _: 'inlineQueryPeerTypeBroadcast' })
break
default:
assertNever(key)
}
}
}
}
const [, tlResult] = await BotInline._convertToTl(client, [params.result])
return client.call({
_: 'messages.savePreparedInlineMessage',
userId: await resolveUser(client, params.userId),
result: tlResult[0],
peerTypes,
})
}

View file

@ -0,0 +1,30 @@
import { assertTrue } from '../../../utils/type-assertions.js'
import type { ITelegramClient } from '../../client.types.js'
import type { InputPeerLike } from '../../types/index.js'
import { resolveUser } from '../users/resolve-peer.js'
/**
* Give or revoke permission for a bot to update emoji status for your account
*/
export async function toggleEmojiStatusPermission(
client: ITelegramClient,
params: {
/** Bot to which the permission should be granted/revoked */
userId: InputPeerLike
/** Whether to grant or revoke permission */
allow: boolean
},
): Promise<void> {
const {
userId,
allow,
} = params
const r = await client.call({
_: 'bots.toggleUserEmojiStatusPermission',
bot: await resolveUser(client, userId),
enabled: allow,
})
assertTrue('bots.toggleUserEmojiStatusPermission', r)
}

View file

@ -1,3 +1,5 @@
import type { tl } from '@mtcute/tl'
import type { ITelegramClient } from '../../client.types.js'
import type { InputPeerLike } from '../../types/index.js'
import { ChatInviteLink } from '../../types/index.js'
@ -37,6 +39,13 @@ export async function createInviteLink(
* approved by an admin
*/
withApproval?: boolean
/**
* When a pricing plan is passed, this link will become a paid subscription link
*
* Currently the only allowed `.period` is 1 month, i.e. `2592000`
*/
subscriptionPricing?: tl.TypeStarsSubscriptionPricing
},
): Promise<ChatInviteLink> {
if (!params) params = {}
@ -47,6 +56,7 @@ export async function createInviteLink(
expireDate: normalizeDate(params.expires),
usageLimit: params.usageLimit,
requestNeeded: params.withApproval,
subscriptionPricing: params.subscriptionPricing,
})
return new ChatInviteLink(res)

View file

@ -70,6 +70,13 @@ export interface ForwardMessageOptions {
* to the client's update handler.
*/
shouldDispatch?: true
/**
* Bots only: if set, allows sending up to 1000 messages per second,
* ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
* The Stars will be withdrawn from the bot's balance.
*/
allowPaidFloodskip?: boolean
}
/**
@ -91,7 +98,18 @@ export async function forwardMessagesById(
messages: number[]
},
): Promise<Message[]> {
const { messages, toChatId, fromChatId, silent, schedule, forbidForwards, sendAs, noAuthor, noCaption } = params
const {
messages,
toChatId,
fromChatId,
silent,
schedule,
forbidForwards,
sendAs,
noAuthor,
noCaption,
allowPaidFloodskip,
} = params
// sending more than 100 will not result in a server-sent
// error, instead only first 100 IDs will be forwarded,
@ -115,6 +133,7 @@ export async function forwardMessagesById(
noforwards: forbidForwards,
sendAs: sendAs ? await resolvePeer(client, sendAs) : undefined,
quickReplyShortcut: _normalizeQuickReplyShortcut(params.quickReply),
allowPaidFloodskip,
})
assertIsUpdatesGroup('messages.forwardMessages', res)

View file

@ -118,6 +118,13 @@ export interface CommonSendParams {
*/
businessConnectionId?: string
/**
* Bots only: if set, allows sending up to 1000 messages per second,
* ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
* The Stars will be withdrawn from the bot's balance.
*/
allowPaidFloodskip?: boolean
/**
* ID of a message effect to use when sending the message
* (see {@link TelegramClient.getAvailableMessageEffects})

View file

@ -117,6 +117,7 @@ export async function sendMediaGroup(
invertMedia: params.invertMedia,
quickReplyShortcut,
effect: params.effect,
allowPaidFloodskip: params.allowPaidFloodskip,
},
{ chainId },
)

View file

@ -113,6 +113,7 @@ export async function sendMedia(
invertMedia: params.invert,
quickReplyShortcut,
effect: params.effect,
allowPaidFloodskip: params.allowPaidFloodskip,
},
{ chainId },
)

View file

@ -85,6 +85,7 @@ export async function sendText(
invertMedia: params.invertMedia,
quickReplyShortcut,
effect: params.effect,
allowPaidFloodskip: params.allowPaidFloodskip,
},
{ chainId },
)

View file

@ -0,0 +1,106 @@
import type { tl } from '@mtcute/tl'
import { assertTrue } from '../../../utils/type-assertions.js'
import type { ITelegramClient } from '../../client.types.js'
import { isInputPeerChannel, isInputPeerUser, normalizeDate, toInputChannel, toInputUser } from '../../utils/index.js'
import type { InputPeerLike } from '../../types/peers/peer.js'
import { isSelfPeer } from '../auth/utils.js'
import { MtInvalidPeerTypeError } from '../../types/errors.js'
import { resolvePeer } from './resolve-peer.js'
/**
* Set an emoji status for the current user
*
* @deprecated use {@link setEmojiStatus} with `self` instead
*/
export async function setMyEmojiStatus(
client: ITelegramClient,
emoji: tl.Long | null,
params?: {
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
},
): Promise<void> {
return setEmojiStatus(client, {
peerId: 'self',
emoji,
until: params?.until,
})
}
/**
* Set an emoji status for the given user/chat
*
* You can change emoji status of:
* - yourself (`self`)
* - supergroups or channels with enough boosts which you are an admin of
* - for bots users who gave you the appropriate permissions
*/
export async function setEmojiStatus(
client: ITelegramClient,
params: {
/** User or chat where the emoji status should be set */
peerId: InputPeerLike
/** Custom emoji ID or `null` to remove the emoji */
emoji: tl.Long | null
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
},
): Promise<void> {
const {
peerId,
emoji,
until,
} = params
const peer = await resolvePeer(client, peerId)
let emojiStatus: tl.TypeEmojiStatus
if (emoji === null) {
emojiStatus = { _: 'emojiStatusEmpty' }
} else if (until) {
emojiStatus = {
_: 'emojiStatusUntil',
documentId: emoji,
until: normalizeDate(until),
}
} else {
emojiStatus = {
_: 'emojiStatus',
documentId: emoji,
}
}
if (isSelfPeer(client, peer)) {
const r = await client.call({
_: 'account.updateEmojiStatus',
emojiStatus,
})
assertTrue('account.updateEmojiStatus', r)
} else if (isInputPeerChannel(peer)) {
const r = await client.call({
_: 'channels.updateEmojiStatus',
channel: toInputChannel(peer),
emojiStatus,
})
client.handleClientUpdate(r)
} else if (isInputPeerUser(peer)) {
const r = await client.call({
_: 'bots.updateUserEmojiStatus',
userId: toInputUser(peer),
emojiStatus,
})
assertTrue('bots.updateUserEmojiStatus', r)
} else {
throw new MtInvalidPeerTypeError(peerId, 'user or channel')
}
}

View file

@ -1,47 +0,0 @@
import type { tl } from '@mtcute/tl'
import { assertTrue } from '../../../utils/type-assertions.js'
import type { ITelegramClient } from '../../client.types.js'
import { normalizeDate } from '../../utils/index.js'
/**
* Set an emoji status for the current user
*
* @param emoji Custom emoji ID or `null` to remove the emoji
*/
export async function setMyEmojiStatus(
client: ITelegramClient,
emoji: tl.Long | null,
params?: {
/**
* Date when the emoji status should expire (only if `emoji` is not `null`)
*/
until?: number | Date
},
): Promise<void> {
const { until } = params ?? {}
let emojiStatus: tl.TypeEmojiStatus
if (emoji === null) {
emojiStatus = { _: 'emojiStatusEmpty' }
} else if (until) {
emojiStatus = {
_: 'emojiStatusUntil',
documentId: emoji,
until: normalizeDate(until),
}
} else {
emojiStatus = {
_: 'emojiStatus',
documentId: emoji,
}
}
const r = await client.call({
_: 'account.updateEmojiStatus',
emojiStatus,
})
assertTrue('account.updateEmojiStatus', r)
}

View file

@ -1,4 +1,5 @@
import type { tl } from '@mtcute/tl'
import Long from 'long'
import { getMarkedPeerId } from '../../../utils/peer-utils.js'
import type { CallDiscardReason } from '../calls/index.js'
@ -162,6 +163,9 @@ export interface ActionPaymentReceived {
/** Payment provider ID */
readonly charge?: tl.TypePaymentCharge
/** If this is a subscription being bought, the date when the subscription will expire */
readonly subscriptionUntilDate?: Date
}
/** A payment was sent to a user */
@ -177,6 +181,9 @@ export interface ActionPaymentSent {
* `US$ 1.45`, `amount = 145`
*/
readonly amount: tl.Long
/** If this is a subscription being bought, the date when the subscription will expire */
readonly subscriptionUntilDate?: Date
}
/** A phone call */
@ -368,6 +375,9 @@ export interface ActionPremiumGifted {
/** Price in the smallest units */
amount: number
}
/** Message attached to the gift */
message?: TextWithEntities
}
/** A photo has been suggested as a profile photo */
@ -433,6 +443,9 @@ export interface ActionGiftCode {
/** Information about the gift code */
raw: tl.RawMessageActionGiftCode
/** Message attached to the gift */
message?: TextWithEntities
}
/** A Telergam Premium giveaway was started */
@ -530,7 +543,10 @@ export interface ActionStarGift {
saved: boolean
/** Whether this gift was converted to stars */
converted: boolean
/** Amount of stars the gift can be converted to by the recipient */
/**
* Amount of stars the gift can be converted to by the recipient
* (0 if the gift cannot be converted)
*/
convertStars: tl.Long
/** The gift itself */
gift: StarGift
@ -679,12 +695,20 @@ export function _messageActionFromTl(this: Message, act: tl.TypeMessageAction):
info: act.info,
shippingOptionId: act.shippingOptionId,
charge: act.charge,
subscriptionUntilDate:
act.subscriptionUntilDate
? new Date(act.subscriptionUntilDate * 1000)
: undefined,
}
case 'messageActionPaymentSent':
return {
type: 'payment_sent',
currency: act.currency,
amount: act.totalAmount,
subscriptionUntilDate:
act.subscriptionUntilDate
? new Date(act.subscriptionUntilDate * 1000)
: undefined,
}
case 'messageActionPhoneCall':
return {
@ -797,6 +821,7 @@ export function _messageActionFromTl(this: Message, act: tl.TypeMessageAction):
amount: act.cryptoAmount.toNumber(),
}
: undefined,
message: act.message,
}
case 'messageActionSuggestProfilePhoto':
return {
@ -826,6 +851,7 @@ export function _messageActionFromTl(this: Message, act: tl.TypeMessageAction):
return {
type: 'gift_code',
raw: act,
message: act.message,
}
case 'messageActionGiveawayLaunch':
return {
@ -875,7 +901,7 @@ export function _messageActionFromTl(this: Message, act: tl.TypeMessageAction):
nameHidden: act.nameHidden!,
saved: act.saved!,
converted: act.converted!,
convertStars: act.convertStars,
convertStars: act.convertStars ?? Long.ZERO,
gift: new StarGift(act.gift),
message: act.message ?? null,
}

View file

@ -498,6 +498,11 @@ export class Message {
return this.raw.effect ?? null
}
/** Whether this message has a video that is still being processed */
get videoProcessingPending(): boolean {
return this.raw._ === 'message' && this.raw.videoProcessingPending!
}
/**
* Generated permalink to this message, only for groups and channels
*

View file

@ -201,9 +201,26 @@ export class FullChat extends Chat {
return this.fullPeer?.boostsUnrestrict ?? 0
}
/** Number of star gifts the user has chosen to display on their profile */
get starGiftsCount(): number {
if (this.fullPeer._ !== 'userFull') return 0
return this.fullPeer?.stargiftsCount ?? 0
}
/** Whether the current user can view Telegram Stars revenue for this chat */
get canViewStarsRevenue(): boolean {
return this.fullPeer._ === 'channelFull' && this.fullPeer.canViewStats!
return this.fullPeer._ === 'channelFull' && this.fullPeer.canViewStarsRevenue!
}
/** Whether the current user can view ad revenue for this chat */
get canViewAdRevenue(): boolean {
return this.fullPeer._ === 'channelFull' && this.fullPeer.canViewRevenue!
}
/** If this chat is a bot, whether the current user can manage its emoji status */
get canManageBotEmojiStatus(): boolean {
return this.fullPeer._ === 'userFull' && this.fullPeer.botCanManageEmojiStatus!
}
/**

View file

@ -23,6 +23,33 @@ export class StarGift {
return this.raw.id
}
/** Whether this gift sold out and cannot be bought anymore */
get isSoldOut(): boolean {
return this.raw.soldOut!
}
/** Whether this gift has limited availability */
get isLimited(): boolean {
return this.raw.limited!
}
/** Additional information for sold-out gifts */
get soldOutInfo(): {
/** Date when the first gift was bought */
firstSale: Date
/** Date when the last gift was bought */
lastSale: Date
} | null {
if (this.raw.firstSaleDate == null || this.raw.lastSaleDate == null) {
return null
}
return {
firstSale: new Date(this.raw.firstSaleDate * 1000),
lastSale: new Date(this.raw.lastSaleDate * 1000),
}
}
/** Sticker associated with the gift */
get sticker(): Sticker {
assertTypeIs('StarGift#sticker', this.raw.sticker, 'document')
@ -52,7 +79,7 @@ export class StarGift {
* the number of remaining and total gifts available
*/
get availability(): { remains: number, total: number } | null {
if (!this.raw.availabilityRemains || !this.raw.availabilityTotal) {
if (this.raw.availabilityRemains == null || this.raw.availabilityTotal == null) {
return null
}

View file

@ -26,6 +26,8 @@ import { StarGift } from './stars-gift.js'
* - `bot_purchase`: This transaction is a purchase at a bot-operated store
* - `channel_subscription`: This transaction is a subscription to a channel
* - `star_gift`: This transaction is either a star gift to a user (if outgoing), or converting a star gift to stars (if incoming)
* - `api_*`: This transaction is a payment for paid API features
* - `api_floodskip`: This transaction is a payment for a paid bot broadcast
*/
export type StarsTransactionType =
| { type: 'unsupported' }
@ -123,6 +125,11 @@ export type StarsTransactionType =
/** The gift */
gift: StarGift
}
| {
type: 'api_floodskip'
/** The number of billed API calls */
count: number
}
export class StarsTransaction {
constructor(
@ -200,6 +207,15 @@ export class StarsTransaction {
}
case 'starsTransactionPeerAds':
return { type: 'ads' }
case 'starsTransactionPeerAPI':
if (this.raw.floodskipNumber != null) {
return {
type: 'api_floodskip',
count: this.raw.floodskipNumber,
}
}
return { type: 'unsupported' }
case 'starsTransactionPeer': {
const peer = parsePeer(this.raw.peer.peer, this.peers)

View file

@ -2,7 +2,7 @@
TL schema and related utils used for mtcute.
Generated from TL layer **189** (last updated on 05.10.2024).
Generated from TL layer **194** (last updated on 20.11.2024).
## About

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "@mtcute/tl",
"version": "189.0.0",
"version": "194.0.0",
"description": "TL schema used for mtcute",
"author": "alina sireneva <alina@tei.su>",
"license": "MIT",