Compare commits
2 commits
016a6dce3f
...
6e4661acd1
Author | SHA1 | Date | |
---|---|---|---|
6e4661acd1 | |||
92aa5ecc8a |
14 changed files with 86 additions and 8 deletions
|
@ -35,6 +35,7 @@ export default ({ mode }) => defineConfig({
|
|||
// https://vitepress.dev/reference/default-theme-config
|
||||
nav: [
|
||||
{ text: 'Guide', link: '/guide/' },
|
||||
{ text: 'Playground', link: '//play.mtcute.dev' },
|
||||
{ text: 'Reference', link: '//ref.mtcute.dev' },
|
||||
],
|
||||
socialLinks: [
|
||||
|
|
|
@ -11,6 +11,9 @@ hero:
|
|||
- theme: brand
|
||||
text: Quick Start →
|
||||
link: /guide/
|
||||
- theme: alt
|
||||
text: 📝 Try online
|
||||
link: //play.mtcute.dev
|
||||
- theme: alt
|
||||
text: API Reference
|
||||
link: //ref.mtcute.dev
|
||||
|
|
|
@ -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 { CanSendStoryResult } from './methods/stories/can-send-story.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 { RawUpdateInfo } from './updates/types.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 { getStarGifts } from './methods/premium/get-star-gifts.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 { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
||||
import { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
||||
|
@ -4746,6 +4747,11 @@ export interface TelegramClient extends ITelegramClient {
|
|||
*/
|
||||
limit?: number
|
||||
}): Promise<StarsStatus>
|
||||
/**
|
||||
* Get information about a unique star gift by its slug
|
||||
*/
|
||||
getUniqueStarGift(
|
||||
slug: string): Promise<StarGiftUnique>
|
||||
/**
|
||||
* Iterate over boosters of a channel.
|
||||
*
|
||||
|
@ -6788,6 +6794,9 @@ TelegramClient.prototype.getStarGifts = function (...args) {
|
|||
TelegramClient.prototype.getStarsTransactions = function (...args) {
|
||||
return getStarsTransactions(this._client, ...args)
|
||||
}
|
||||
TelegramClient.prototype.getUniqueStarGift = function (...args) {
|
||||
return getUniqueStarGift(this._client, ...args)
|
||||
}
|
||||
TelegramClient.prototype.iterBoosters = function (...args) {
|
||||
return iterBoosters(this._client, ...args)
|
||||
}
|
||||
|
|
|
@ -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 { getStarGifts } from './methods/premium/get-star-gifts.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 { iterStarGifts } from './methods/premium/iter-star-gifts.js'
|
||||
export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js'
|
||||
|
|
|
@ -90,6 +90,7 @@ import {
|
|||
ReplyMarkup,
|
||||
SentCode,
|
||||
StarGift,
|
||||
StarGiftUnique,
|
||||
StarsStatus,
|
||||
StarsTransaction,
|
||||
Sticker,
|
||||
|
|
|
@ -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)
|
||||
}
|
|
@ -139,11 +139,22 @@ export class StarGiftUnique {
|
|||
return this.raw.title
|
||||
}
|
||||
|
||||
/** ID of the user who owns this gift */
|
||||
get owner(): User {
|
||||
/** Slug of the gift */
|
||||
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))
|
||||
}
|
||||
|
||||
/** Name of the user who owns this gift, if available */
|
||||
get ownerName(): string | null {
|
||||
return this.raw.ownerName ?? null
|
||||
}
|
||||
|
||||
get availabilityIssued(): number {
|
||||
return this.raw.availabilityIssued
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { MtTypeAssertionError } from '../../../../types/errors.js'
|
|||
import { StoryInteractiveChannelPost } from './channel-post.js'
|
||||
import { StoryInteractiveLocation } from './location.js'
|
||||
import { StoryInteractiveReaction } from './reaction.js'
|
||||
import { StoryInteractiveStarGift } from './star-gift.js'
|
||||
import { StoryInteractiveUrl } from './url.js'
|
||||
import { StoryInteractiveVenue } from './venue.js'
|
||||
import { StoryInteractiveWeather } from './weather.js'
|
||||
|
@ -15,6 +16,7 @@ export {
|
|||
StoryInteractiveChannelPost,
|
||||
StoryInteractiveLocation,
|
||||
StoryInteractiveReaction,
|
||||
StoryInteractiveStarGift,
|
||||
StoryInteractiveUrl,
|
||||
StoryInteractiveVenue,
|
||||
StoryInteractiveWeather,
|
||||
|
@ -27,6 +29,7 @@ export type StoryInteractiveElement =
|
|||
| StoryInteractiveChannelPost
|
||||
| StoryInteractiveUrl
|
||||
| StoryInteractiveWeather
|
||||
| StoryInteractiveStarGift
|
||||
|
||||
export function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {
|
||||
switch (raw._) {
|
||||
|
@ -42,6 +45,8 @@ export function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: Pee
|
|||
return new StoryInteractiveUrl(raw)
|
||||
case 'mediaAreaWeather':
|
||||
return new StoryInteractiveWeather(raw)
|
||||
case 'mediaAreaStarGift':
|
||||
return new StoryInteractiveStarGift(raw)
|
||||
case 'inputMediaAreaVenue':
|
||||
case 'inputMediaAreaChannelPost':
|
||||
throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)
|
||||
|
|
|
@ -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)
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mtcute/tl",
|
||||
"version": "196.0.0",
|
||||
"version": "197.0.0",
|
||||
"description": "TL schema used for mtcute",
|
||||
"author": "alina sireneva <alina@tei.su>",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -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 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_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.
|
||||
"use strict";
|
||||
|
|
|
@ -137,7 +137,7 @@ async function fetchWebaSchema(): Promise<Schema> {
|
|||
])
|
||||
|
||||
// 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')
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue