feat(client): support webm stickers
This commit is contained in:
parent
9543f64558
commit
daff3e62a0
3 changed files with 25 additions and 7 deletions
|
@ -21,8 +21,12 @@ export function parseDocument(
|
|||
}
|
||||
case 'documentAttributeSticker': {
|
||||
const sz = doc.attributes.find(
|
||||
(it) => it._ === 'documentAttributeImageSize'
|
||||
)! as tl.RawDocumentAttributeImageSize
|
||||
(it) =>
|
||||
it._ === 'documentAttributeImageSize' ||
|
||||
it._ === 'documentAttributeVideo'
|
||||
)! as
|
||||
| tl.RawDocumentAttributeImageSize
|
||||
| tl.RawDocumentAttributeVideo
|
||||
return new Sticker(client, doc, attr, sz)
|
||||
}
|
||||
case 'documentAttributeVideo':
|
||||
|
|
|
@ -50,7 +50,7 @@ export class Sticker extends RawDocument {
|
|||
client: TelegramClient,
|
||||
doc: tl.RawDocument,
|
||||
readonly attr: tl.RawDocumentAttributeSticker,
|
||||
readonly attrSize?: tl.RawDocumentAttributeImageSize
|
||||
readonly attr2?: tl.RawDocumentAttributeImageSize | tl.RawDocumentAttributeVideo
|
||||
) {
|
||||
super(client, doc)
|
||||
}
|
||||
|
@ -59,14 +59,21 @@ export class Sticker extends RawDocument {
|
|||
* Sticker width in pixels
|
||||
*/
|
||||
get width(): number {
|
||||
return this.attrSize?.w ?? 512
|
||||
return this.attr2?.w ?? 512
|
||||
}
|
||||
|
||||
/**
|
||||
* Sticker height in pixels
|
||||
*/
|
||||
get height(): number {
|
||||
return this.attrSize?.h ?? 512
|
||||
return this.attr2?.h ?? 512
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this sticker is a video (WEBM) sticker
|
||||
*/
|
||||
get isVideoSticker(): boolean {
|
||||
return this.attr2?._ === 'documentAttributeVideo'
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,8 +84,8 @@ export class Sticker extends RawDocument {
|
|||
*/
|
||||
get isValidSticker(): boolean {
|
||||
return (
|
||||
this.attrSize !== undefined &&
|
||||
(this.attrSize.w === 512 || this.attrSize.h === 512)
|
||||
this.attr2 !== undefined &&
|
||||
(this.attr2.w === 512 || this.attr2.h === 512)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,13 @@ export class StickerSet {
|
|||
return this.brief.animated!
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this stickerset is video (WEBM)
|
||||
*/
|
||||
get isVideo(): boolean {
|
||||
return this.brief.videos!
|
||||
}
|
||||
|
||||
/**
|
||||
* Date when this stickerset was installed
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue