Compare commits

..

2 commits

Author SHA1 Message Date
6e4661acd1
build: updated to layer 197
All checks were successful
Build and deploy docs / build (push) Successful in 1m27s
Tests / test-deno (push) Successful in 1m49s
Tests / test-bun (push) Successful in 1m59s
Tests / test-node (node22) (push) Successful in 2m5s
Tests / test-node (node20) (push) Successful in 2m9s
Tests / test-node (node18) (push) Successful in 2m13s
Tests / test-web (chromium) (push) Successful in 2m9s
Tests / test-web (firefox) (push) Successful in 2m19s
Build and deploy typedoc / build (push) Successful in 6m1s
Tests / lint (push) Successful in 6m44s
Tests / e2e (push) Successful in 48s
Tests / e2e-deno (push) Successful in 51s
2025-01-22 09:33:24 +03:00
92aa5ecc8a
docs: added link to playground 2025-01-21 00:59:03 +03:00
14 changed files with 86 additions and 8 deletions

View file

@ -35,6 +35,7 @@ export default ({ mode }) => defineConfig({
// https://vitepress.dev/reference/default-theme-config // https://vitepress.dev/reference/default-theme-config
nav: [ nav: [
{ text: 'Guide', link: '/guide/' }, { text: 'Guide', link: '/guide/' },
{ text: 'Playground', link: '//play.mtcute.dev' },
{ text: 'Reference', link: '//ref.mtcute.dev' }, { text: 'Reference', link: '//ref.mtcute.dev' },
], ],
socialLinks: [ socialLinks: [

View file

@ -11,6 +11,9 @@ hero:
- theme: brand - theme: brand
text: Quick Start → text: Quick Start →
link: /guide/ link: /guide/
- theme: alt
text: 📝  Try online
link: //play.mtcute.dev
- theme: alt - theme: alt
text: API Reference text: API Reference
link: //ref.mtcute.dev link: //ref.mtcute.dev

View file

@ -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, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, PeerReaction, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SentCode, StarGift, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js' 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'
@ -224,6 +224,7 @@ import { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
import { getStarGiftOptions } from './methods/premium/get-star-gift-options.js' import { getStarGiftOptions } from './methods/premium/get-star-gift-options.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 { iterBoosters } from './methods/premium/iter-boosters.js' import { iterBoosters } from './methods/premium/iter-boosters.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'
@ -4746,6 +4747,11 @@ export interface TelegramClient extends ITelegramClient {
*/ */
limit?: number limit?: number
}): Promise<StarsStatus> }): Promise<StarsStatus>
/**
* Get information about a unique star gift by its slug
*/
getUniqueStarGift(
slug: string): Promise<StarGiftUnique>
/** /**
* Iterate over boosters of a channel. * Iterate over boosters of a channel.
* *
@ -6788,6 +6794,9 @@ TelegramClient.prototype.getStarGifts = function (...args) {
TelegramClient.prototype.getStarsTransactions = function (...args) { TelegramClient.prototype.getStarsTransactions = function (...args) {
return getStarsTransactions(this._client, ...args) return getStarsTransactions(this._client, ...args)
} }
TelegramClient.prototype.getUniqueStarGift = function (...args) {
return getUniqueStarGift(this._client, ...args)
}
TelegramClient.prototype.iterBoosters = function (...args) { TelegramClient.prototype.iterBoosters = function (...args) {
return iterBoosters(this._client, ...args) return iterBoosters(this._client, ...args)
} }

View file

@ -224,6 +224,7 @@ export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js'
export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js' export { getStarGiftOptions } from './methods/premium/get-star-gift-options.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 { iterBoosters } from './methods/premium/iter-boosters.js' export { iterBoosters } from './methods/premium/iter-boosters.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'

View file

@ -90,6 +90,7 @@ import {
ReplyMarkup, ReplyMarkup,
SentCode, SentCode,
StarGift, StarGift,
StarGiftUnique,
StarsStatus, StarsStatus,
StarsTransaction, StarsTransaction,
Sticker, Sticker,

View file

@ -0,0 +1,22 @@
import type { ITelegramClient } from '../../client.types.js'
import { assert } from '@fuman/utils'
import { PeersIndex, StarGiftUnique } from '../../types/index.js'
/**
* Get information about a unique star gift by its slug
*/
export async function getUniqueStarGift(
client: ITelegramClient,
slug: string,
): Promise<StarGiftUnique> {
const res = await client.call({
_: 'payments.getUniqueStarGift',
slug,
})
const peers = PeersIndex.from(res)
assert(res.gift._ === 'starGiftUnique')
return new StarGiftUnique(res.gift, peers)
}

View file

@ -139,11 +139,22 @@ export class StarGiftUnique {
return this.raw.title return this.raw.title
} }
/** ID of the user who owns this gift */ /** Slug of the gift */
get owner(): User { get slug(): string {
return this.raw.slug
}
/** ID of the user who owns this gift, if available */
get owner(): User | null {
if (!this.raw.ownerId) return null
return new User(this._peers.user(this.raw.ownerId)) return new User(this._peers.user(this.raw.ownerId))
} }
/** Name of the user who owns this gift, if available */
get ownerName(): string | null {
return this.raw.ownerName ?? null
}
get availabilityIssued(): number { get availabilityIssued(): number {
return this.raw.availabilityIssued return this.raw.availabilityIssued
} }

View file

@ -6,6 +6,7 @@ import { MtTypeAssertionError } from '../../../../types/errors.js'
import { StoryInteractiveChannelPost } from './channel-post.js' import { StoryInteractiveChannelPost } from './channel-post.js'
import { StoryInteractiveLocation } from './location.js' import { StoryInteractiveLocation } from './location.js'
import { StoryInteractiveReaction } from './reaction.js' import { StoryInteractiveReaction } from './reaction.js'
import { StoryInteractiveStarGift } from './star-gift.js'
import { StoryInteractiveUrl } from './url.js' import { StoryInteractiveUrl } from './url.js'
import { StoryInteractiveVenue } from './venue.js' import { StoryInteractiveVenue } from './venue.js'
import { StoryInteractiveWeather } from './weather.js' import { StoryInteractiveWeather } from './weather.js'
@ -15,6 +16,7 @@ export {
StoryInteractiveChannelPost, StoryInteractiveChannelPost,
StoryInteractiveLocation, StoryInteractiveLocation,
StoryInteractiveReaction, StoryInteractiveReaction,
StoryInteractiveStarGift,
StoryInteractiveUrl, StoryInteractiveUrl,
StoryInteractiveVenue, StoryInteractiveVenue,
StoryInteractiveWeather, StoryInteractiveWeather,
@ -27,6 +29,7 @@ export type StoryInteractiveElement =
| StoryInteractiveChannelPost | StoryInteractiveChannelPost
| StoryInteractiveUrl | StoryInteractiveUrl
| StoryInteractiveWeather | StoryInteractiveWeather
| StoryInteractiveStarGift
export function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement { export function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {
switch (raw._) { switch (raw._) {
@ -42,6 +45,8 @@ export function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: Pee
return new StoryInteractiveUrl(raw) return new StoryInteractiveUrl(raw)
case 'mediaAreaWeather': case 'mediaAreaWeather':
return new StoryInteractiveWeather(raw) return new StoryInteractiveWeather(raw)
case 'mediaAreaStarGift':
return new StoryInteractiveStarGift(raw)
case 'inputMediaAreaVenue': case 'inputMediaAreaVenue':
case 'inputMediaAreaChannelPost': case 'inputMediaAreaChannelPost':
throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._) throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)

View file

@ -0,0 +1,25 @@
import type { tl } from '@mtcute/tl'
import { makeInspectable } from '../../../utils/index.js'
import { StoryInteractiveArea } from './base.js'
/**
* Interactive element containing a star gift
*/
export class StoryInteractiveStarGift extends StoryInteractiveArea {
readonly type = 'star_gift' as const
constructor(
override readonly raw: tl.RawMediaAreaStarGift,
) {
super(raw)
}
/** Star gift slug */
get slug(): string {
return this.raw.slug
}
}
makeInspectable(StoryInteractiveStarGift)

View file

@ -2,7 +2,7 @@
TL schema and related utils used for mtcute. TL schema and related utils used for mtcute.
Generated from TL layer **196** (last updated on 01.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

View file

@ -1,6 +1,6 @@
{ {
"name": "@mtcute/tl", "name": "@mtcute/tl",
"version": "196.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",

View file

@ -22,7 +22,7 @@ export const TDESKTOP_LAYER
export const TDLIB_SCHEMA = 'https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/telegram_api.tl' export const TDLIB_SCHEMA = 'https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/telegram_api.tl'
export const WEBK_SCHEMA = 'https://raw.githubusercontent.com/morethanwords/tweb/master/src/scripts/in/schema.json' export const WEBK_SCHEMA = 'https://raw.githubusercontent.com/morethanwords/tweb/master/src/scripts/in/schema.json'
export const WEBA_SCHEMA = 'https://raw.githubusercontent.com/Ajaxy/telegram-tt/master/src/lib/gramjs/tl/static/api.tl' export const WEBA_SCHEMA = 'https://raw.githubusercontent.com/Ajaxy/telegram-tt/master/src/lib/gramjs/tl/static/api.tl'
export const WEBA_LAYER = 'https://raw.githubusercontent.com/Ajaxy/telegram-tt/master/src/lib/gramjs/tl/AllTLObjects.js' export const WEBA_LAYER = 'https://raw.githubusercontent.com/Ajaxy/telegram-tt/master/src/lib/gramjs/tl/AllTLObjects.ts'
export const ESM_PRELUDE = `// This file is auto-generated. Do not edit. export const ESM_PRELUDE = `// This file is auto-generated. Do not edit.
"use strict"; "use strict";

View file

@ -137,7 +137,7 @@ async function fetchWebaSchema(): Promise<Schema> {
]) ])
// const LAYER = 174; // const LAYER = 174;
const version = layerFile.match(/^const LAYER = (\d+);$/m) const version = layerFile.match(/^export const LAYER = (\d+);$/m)
if (!version) throw new Error('Layer number not found') if (!version) throw new Error('Layer number not found')
return { return {